[PATCH] Added InstCombine transform for pattern "(A ^ B) | ((~A) ^ B) -> True".

David Majnemer david.majnemer at gmail.com
Sun Jul 27 23:58:49 PDT 2014


================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1283
@@ -1283,1 +1282,3 @@
+        return BinaryOperator::CreateAnd(A, Op0);
+
   }
----------------
This change seems irrelevant to the patch.

================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1986-1989
@@ -1984,1 +1985,6 @@
 
+  // (A^B) | (~(A)^B) -> 1
+    if(match(Op0,m_Xor(m_Value(A),m_Value(B)))
+            && match(Op1,m_Xor(m_Not(m_Specific(A)),m_Specific(B))))
+        return BinaryOperator::CreateOr(A, Builder->CreateNot(A));
+
----------------
See my comments in your other differential, D4690.

================
Comment at: test/Transforms/InstCombine/or.ll:411-420
@@ -410,1 +410,11 @@
 }
+
+define i32 @test39(i32%x,i32%y){
+; CHECK-LABEL: @test39(
+; CHECK-NEXT: ret i32 -1
+%xor = xor i32%x,%y
+%nega = xor i32%x,-1
+%xor1 = xor i32%nega,%y
+%or = or i32%xor,%xor1
+ret i32 %or
+}
----------------
Again, please see my comments in D4690.

http://reviews.llvm.org/D4691






More information about the llvm-commits mailing list