[all-commits] [llvm/llvm-project] 06ca0a: [InstCombine] (~a & b & c) | ~(a | b | c) -> ~(a |...
Stanislav Mekhanoshin via All-commits
all-commits at lists.llvm.org
Thu Dec 9 09:51:12 PST 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 06ca0a273308112c660dddf14c92fe14957bd468
https://github.com/llvm/llvm-project/commit/06ca0a273308112c660dddf14c92fe14957bd468
Author: Stanislav Mekhanoshin <Stanislav.Mekhanoshin at amd.com>
Date: 2021-12-09 (Thu, 09 Dec 2021)
Changed paths:
M llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
M llvm/test/Transforms/InstCombine/and-xor-or.ll
Log Message:
-----------
[InstCombine] (~a & b & c) | ~(a | b | c) -> ~(a | (b ^ c))
Transform
```
(~a & b & c) | ~(a | b | c) -> ~(a | (b ^ c))
```
And swapped case:
```
(~a | b | c) & ~(a & b & c) -> ~a | (b ^ c)
```
```
----------------------------------------
define i4 @src(i4 %a, i4 %b, i4 %c) {
%0:
%or1 = or i4 %b, %a
%or2 = or i4 %or1, %c
%not1 = xor i4 %or2, 15
%not2 = xor i4 %a, 15
%and1 = and i4 %b, %not2
%and2 = and i4 %and1, %c
%or3 = or i4 %and2, %not1
ret i4 %or3
}
=>
define i4 @tgt(i4 %a, i4 %b, i4 %c) {
%0:
%1 = xor i4 %c, %b
%2 = or i4 %1, %a
%or3 = xor i4 %2, 15
ret i4 %or3
}
Transformation seems to be correct!
```
```
----------------------------------------
define i4 @src(i4 %a, i4 %b, i4 %c) {
%0:
%and1 = and i4 %b, %a
%and2 = and i4 %and1, %c
%not1 = xor i4 %and2, 15
%not2 = xor i4 %a, 15
%or1 = or i4 %not2, %b
%or2 = or i4 %or1, %c
%and3 = and i4 %or2, %not1
ret i4 %and3
}
=>
define i4 @tgt(i4 %a, i4 %b, i4 %c) {
%0:
%xor = xor i4 %b, %c
%not = xor i4 %a, 15
%or = or i4 %xor, %not
ret i4 %or
}
Transformation seems to be correct!
```
Differential Revision: https://reviews.llvm.org/D112966
More information about the All-commits
mailing list