[PATCH] Added InstCombine transform for pattern "(A ^ B) & ((~A) ^ B) -> False"

David Majnemer david.majnemer at gmail.com
Sun Jul 27 23:55:19 PDT 2014


================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1284-1287
@@ -1283,1 +1283,6 @@
+
+// (A^B) & ((~(A)^B) -> 0
+  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::CreateAnd(A, Builder->CreateNot(A));
   }
----------------
Please format the code to match the coding standards: http://llvm.org/docs/CodingStandards.html 

================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1287
@@ -1283,1 +1286,3 @@
+          && match(Op1,m_Xor(m_Not(m_Specific(A)),m_Specific(B))))
+      return BinaryOperator::CreateAnd(A, Builder->CreateNot(A));
   }
----------------
This is wasteful, we don't need an instruction if we know the result is a constant. Sounds like a candidate for InstSimplify instead of InstCombine.

================
Comment at: test/Transforms/InstCombine/or-xor.ll:96-104
@@ +95,10 @@
+
+define i32 @test10(i32%x,i32%y){
+;CHECK-LABEL: @test10(
+;CHECK-NEXT: ret i32 0
+%xor = xor i32%x,%y
+%nega = xor i32%x,-1
+%xor1 = xor i32%nega,%y
+%and = and i32%xor,%xor1
+ret i32 %and
+}
----------------
Please format this test to match the others.

http://reviews.llvm.org/D4690






More information about the llvm-commits mailing list