summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/test/Transforms/InstCombine/mul.ll44
1 files changed, 44 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/mul.ll b/llvm/test/Transforms/InstCombine/mul.ll
index fc3773aa9f1..3becd07586e 100644
--- a/llvm/test/Transforms/InstCombine/mul.ll
+++ b/llvm/test/Transforms/InstCombine/mul.ll
@@ -442,3 +442,47 @@ define i128 @test34(i128 %X) {
%mul = mul nsw i128 %X, 2
ret i128 %mul
}
+
+define i32 @test_mul_canonicalize_op0(i32 %x, i32 %y) {
+; CHECK-LABEL: @test_mul_canonicalize_op0(
+; CHECK-NEXT: [[NEG:%.*]] = sub i32 0, [[X:%.*]]
+; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[NEG]], [[Y:%.*]]
+; CHECK-NEXT: ret i32 [[MUL]]
+;
+ %neg = sub i32 0, %x
+ %mul = mul i32 %neg, %y
+ ret i32 %mul
+}
+
+define i32 @test_mul_canonicalize_op1(i32 %x, i32 %y) {
+; CHECK-LABEL: @test_mul_canonicalize_op1(
+; CHECK-NEXT: [[NEG:%.*]] = sub i32 0, [[Y:%.*]]
+; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[NEG]], [[X:%.*]]
+; CHECK-NEXT: ret i32 [[MUL]]
+;
+ %neg = sub i32 0, %y
+ %mul = mul i32 %x, %neg
+ ret i32 %mul
+}
+
+define i32 @test_mul_canonicalize_nsw(i32 %x, i32 %y) {
+; CHECK-LABEL: @test_mul_canonicalize_nsw(
+; CHECK-NEXT: [[NEG:%.*]] = sub nsw i32 0, [[X:%.*]]
+; CHECK-NEXT: [[MUL:%.*]] = mul nsw i32 [[NEG]], [[Y:%.*]]
+; CHECK-NEXT: ret i32 [[MUL]]
+;
+ %neg = sub nsw i32 0, %x
+ %mul = mul nsw i32 %neg, %y
+ ret i32 %mul
+}
+
+define <2 x i32> @test_mul_canonicalize_vec(<2 x i32> %x, <2 x i32> %y) {
+; CHECK-LABEL: @test_mul_canonicalize_vec(
+; CHECK-NEXT: [[NEG:%.*]] = sub <2 x i32> zeroinitializer, [[X:%.*]]
+; CHECK-NEXT: [[MUL:%.*]] = mul <2 x i32> [[NEG]], [[Y:%.*]]
+; CHECK-NEXT: ret <2 x i32> [[MUL]]
+;
+ %neg = sub <2 x i32> <i32 0, i32 0>, %x
+ %mul = mul <2 x i32> %neg, %y
+ ret <2 x i32> %mul
+}
OpenPOWER on IntegriCloud