[InstCombine] Transform (A + B) - (A & B) to A | B (PR48604)
authorDávid Bolvanský <david.bolvansky@gmail.com>
Thu, 31 Dec 2020 14:04:32 +0000 (15:04 +0100)
committerDávid Bolvanský <david.bolvansky@gmail.com>
Thu, 31 Dec 2020 14:04:32 +0000 (15:04 +0100)
commitae69fa9b9f65f59cc0ca8c47f23748a53c8dbdc5
tree3da849b22a4e47e48d439aa8d52d12babc35afb8
parentc1937c2af2a03f0b5fda3bbf99e2971ffa04ff0c
[InstCombine] Transform (A + B) - (A & B) to A | B (PR48604)

define i32 @src(i32 %x, i32 %y) {
%0:
  %a = add i32 %x, %y
  %o = and i32 %x, %y
  %r = sub i32 %a, %o
  ret i32 %r
}
=>
define i32 @tgt(i32 %x, i32 %y) {
%0:
  %b = or i32 %x, %y
  ret i32 %b
}
Transformation seems to be correct!

https://alive2.llvm.org/ce/z/2fhW6r
llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
llvm/test/Transforms/InstCombine/sub.ll