aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2008-12-01 08:09:47 +0000
committerBill Wendling <isanbard@gmail.com>2008-12-01 08:09:47 +0000
commit03aae5f7e1d7b0ce7118cd2ff2d19fba1babb0f8 (patch)
tree0193288b7b1201c824545d3c4e9f12da7a73a0e5
parent9c531a0f070b4f16b9dab34685a3687dbc98493a (diff)
Use m_Specific() instead of double matching.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60341 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp30
-rw-r--r--test/Transforms/InstCombine/or-to-xor.ll2
2 files changed, 13 insertions, 19 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index aae1e14f9d..47d9c25d5b 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -4603,28 +4603,22 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
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.
diff --git a/test/Transforms/InstCombine/or-to-xor.ll b/test/Transforms/InstCombine/or-to-xor.ll
index f403412bd5..e40417b17d 100644
--- a/test/Transforms/InstCombine/or-to-xor.ll
+++ b/test/Transforms/InstCombine/or-to-xor.ll
@@ -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 {