[llvm] [InstSimpify] Simplifying `(xor (sub C_Mask, X), C_Mask)` -> `X` (PR #122552)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 11 01:10:55 PST 2025
================
@@ -2540,6 +2548,14 @@ static Value *simplifyXorInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
if (Value *V = simplifyByDomEq(Instruction::Xor, Op0, Op1, Q, MaxRecurse))
return V;
+ // (xor (sub nuw C_Mask, X), C_Mask) -> X
+ {
+ Value *X;
+ if (match(Op0, m_NUWSub(m_Specific(Op1), m_Value(X))) &&
+ match(Op1, m_CheckedInt([](const APInt &C) { return C.isMask(); })))
----------------
nikic wrote:
```suggestion
match(Op1, m_LowBitMask())
```
https://github.com/llvm/llvm-project/pull/122552
More information about the llvm-commits
mailing list