[llvm] r299853 - [InstCombine] Use m_c_Add to shorten some code. Add testcases for this fold since they were missing. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 10 09:59:40 PDT 2017
Author: ctopper
Date: Mon Apr 10 11:59:40 2017
New Revision: 299853
URL: http://llvm.org/viewvc/llvm-project?rev=299853&view=rev
Log:
[InstCombine] Use m_c_Add to shorten some code. Add testcases for this fold since they were missing. NFC
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp
llvm/trunk/test/Transforms/InstCombine/sub.ll
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp?rev=299853&r1=299852&r2=299853&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp Mon Apr 10 11:59:40 2017
@@ -1623,8 +1623,7 @@ Instruction *InstCombiner::visitSub(Bina
{
Value *Y;
// X-(X+Y) == -Y X-(Y+X) == -Y
- if (match(Op1, m_Add(m_Specific(Op0), m_Value(Y))) ||
- match(Op1, m_Add(m_Value(Y), m_Specific(Op0))))
+ if (match(Op1, m_c_Add(m_Specific(Op0), m_Value(Y))))
return BinaryOperator::CreateNeg(Y);
// (X-Y)-X == -Y
Modified: llvm/trunk/test/Transforms/InstCombine/sub.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/sub.ll?rev=299853&r1=299852&r2=299853&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/sub.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/sub.ll Mon Apr 10 11:59:40 2017
@@ -851,3 +851,21 @@ final:
%value = sub <2 x i32> <i32 123, i32 333>, %A
ret <2 x i32> %value
}
+
+define i32 @test56(i32 %A, i32 %B) {
+; CHECK-LABEL: @test56(
+; CHECK-NEXT: [[Y:%.*]] = sub i32 0, [[B:%.*]]
+; CHECK-NEXT: ret i32 [[Y]]
+;
+ %X = add i32 %A, %B
+ %Y = sub i32 %A, %X
+ ret i32 %Y }
+
+define i32 @test57(i32 %A, i32 %B) {
+; CHECK-LABEL: @test57(
+; CHECK-NEXT: [[Y:%.*]] = sub i32 0, [[B:%.*]]
+; CHECK-NEXT: ret i32 [[Y]]
+;
+ %X = add i32 %B, %A
+ %Y = sub i32 %A, %X
+ ret i32 %Y }
More information about the llvm-commits
mailing list