[PATCH] D113216: [InstCombine] (~(a | b) & c) | ~(a | b | c) -> ~(a | b)
Stanislav Mekhanoshin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 4 14:48:32 PDT 2021
rampitec created this revision.
rampitec added a reviewer: spatel.
Herald added a subscriber: hiraditya.
rampitec requested review of this revision.
Herald added a project: LLVM.
This handles expressions:
`(~(a | b) & c) | ~(a | (b | c))` -> `~(a | b)`
`(~(a | b) & c) | ~(b | (a | c))` -> `~(a | b)`
The expression `(~(a | b) & c) | ~((a | b) | c)` is just an
`(~x & c) | ~(x | c)` and will be simplified without this
patch but two cases above need reassociation.
----------------------------------------
define i4 @src(i4 %a, i4 %b, i4 %c) {
%0:
%or1 = or i4 %c, %a
%or2 = or i4 %or1, %b
%not1 = xor i4 %or2, 15
%or3 = or i4 %a, %b
%not2 = xor i4 %or3, 15
%and2 = and i4 %not2, %c
%or4 = or i4 %and2, %not1
ret i4 %or4
}
=>
define i4 @tgt(i4 %a, i4 %b, i4 %c) {
%0:
%or = or i4 %a, %b
%not = xor i4 %or, 15
ret i4 %not
}
Transformation seems to be correct!
https://reviews.llvm.org/D113216
Files:
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/test/Transforms/InstCombine/and-xor-or.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113216.384870.patch
Type: text/x-patch
Size: 6667 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211104/7ee4aa71/attachment.bin>
More information about the llvm-commits
mailing list