[PATCH] D112108: [InstCombine] Fold `(a & ~b) & ~c` to `a & ~(b | c)`
Stanislav Mekhanoshin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 20 11:17:51 PDT 2021
rampitec added a comment.
In D112108#3074952 <https://reviews.llvm.org/D112108#3074952>, @spatel wrote:
> This seems like another short-coming of the reassociation pass, but I think it's ok to deal with the minimal case here.
> For example (if I'm seeing it correctly), this test still won't change:
>
> define i4 @src(i4 %a, i4 %b, i4 %c, i4 %d) {
> %notb = xor i4 %b, -1
> %notc = xor i4 %c, -1
> %and1 = and i4 %a, %notb
> %and2 = and i4 %and1, %d
> %and3 = and i4 %and2, %notc
> ret i4 %and3
> }
>
> https://alive2.llvm.org/ce/z/_T8ZhP
Yes, this test does not change.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:2024-2025
+
+ // ~C & (A & ~B) -> A & ~(B | C)
+ // ~C & (~B & A) -> A & ~(B | C)
+ if (match(Op1, m_c_And(m_Value(A), m_Not(m_Value(B)))))
----------------
spatel wrote:
> I suspect this is dead code (so it can be removed) - complexity-based canonicalization should guarantee that an `and` is always op0 in this pattern.
That seems to be right. Removed.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D112108/new/
https://reviews.llvm.org/D112108
More information about the llvm-commits
mailing list