summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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