[llvm] r299837 - [InstCombine] use m_c_And and m_c_Xor to handle commuted versions of a transform.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 9 23:53:28 PDT 2017
Author: ctopper
Date: Mon Apr 10 01:53:28 2017
New Revision: 299837
URL: http://llvm.org/viewvc/llvm-project?rev=299837&view=rev
Log:
[InstCombine] use m_c_And and m_c_Xor to handle commuted versions of a transform.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/trunk/test/Transforms/InstCombine/xor2.ll
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=299837&r1=299836&r2=299837&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Mon Apr 10 01:53:28 2017
@@ -2600,11 +2600,11 @@ Instruction *InstCombiner::visitXor(Bina
}
// (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);
}
Modified: llvm/trunk/test/Transforms/InstCombine/xor2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/xor2.ll?rev=299837&r1=299836&r2=299837&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/xor2.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/xor2.ll Mon Apr 10 01:53:28 2017
@@ -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
More information about the llvm-commits
mailing list