[PATCH] D112108: [InstCombine] Fold `(a & ~b) & ~c` to `a & ~(b | c)`
Stanislav Mekhanoshin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 21 10:04:26 PDT 2021
rampitec added a comment.
In D112108#3077962 <https://reviews.llvm.org/D112108#3077962>, @spatel wrote:
> I forgot to mention it during the review, but we should always have these kinds of bitwise logic folds apply to the Demorgan'ized sibling form too (and this fold itself is just reassociation + Demorgan):
> 3888de9507c7 <https://reviews.llvm.org/rG3888de9507c78d3d77a4f565f30a3bf1b2fce690>
Thanks Sanjay! I now wander if a next testcase I am looking at needs a pattern as I wanted to add to `visitOr`, because it also looks like a more complex case of reassociation:
(c & ~(a | b)) | (b & ~(a | c)) --> ~a & (b ^ c)
We currently cannot simplify it.
define i32 @or_not_and(i32 %a, i32 %b, i32 %c) {
%or1 = or i32 %a, %b
%not1 = xor i32 %or1, -1
%and1 = and i32 %not1, %c
%or2 = or i32 %a, %c
%not2 = xor i32 %or2, -1
%and2 = and i32 %not2, %b
%or3 = or i32 %and1, %and2
ret i32 %or3
}
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D112108/new/
https://reviews.llvm.org/D112108
More information about the llvm-commits
mailing list