]> granicus.if.org Git - llvm/commitdiff
[InstCombine] Make the (A|B)^B -> A & ~B transform code consistent with the very...
authorCraig Topper <craig.topper@gmail.com>
Mon, 10 Apr 2017 06:53:21 +0000 (06:53 +0000)
committerCraig Topper <craig.topper@gmail.com>
Mon, 10 Apr 2017 06:53:21 +0000 (06:53 +0000)
I think this code is still overly complicated and should use matchers, but first I wanted to make it consistent.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299834 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstCombineAndOrXor.cpp

index 5b2dbd9d1f3472d5ebc9f2c328f5aeb7421c0f2e..091c80daef6a70362d429f7c39b2abe0bac41176 100644 (file)
@@ -2504,12 +2504,12 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
   BinaryOperator *Op1I = dyn_cast<BinaryOperator>(Op1);
   if (Op1I) {
     Value *A, *B;
-    if (match(Op1I, m_Or(m_Value(A), m_Value(B)))) {
-      if (A == Op0) {              // B^(B|A) == (A|B)^B
+    if (match(Op1I, m_OneUse(m_Or(m_Value(A), m_Value(B))))) {
+      if (A == Op0) {                                      // A^(A|B) == A^(B|A)
         Op1I->swapOperands();
-        I.swapOperands();
-        std::swap(Op0, Op1);
-      } else if (B == Op0) {       // B^(A|B) == (A|B)^B
+        std::swap(A, B);
+      }
+      if (B == Op0) {                                      // A^(B|A) == (B|A)^A
         I.swapOperands();     // Simplified below.
         std::swap(Op0, Op1);
       }