]> granicus.if.org Git - llvm/commit
[InstCombine] Fold sub (and A, B) (or A, B)) to neg (xor A, B)
authorDavid Bolvansky <david.bolvansky@gmail.com>
Wed, 4 Sep 2019 17:30:53 +0000 (17:30 +0000)
committerDavid Bolvansky <david.bolvansky@gmail.com>
Wed, 4 Sep 2019 17:30:53 +0000 (17:30 +0000)
commit9a3265114abd2e18a6edb48d16969d469638a291
treedba975037edd3e5b4b586031ff9d536438489a27
parent2aeb54d7d4bb0d8847bd2264145731fb765987e9
[InstCombine] Fold sub (and A, B) (or A, B)) to neg (xor A, B)

Summary:
```
Name: sub(and(x, y), or(x, y)) -> neg(xor(x, y))
%or = or i32 %y, %x
%and = and i32 %x, %y
%sub = sub i32 %and, %or
  =>
%sub1 = xor i32 %x, %y
%sub = sub i32 0, %sub1

Optimization: sub(and(x, y), or(x, y)) -> neg(xor(x, y))
Done: 1
Optimization is correct!
```

https://rise4fun.com/Alive/VI6

Found by @lebedev.ri. Also author of the proof.

Reviewers: lebedev.ri, spatel

Reviewed By: lebedev.ri

Subscribers: llvm-commits, lebedev.ri

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D67155

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@370934 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineAddSub.cpp
test/Transforms/InstCombine/sub-and-or-not-xor.ll