summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2017-04-10 06:53:28 +0000
committerCraig Topper <craig.topper@gmail.com>2017-04-10 06:53:28 +0000
commitd8840d7b101d6958e1746183b8e7d09e16e07c55 (patch)
tree47b70eaeed35e66fd3b2d6f573b83424c5043623
parent7260e2f159f392391e130fe9a446502769abc25f (diff)
downloadbcm5719-llvm-d8840d7b101d6958e1746183b8e7d09e16e07c55.tar.gz
bcm5719-llvm-d8840d7b101d6958e1746183b8e7d09e16e07c55.zip
[InstCombine] use m_c_And and m_c_Xor to handle commuted versions of a transform.
llvm-svn: 299837
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp4
-rw-r--r--llvm/test/Transforms/InstCombine/xor2.ll8
2 files changed, 4 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 71a7c92ec06..fa2631c9535 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -2600,11 +2600,11 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
}
// (A & B) ^ (A ^ B) -> (A | B)
if (match(Op0, m_And(m_Value(A), m_Value(B))) &&
- match(Op1, m_Xor(m_Specific(A), m_Specific(B))))
+ match(Op1, m_c_Xor(m_Specific(A), m_Specific(B))))
return BinaryOperator::CreateOr(A, B);
// (A ^ B) ^ (A & B) -> (A | B)
if (match(Op0, m_Xor(m_Value(A), m_Value(B))) &&
- match(Op1, m_And(m_Specific(A), m_Specific(B))))
+ match(Op1, m_c_And(m_Specific(A), m_Specific(B))))
return BinaryOperator::CreateOr(A, B);
}
diff --git a/llvm/test/Transforms/InstCombine/xor2.ll b/llvm/test/Transforms/InstCombine/xor2.ll
index ca93419681a..79e62723f14 100644
--- a/llvm/test/Transforms/InstCombine/xor2.ll
+++ b/llvm/test/Transforms/InstCombine/xor2.ll
@@ -147,9 +147,7 @@ define i32 @test9(i32 %b, i32 %c) {
; (A & B) ^ (B ^ A) -> (A | B)
define i32 @test9b(i32 %b, i32 %c) {
; CHECK-LABEL: @test9b(
-; CHECK-NEXT: [[AND:%.*]] = and i32 [[B:%.*]], [[C:%.*]]
-; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[C]], [[B]]
-; CHECK-NEXT: [[XOR2:%.*]] = xor i32 [[AND]], [[XOR]]
+; CHECK-NEXT: [[XOR2:%.*]] = or i32 [[B:%.*]], [[C:%.*]]
; CHECK-NEXT: ret i32 [[XOR2]]
;
%and = and i32 %b, %c
@@ -173,9 +171,7 @@ define i32 @test10(i32 %b, i32 %c) {
; (A ^ B) ^ (A & B) -> (A | B)
define i32 @test10b(i32 %b, i32 %c) {
; CHECK-LABEL: @test10b(
-; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[B:%.*]], [[C:%.*]]
-; CHECK-NEXT: [[AND:%.*]] = and i32 [[C]], [[B]]
-; CHECK-NEXT: [[XOR2:%.*]] = xor i32 [[XOR]], [[AND]]
+; CHECK-NEXT: [[XOR2:%.*]] = or i32 [[B:%.*]], [[C:%.*]]
; CHECK-NEXT: ret i32 [[XOR2]]
;
%xor = xor i32 %b, %c
OpenPOWER on IntegriCloud