[llvm] [InstCombine] Change (add x, c) to (xor x, c) (PR #75129)

Fujun Han via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 14 04:01:20 PST 2023


================
@@ -552,6 +552,16 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
     if (DemandedFromOps.isSubsetOf(LHSKnown.Zero))
       return I->getOperand(1);
 
+    // (add X, C) --> (xor X, C) IFF C is equal to the top bit of the DemandMask
+    {
+      Value *X;
+      const APInt *C;
+      if (match(I, m_Add(m_Value(X), m_APInt(C))) &&
+          C->isOneBitSet(DemandedMask.getBitWidth() -
----------------
Peter9606 wrote:

updated! thank you!

https://github.com/llvm/llvm-project/pull/75129


More information about the llvm-commits mailing list