[TargetLowering] Check boolean content when folding bit compare
authorSven van Haastregt <sven.vanhaastregt@arm.com>
Wed, 21 Oct 2020 10:46:55 +0000 (11:46 +0100)
committerSven van Haastregt <sven.vanhaastregt@arm.com>
Wed, 21 Oct 2020 10:46:55 +0000 (11:46 +0100)
commitbfc961aeb2d0e5a05bca7a894cbc4370f5e79a6a
tree5d101e7086516222ec8b40fdf9e246a51c6698b3
parent1af51f077b003253ff50567022efd1e850b2ec54
[TargetLowering] Check boolean content when folding bit compare

Updates an optimization that relies on boolean contents being either 0
or 1 to properly check for this before triggering.

The following:
  (X & 8) != 0 --> (X & 8) >> 3
Produces unexpected results when a boolean 'true' value is represented
by negative one.

Patch by Erik Hogeman.

Differential Revision: https://reviews.llvm.org/D89390
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/test/CodeGen/NVPTX/pow2_mask_cmp.ll