diff options
| -rw-r--r-- | llvm/test/Transforms/InstCombine/mul.ll | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/llvm/test/Transforms/InstCombine/mul.ll b/llvm/test/Transforms/InstCombine/mul.ll index 3becd07586e..d97ba88dfd7 100644 --- a/llvm/test/Transforms/InstCombine/mul.ll +++ b/llvm/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 +} |

