[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
================
@@ -871,6 +871,14 @@ static Value *simplifySubInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW,
if (Value *V = simplifyByDomEq(Instruction::Sub, Op0, Op1, Q, MaxRecurse))
return V;
+ // (sub nuw C_Mask, (xor X, C_Mask)) -> X
+ if (IsNUW) {
+ Value *X;
+ if (match(Op1, m_Xor(m_Value(X), m_Specific(Op0))) &&
+ match(Op0, m_CheckedInt([](const APInt &C) { return C.isMask(); })))
----------------
nikic wrote:
```suggestion
match(Op0, m_LowBitMask())
```
https://github.com/llvm/llvm-project/pull/122552
More information about the llvm-commits
mailing list