[PATCH] D50604: [InstCombine] Replace call to haveNoCommonBitsSet in visitXor with just the special case that doesn't use computeKnownBits.

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 12 17:39:17 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL339531: [InstCombine] Replace call to haveNoCommonBitsSet in visitXor with just theā€¦ (authored by ctopper, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50604?vs=160250&id=160281#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50604

Files:
  llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp


Index: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
===================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -2507,9 +2507,15 @@
   if (Value *V = SimplifyBSwap(I, Builder))
     return replaceInstUsesWith(I, V);
 
-  // A^B --> A|B iff A and B have no bits set in common.
   Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
-  if (haveNoCommonBitsSet(Op0, Op1, DL, &AC, &I, &DT))
+
+  // Fold (X & M) ^ (Y & ~M) -> (X & M) | (Y & ~M)
+  // This it a special case in haveNoCommonBitsSet, but the commputeKnownBits
+  // calls in there are unnecessary as SimplifyDemandedInstructionBits should
+  // have already taken care of those cases.
+  Value *M;
+  if (match(&I, m_c_Xor(m_c_And(m_Not(m_Value(M)), m_Value()),
+                        m_c_And(m_Deferred(M), m_Value()))))
     return BinaryOperator::CreateOr(Op0, Op1);
 
   // Apply DeMorgan's Law for 'nand' / 'nor' logic with an inverted operand.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50604.160281.patch
Type: text/x-patch
Size: 1074 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180813/2d1b92eb/attachment.bin>


More information about the llvm-commits mailing list