[ValueTracking] Checking haveNoCommonBitsSet for (x & y) and ~(x | y)
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>
Tue, 25 Jan 2022 03:12:25 +0000 (11:12 +0800)
committerChuanqi Xu <yedeng.yd@linux.alibaba.com>
Wed, 16 Feb 2022 05:42:52 +0000 (13:42 +0800)
commita2609be0b284bfa55edf78e607eb426679cfea3d
tree0696b463625f6ab94a67668805c6e6b2e9b91ebf
parentd30ca5e2e23fe50dcd8d5d602bf7cfc61b4c1561
[ValueTracking] Checking haveNoCommonBitsSet for (x & y) and ~(x | y)

This one tries to fix:
https://github.com/llvm/llvm-project/issues/53357.

Simply, this one would check (x & y) and ~(x | y) in
haveNoCommonBitsSet. Since they shouldn't have common bits (we could
traverse the case by enumerating), and we could convert this one to (x &
y) | ~(x | y) . Then the compiler could handle it in
InstCombineAndOrXor.
Further more, since ((x & y) + (~x & ~y)) would be converted to ((x & y)
+ ~(x | y)), this patch would fix it too.

https://alive2.llvm.org/ce/z/qsKzRS

Reviewed By: spatel, xbolva00, RKSimon, lebedev.ri

Differential Revision: https://reviews.llvm.org/D118094
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/InstCombine/pr53357.ll
llvm/unittests/Analysis/ValueTrackingTest.cpp