[llvm-commits] [llvm] r60341 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/or-to-xor.ll

Bill Wendling isanbard at gmail.com
Mon Dec 1 00:09:48 PST 2008


Author: void
Date: Mon Dec  1 02:09:47 2008
New Revision: 60341

URL: http://llvm.org/viewvc/llvm-project?rev=60341&view=rev
Log:
Use m_Specific() instead of double matching.

Modified:
    llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
    llvm/trunk/test/Transforms/InstCombine/or-to-xor.ll

Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=60341&r1=60340&r2=60341&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Dec  1 02:09:47 2008
@@ -4603,28 +4603,22 @@
     if (Instruction *Match = MatchSelectFromAndOr(D, A, B, C))
       return Match;
 
-    V1 = V2 = 0;
-
     // ((A&~B)|(~A&B)) -> A^B
-    if ((match(C, m_Not(m_Value(V1))) &&
-         match(B, m_Not(m_Value(V2)))))
-      if (V1 == D && V2 == A)
-        return BinaryOperator::CreateXor(V1, V2);
+    if ((match(C, m_Not(m_Specific(D))) &&
+         match(B, m_Not(m_Specific(A)))))
+      return BinaryOperator::CreateXor(A, D);
     // ((~B&A)|(~A&B)) -> A^B
-    if ((match(A, m_Not(m_Value(V1))) &&
-         match(B, m_Not(m_Value(V2)))))
-      if (V1 == D && V2 == C)
-        return BinaryOperator::CreateXor(V1, V2);
+    if ((match(A, m_Not(m_Specific(D))) &&
+         match(B, m_Not(m_Specific(C)))))
+      return BinaryOperator::CreateXor(C, D);
     // ((A&~B)|(B&~A)) -> A^B
-    if ((match(C, m_Not(m_Value(V1))) &&
-         match(D, m_Not(m_Value(V2)))))
-      if (V1 == B && V2 == A)
-        return BinaryOperator::CreateXor(V1, V2);
+    if ((match(C, m_Not(m_Specific(B))) &&
+         match(D, m_Not(m_Specific(A)))))
+      return BinaryOperator::CreateXor(A, B);
     // ((~B&A)|(B&~A)) -> A^B
-    if ((match(A, m_Not(m_Value(V1))) &&
-         match(D, m_Not(m_Value(V2)))))
-      if (V1 == B && V2 == C)
-        return BinaryOperator::CreateXor(V1, V2);
+    if ((match(A, m_Not(m_Specific(B))) &&
+         match(D, m_Not(m_Specific(C)))))
+      return BinaryOperator::CreateXor(C, B);
   }
   
   // (X >> Z) | (Y >> Z)  -> (X|Y) >> Z  for all shifts.

Modified: llvm/trunk/test/Transforms/InstCombine/or-to-xor.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/or-to-xor.ll?rev=60341&r1=60340&r2=60341&view=diff

==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/or-to-xor.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/or-to-xor.ll Mon Dec  1 02:09:47 2008
@@ -1,4 +1,4 @@
-; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {xor i32 %b, %a} | count 4
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {xor i32 %a, %b} | count 4
 ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep {and}
 
 define i32 @func1(i32 %a, i32 %b) nounwind readnone {





More information about the llvm-commits mailing list