[llvm] [InstSimplify] Simplify the expression `(a^c)&(a^~c)` to zero (PR #76637)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 2 09:49:35 PST 2024
================
@@ -2204,6 +2204,13 @@ static Value *simplifyAndInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
match(Op1, m_c_Xor(m_Specific(Or), m_Specific(Y))))
return Constant::getNullValue(Op0->getType());
+ const APInt *C1, *C2;
+ Value *A;
+ // (A ^ C) & (A ^ ~C) -> 0
+ if (match(Op0, m_Xor(m_Value(A), m_APInt(C1))) &&
+ match(Op1, m_Xor(m_Specific(A), m_APInt(C2))) && (*C1 ^ *C2).isAllOnes())
----------------
nikic wrote:
```suggestion
match(Op1, m_Xor(m_Specific(A), m_SpecificInt(~*C1))))
```
https://github.com/llvm/llvm-project/pull/76637
More information about the llvm-commits
mailing list