[ValueTracking] Determine assume KnownBits using ConstantRange
authorNikita Popov <npopov@redhat.com>
Wed, 5 Jul 2023 10:02:42 +0000 (12:02 +0200)
committerNikita Popov <npopov@redhat.com>
Wed, 5 Jul 2023 12:00:03 +0000 (14:00 +0200)
commitc6a4fc8ddfaf68d932b69b80a1efd0742fa8211a
tree6986ec85f47ffc7277a07d05efb5c0712bc0e508
parentf6df11568e83960ef698fc979965428c6b431344
[ValueTracking] Determine assume KnownBits using ConstantRange

For non-equality icmps, we don't do any KnownBits-specific
reasoning, and just use the known bits as a constraint on the range.
We can generalize this for all predicates by round-tripping through
ConstantRange and using makeAllowedICmpRegion().

The minor improvement in zext-or-icmp is because we assume that
a value is ult [0,1], which means it must be zero.
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/InstCombine/zext-or-icmp.ll