diff options
author | Stanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com> | 2021-11-09 13:06:15 -0800 |
---|---|---|
committer | Stanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com> | 2021-11-17 10:47:36 -0800 |
commit | 6d3db28088267203ab4a42c5da0d53c0a259f316 (patch) | |
tree | 2865135e9a3b2961b8f38a59c00dcf16f48d2a59 /clang/lib/Frontend/InitPreprocessor.cpp | |
parent | 1718fe4643925f4c9788ccb3f7c5779cae394a2a (diff) | |
download | llvm-6d3db28088267203ab4a42c5da0d53c0a259f316.zip llvm-6d3db28088267203ab4a42c5da0d53c0a259f316.tar.gz llvm-6d3db28088267203ab4a42c5da0d53c0a259f316.tar.bz2 |
[InstCombine] Generalize complex OR patterns to AND
For every pattern with only NOT, OR, and AND operations there is
always a symmetrical attern with AND and OR swapped.
This adds 2 transformations: https://reviews.llvm.org/D113526
```
(~(a & b) | c) & (~(a & c) | b) --> ~((b ^ c) & a)
(~(a & b) | c) & ~(a & c) --> ~((b | c) & a)
```
```
----------------------------------------
define i4 @src(i4 %a, i4 %b, i4 %c) {
%0:
%and1 = and i4 %b, %a
%not1 = xor i4 %and1, 15
%and2 = and i4 %a, %c
%not2 = xor i4 %and2, 15
%or = or i4 %not2, %b
%r = and i4 %or, %not1
ret i4 %r
}
=>
define i4 @tgt(i4 %a, i4 %b, i4 %c) {
%0:
%or = or i4 %b, %c
%and = and i4 %or, %a
%r = xor i4 %and, 15
ret i4 %r
}
Transformation seems to be correct!
----------------------------------------
define i4 @src(i4 %a, i4 %b, i4 %c) {
%0:
%and1 = and i4 %a, %b
%not1 = xor i4 %and1, 15
%or1 = or i4 %not1, %c
%and2 = and i4 %a, %c
%not2 = xor i4 %and2, 15
%or2 = or i4 %not2, %b
%and3 = and i4 %or1, %or2
ret i4 %and3
}
=>
define i4 @tgt(i4 %a, i4 %b, i4 %c) {
%0:
%xor = xor i4 %b, %c
%and = and i4 %xor, %a
%not = xor i4 %and, 15
ret i4 %not
}
Transformation seems to be correct!
```
Differential Revision: https://reviews.llvm.org/D113526
Diffstat (limited to 'clang/lib/Frontend/InitPreprocessor.cpp')
0 files changed, 0 insertions, 0 deletions