[InstCombine] Fold `a & ~(a ^ b)` to `x & y`
authorRoman Lebedev <lebedev.ri@gmail.com>
Thu, 24 Dec 2020 11:09:49 +0000 (14:09 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Thu, 24 Dec 2020 18:20:49 +0000 (21:20 +0300)
commit5b78303433c0778a839e89d20daa57fbc037d0c7
tree93ea5f7ab268da0078bf9ec3caad59d03312f843
parent1fda23367d46955fcb6e605f4114d47e499f0901
[InstCombine] Fold `a & ~(a ^ b)` to `x & y`

```
----------------------------------------
define i32 @and_xor_not_common_op(i32 %a, i32 %b) {
%0:
  %b2 = xor i32 %b, 4294967295
  %t2 = xor i32 %a, %b2
  %t4 = and i32 %t2, %a
  ret i32 %t4
}
=>
define i32 @and_xor_not_common_op(i32 %a, i32 %b) {
%0:
  %t4 = and i32 %a, %b
  ret i32 %t4
}
Transformation seems to be correct!
```
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/test/Transforms/InstCombine/and-xor-or.ll