summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorChen Zheng <czhengsz@cn.ibm.com>2019-01-01 01:09:20 +0000
committerChen Zheng <czhengsz@cn.ibm.com>2019-01-01 01:09:20 +0000
commit4952e668f8e525820bb59ea78c1e5eeea3da68fe (patch)
tree350c039f660453b815d467a7496646b365d06d02 /llvm/test
parent745983ba0ed8a2a8bbd8b75beaa9f3a4a02dad95 (diff)
downloadbcm5719-llvm-4952e668f8e525820bb59ea78c1e5eeea3da68fe.tar.gz
bcm5719-llvm-4952e668f8e525820bb59ea78c1e5eeea3da68fe.zip
[InstCombine] canonicalize MUL with NEG operand
-X * Y --> -(X * Y) X * -Y --> -(X * Y) Differential Revision: https://reviews.llvm.org/D55961 llvm-svn: 350185
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/InstCombine/mul.ll24
-rw-r--r--llvm/test/Transforms/InstCombine/operand-complexity.ll12
2 files changed, 18 insertions, 18 deletions
diff --git a/llvm/test/Transforms/InstCombine/mul.ll b/llvm/test/Transforms/InstCombine/mul.ll
index d97ba88dfd7..94d21714d1f 100644
--- a/llvm/test/Transforms/InstCombine/mul.ll
+++ b/llvm/test/Transforms/InstCombine/mul.ll
@@ -445,9 +445,9 @@ define i128 @test34(i128 %X) {
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]]
+; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[NEG:%.*]] = sub i32 0, [[MUL]]
+; CHECK-NEXT: ret i32 [[NEG]]
;
%neg = sub i32 0, %x
%mul = mul i32 %neg, %y
@@ -457,9 +457,9 @@ define i32 @test_mul_canonicalize_op0(i32 %x, i32 %y) {
define i32 @test_mul_canonicalize_op1(i32 %x, i32 %z) {
; CHECK-LABEL: @test_mul_canonicalize_op1(
; 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]]
+; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[NEG:%.*]] = sub i32 0, [[MUL]]
+; CHECK-NEXT: ret i32 [[NEG]]
;
%y = mul i32 %z, 3
%neg = sub i32 0, %x
@@ -469,9 +469,9 @@ define i32 @test_mul_canonicalize_op1(i32 %x, i32 %z) {
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]]
+; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[NEG:%.*]] = sub i32 0, [[MUL]]
+; CHECK-NEXT: ret i32 [[NEG]]
;
%neg = sub nsw i32 0, %x
%mul = mul nsw i32 %neg, %y
@@ -480,9 +480,9 @@ define i32 @test_mul_canonicalize_nsw(i32 %x, i32 %y) {
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]]
+; CHECK-NEXT: [[MUL:%.*]] = mul <2 x i32> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[NEG:%.*]] = sub <2 x i32> zeroinitializer, [[MUL]]
+; CHECK-NEXT: ret <2 x i32> [[NEG]]
;
%neg = sub <2 x i32> <i32 0, i32 0>, %x
%mul = mul <2 x i32> %neg, %y
diff --git a/llvm/test/Transforms/InstCombine/operand-complexity.ll b/llvm/test/Transforms/InstCombine/operand-complexity.ll
index 20abe7b48f9..2dc161cb006 100644
--- a/llvm/test/Transforms/InstCombine/operand-complexity.ll
+++ b/llvm/test/Transforms/InstCombine/operand-complexity.ll
@@ -7,12 +7,12 @@ define i8 @neg(i8 %x) {
; CHECK-LABEL: @neg(
; CHECK-NEXT: [[BO:%.*]] = udiv i8 [[X:%.*]], 42
; CHECK-NEXT: [[NEGX:%.*]] = sub i8 0, [[X]]
-; CHECK-NEXT: [[R:%.*]] = mul i8 [[BO]], [[NEGX]]
+; CHECK-NEXT: [[R:%.*]] = xor i8 [[BO]], [[NEGX]]
; CHECK-NEXT: ret i8 [[R]]
;
%bo = udiv i8 %x, 42
%negx = sub i8 0, %x
- %r = mul i8 %negx, %bo
+ %r = xor i8 %negx, %bo
ret i8 %r
}
@@ -20,12 +20,12 @@ define <2 x i8> @neg_vec(<2 x i8> %x) {
; CHECK-LABEL: @neg_vec(
; CHECK-NEXT: [[BO:%.*]] = udiv <2 x i8> [[X:%.*]], <i8 42, i8 -42>
; CHECK-NEXT: [[NEGX:%.*]] = sub <2 x i8> zeroinitializer, [[X]]
-; CHECK-NEXT: [[R:%.*]] = mul <2 x i8> [[BO]], [[NEGX]]
+; CHECK-NEXT: [[R:%.*]] = xor <2 x i8> [[BO]], [[NEGX]]
; CHECK-NEXT: ret <2 x i8> [[R]]
;
%bo = udiv <2 x i8> %x, <i8 42, i8 -42>
%negx = sub <2 x i8> <i8 0, i8 0>, %x
- %r = mul <2 x i8> %negx, %bo
+ %r = xor <2 x i8> %negx, %bo
ret <2 x i8> %r
}
@@ -33,12 +33,12 @@ define <2 x i8> @neg_vec_undef(<2 x i8> %x) {
; CHECK-LABEL: @neg_vec_undef(
; CHECK-NEXT: [[BO:%.*]] = udiv <2 x i8> [[X:%.*]], <i8 42, i8 -42>
; CHECK-NEXT: [[NEGX:%.*]] = sub <2 x i8> <i8 0, i8 undef>, [[X]]
-; CHECK-NEXT: [[R:%.*]] = mul <2 x i8> [[BO]], [[NEGX]]
+; CHECK-NEXT: [[R:%.*]] = xor <2 x i8> [[BO]], [[NEGX]]
; CHECK-NEXT: ret <2 x i8> [[R]]
;
%bo = udiv <2 x i8> %x, <i8 42, i8 -42>
%negx = sub <2 x i8> <i8 0, i8 undef>, %x
- %r = mul <2 x i8> %negx, %bo
+ %r = xor <2 x i8> %negx, %bo
ret <2 x i8> %r
}
OpenPOWER on IntegriCloud