From: Chen Zheng Date: Sat, 29 Dec 2018 12:18:15 +0000 (+0000) Subject: [InstCombine] [NFC] update testcases for canonicalize MUL with NEG operand X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b7c3be51e432282289d9ef2a350ad3e954032754;p=llvm [InstCombine] [NFC] update testcases for canonicalize MUL with NEG operand git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350154 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Transforms/InstCombine/mul.ll b/test/Transforms/InstCombine/mul.ll index 3becd07586e..d97ba88dfd7 100644 --- a/test/Transforms/InstCombine/mul.ll +++ b/test/Transforms/InstCombine/mul.ll @@ -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 +}