]> granicus.if.org Git - llvm/commitdiff
[InstCombine] [NFC] update testcases for canonicalize MUL with NEG operand
authorChen Zheng <czhengsz@cn.ibm.com>
Sat, 29 Dec 2018 12:18:15 +0000 (12:18 +0000)
committerChen Zheng <czhengsz@cn.ibm.com>
Sat, 29 Dec 2018 12:18:15 +0000 (12:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350154 91177308-0d34-0410-b5e6-96231b3b80d8

test/Transforms/InstCombine/mul.ll

index 3becd07586edf5b646d3ad9e800ba1fe055d24f4..d97ba88dfd7b53a1e04268d5537fe588b2f3aaec 100644 (file)
@@ -454,14 +454,16 @@ define i32 @test_mul_canonicalize_op0(i32 %x, i32 %y) {
   ret i32 %mul
 }
 
-define i32 @test_mul_canonicalize_op1(i32 %x, i32 %y) {
+define i32 @test_mul_canonicalize_op1(i32 %x, i32 %z) {
 ; CHECK-LABEL: @test_mul_canonicalize_op1(
-; CHECK-NEXT:    [[NEG:%.*]] = sub i32 0, [[Y:%.*]]
-; CHECK-NEXT:    [[MUL:%.*]] = mul i32 [[NEG]], [[X:%.*]]
+; CHECK-NEXT:    [[Y:%.*]] = mul i32 [[Z:%.*]], 3
+; CHECK-NEXT:    [[NEG:%.*]] = sub i32 0, [[X:%.*]]
+; CHECK-NEXT:    [[MUL:%.*]] = mul i32 [[Y]], [[NEG]]
 ; CHECK-NEXT:    ret i32 [[MUL]]
 ;
-  %neg = sub i32 0, %y
-  %mul = mul i32 %x, %neg
+  %y = mul i32 %z, 3 
+  %neg = sub i32 0, %x
+  %mul = mul i32 %y, %neg
   ret i32 %mul
 }
 
@@ -486,3 +488,16 @@ define <2 x i32> @test_mul_canonicalize_vec(<2 x i32> %x, <2 x i32> %y) {
   %mul = mul <2 x i32> %neg, %y
   ret <2 x i32> %mul
 }
+
+define i32 @test_mul_canonicalize_multiple_uses(i32 %x, i32 %y) {
+; CHECK-LABEL: @test_mul_canonicalize_multiple_uses(
+; CHECK-NEXT:    [[NEG:%.*]] = sub i32 0, [[X:%.*]]
+; CHECK-NEXT:    [[MUL:%.*]] = mul i32 [[NEG]], [[Y:%.*]]
+; CHECK-NEXT:    [[MUL2:%.*]] = mul i32 [[MUL]], [[NEG]]
+; CHECK-NEXT:    ret i32 [[MUL2]]
+;
+  %neg = sub i32 0, %x
+  %mul = mul i32 %neg, %y
+  %mul2 = mul i32 %mul, %neg
+  ret i32 %mul2
+}