[XLA] Emit saturating shifts on CPU, GPU and interpreter
authorSanjoy Das <sanjoy@google.com>
Wed, 21 Feb 2018 00:13:11 +0000 (16:13 -0800)
committerTensorFlower Gardener <gardener@tensorflow.org>
Wed, 21 Feb 2018 00:16:54 +0000 (16:16 -0800)
commit8e44ce68ea102f8d6fde317fbe38e0c58b59b9af
tree616fde5db1283b7f8a9abb13f978b02d77bffd48
parent776fa148b4772afb3e000ec15c3b3e6eb9f43a52
[XLA] Emit saturating shifts on CPU, GPU and interpreter

With this change shifting out >= bitwidth for shift left and logical shift right
produces 0, and shifting out >= bitwidth for arithmetic shift right produces -1
if the LHS is negative and 0 otherwise.  Before this we were invoking undefined
behavior for these out-of-bounds shifts in LLVM and the HLO evaluator.

PiperOrigin-RevId: 186379160
tensorflow/compiler/xla/service/elemental_ir_emitter.cc
tensorflow/compiler/xla/service/hlo_evaluator.cc
tensorflow/compiler/xla/tests/array_elementwise_ops_test.cc