summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstSimplify
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2018-12-17 17:45:18 +0000
committerNikita Popov <nikita.ppv@gmail.com>2018-12-17 17:45:18 +0000
commit221f3fc750b7a91ed3722805ca4ecc6c34922f10 (patch)
treee19d2e4c905238741a82f928722558e31880c8aa /llvm/test/Transforms/InstSimplify
parent47eb63684d22c12b9defb99c394dbd10e26fefff (diff)
downloadbcm5719-llvm-221f3fc750b7a91ed3722805ca4ecc6c34922f10.tar.gz
bcm5719-llvm-221f3fc750b7a91ed3722805ca4ecc6c34922f10.zip
[InstSimplify] Simplify saturating add/sub + icmp
If a saturating add/sub has one constant operand, then we can determine the possible range of outputs it can produce, and simplify an icmp comparison based on that. The implementation is based on a similar existing mechanism for simplifying binary operator + icmps. Differential Revision: https://reviews.llvm.org/D55735 llvm-svn: 349369
Diffstat (limited to 'llvm/test/Transforms/InstSimplify')
-rw-r--r--llvm/test/Transforms/InstSimplify/saturating-add-sub.ll56
1 files changed, 14 insertions, 42 deletions
diff --git a/llvm/test/Transforms/InstSimplify/saturating-add-sub.ll b/llvm/test/Transforms/InstSimplify/saturating-add-sub.ll
index 8e733d6d272..a226cc456ac 100644
--- a/llvm/test/Transforms/InstSimplify/saturating-add-sub.ll
+++ b/llvm/test/Transforms/InstSimplify/saturating-add-sub.ll
@@ -408,9 +408,7 @@ define <2 x i8> @ssub_vector_same(<2 x i8> %a) {
define i1 @uadd_icmp_op0_known(i8 %a) {
; CHECK-LABEL: @uadd_icmp_op0_known(
-; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.uadd.sat.i8(i8 10, i8 [[A:%.*]])
-; CHECK-NEXT: [[C:%.*]] = icmp uge i8 [[B]], 10
-; CHECK-NEXT: ret i1 [[C]]
+; CHECK-NEXT: ret i1 true
;
%b = call i8 @llvm.uadd.sat.i8(i8 10, i8 %a)
%c = icmp uge i8 %b, 10
@@ -430,9 +428,7 @@ define i1 @uadd_icmp_op0_unknown(i8 %a) {
define i1 @uadd_icmp_op1_known(i8 %a) {
; CHECK-LABEL: @uadd_icmp_op1_known(
-; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.uadd.sat.i8(i8 [[A:%.*]], i8 10)
-; CHECK-NEXT: [[C:%.*]] = icmp uge i8 [[B]], 10
-; CHECK-NEXT: ret i1 [[C]]
+; CHECK-NEXT: ret i1 true
;
%b = call i8 @llvm.uadd.sat.i8(i8 %a, i8 10)
%c = icmp uge i8 %b, 10
@@ -452,9 +448,7 @@ define i1 @uadd_icmp_op1_unknown(i8 %a) {
define i1 @sadd_icmp_op0_pos_known(i8 %a) {
; CHECK-LABEL: @sadd_icmp_op0_pos_known(
-; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.sadd.sat.i8(i8 10, i8 [[A:%.*]])
-; CHECK-NEXT: [[C:%.*]] = icmp sge i8 [[B]], -118
-; CHECK-NEXT: ret i1 [[C]]
+; CHECK-NEXT: ret i1 true
;
%b = call i8 @llvm.sadd.sat.i8(i8 10, i8 %a)
%c = icmp sge i8 %b, -118
@@ -474,9 +468,7 @@ define i1 @sadd_icmp_op0_pos_unknown(i8 %a) {
define i1 @sadd_icmp_op0_neg_known(i8 %a) {
; CHECK-LABEL: @sadd_icmp_op0_neg_known(
-; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.sadd.sat.i8(i8 -10, i8 [[A:%.*]])
-; CHECK-NEXT: [[C:%.*]] = icmp sle i8 [[B]], 117
-; CHECK-NEXT: ret i1 [[C]]
+; CHECK-NEXT: ret i1 true
;
%b = call i8 @llvm.sadd.sat.i8(i8 -10, i8 %a)
%c = icmp sle i8 %b, 117
@@ -496,9 +488,7 @@ define i1 @sadd_icmp_op0_neg_unknown(i8 %a) {
define i1 @sadd_icmp_op1_pos_known(i8 %a) {
; CHECK-LABEL: @sadd_icmp_op1_pos_known(
-; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.sadd.sat.i8(i8 [[A:%.*]], i8 10)
-; CHECK-NEXT: [[C:%.*]] = icmp sge i8 [[B]], -118
-; CHECK-NEXT: ret i1 [[C]]
+; CHECK-NEXT: ret i1 true
;
%b = call i8 @llvm.sadd.sat.i8(i8 %a, i8 10)
%c = icmp sge i8 %b, -118
@@ -518,9 +508,7 @@ define i1 @sadd_icmp_op1_pos_unknown(i8 %a) {
define i1 @sadd_icmp_op1_neg_known(i8 %a) {
; CHECK-LABEL: @sadd_icmp_op1_neg_known(
-; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.sadd.sat.i8(i8 [[A:%.*]], i8 -10)
-; CHECK-NEXT: [[C:%.*]] = icmp sle i8 [[B]], 117
-; CHECK-NEXT: ret i1 [[C]]
+; CHECK-NEXT: ret i1 true
;
%b = call i8 @llvm.sadd.sat.i8(i8 %a, i8 -10)
%c = icmp sle i8 %b, 117
@@ -540,9 +528,7 @@ define i1 @sadd_icmp_op1_neg_unknown(i8 %a) {
define i1 @usub_icmp_op0_known(i8 %a) {
; CHECK-LABEL: @usub_icmp_op0_known(
-; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.usub.sat.i8(i8 10, i8 [[A:%.*]])
-; CHECK-NEXT: [[C:%.*]] = icmp ule i8 [[B]], 10
-; CHECK-NEXT: ret i1 [[C]]
+; CHECK-NEXT: ret i1 true
;
%b = call i8 @llvm.usub.sat.i8(i8 10, i8 %a)
%c = icmp ule i8 %b, 10
@@ -562,9 +548,7 @@ define i1 @usub_icmp_op0_unknown(i8 %a) {
define i1 @usub_icmp_op1_known(i8 %a) {
; CHECK-LABEL: @usub_icmp_op1_known(
-; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.usub.sat.i8(i8 [[A:%.*]], i8 10)
-; CHECK-NEXT: [[C:%.*]] = icmp ule i8 [[B]], -11
-; CHECK-NEXT: ret i1 [[C]]
+; CHECK-NEXT: ret i1 true
;
%b = call i8 @llvm.usub.sat.i8(i8 %a, i8 10)
%c = icmp ule i8 %b, 245
@@ -584,9 +568,7 @@ define i1 @usub_icmp_op1_unknown(i8 %a) {
define i1 @ssub_icmp_op0_pos_known(i8 %a) {
; CHECK-LABEL: @ssub_icmp_op0_pos_known(
-; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.ssub.sat.i8(i8 10, i8 [[A:%.*]])
-; CHECK-NEXT: [[C:%.*]] = icmp sge i8 [[B]], -117
-; CHECK-NEXT: ret i1 [[C]]
+; CHECK-NEXT: ret i1 true
;
%b = call i8 @llvm.ssub.sat.i8(i8 10, i8 %a)
%c = icmp sge i8 %b, -117
@@ -606,9 +588,7 @@ define i1 @ssub_icmp_op0_pos_unknown(i8 %a) {
define i1 @ssub_icmp_op0_neg_known(i8 %a) {
; CHECK-LABEL: @ssub_icmp_op0_neg_known(
-; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.ssub.sat.i8(i8 -10, i8 [[A:%.*]])
-; CHECK-NEXT: [[C:%.*]] = icmp sle i8 [[B]], 118
-; CHECK-NEXT: ret i1 [[C]]
+; CHECK-NEXT: ret i1 true
;
%b = call i8 @llvm.ssub.sat.i8(i8 -10, i8 %a)
%c = icmp sle i8 %b, 118
@@ -629,9 +609,7 @@ define i1 @ssub_icmp_op0_neg_unknown(i8 %a) {
; Peculiar case: ssub.sat(0, x) is never signed min.
define i1 @ssub_icmp_op0_zero(i8 %a) {
; CHECK-LABEL: @ssub_icmp_op0_zero(
-; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.ssub.sat.i8(i8 0, i8 [[A:%.*]])
-; CHECK-NEXT: [[C:%.*]] = icmp ne i8 [[B]], -128
-; CHECK-NEXT: ret i1 [[C]]
+; CHECK-NEXT: ret i1 true
;
%b = call i8 @llvm.ssub.sat.i8(i8 0, i8 %a)
%c = icmp ne i8 %b, -128
@@ -640,9 +618,7 @@ define i1 @ssub_icmp_op0_zero(i8 %a) {
define i1 @ssub_icmp_op1_pos_known(i8 %a) {
; CHECK-LABEL: @ssub_icmp_op1_pos_known(
-; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.ssub.sat.i8(i8 [[A:%.*]], i8 10)
-; CHECK-NEXT: [[C:%.*]] = icmp sle i8 [[B]], 117
-; CHECK-NEXT: ret i1 [[C]]
+; CHECK-NEXT: ret i1 true
;
%b = call i8 @llvm.ssub.sat.i8(i8 %a, i8 10)
%c = icmp sle i8 %b, 117
@@ -662,9 +638,7 @@ define i1 @ssub_icmp_op1_pos_unknown(i8 %a) {
define i1 @ssub_icmp_op1_neg_known(i8 %a) {
; CHECK-LABEL: @ssub_icmp_op1_neg_known(
-; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.ssub.sat.i8(i8 [[A:%.*]], i8 -10)
-; CHECK-NEXT: [[C:%.*]] = icmp sge i8 [[B]], -118
-; CHECK-NEXT: ret i1 [[C]]
+; CHECK-NEXT: ret i1 true
;
%b = call i8 @llvm.ssub.sat.i8(i8 %a, i8 -10)
%c = icmp sge i8 %b, -118
@@ -684,9 +658,7 @@ define i1 @ssub_icmp_op1_neg_unknown(i8 %a) {
define i1 @ssub_icmp_op1_smin(i8 %a) {
; CHECK-LABEL: @ssub_icmp_op1_smin(
-; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.ssub.sat.i8(i8 [[A:%.*]], i8 -128)
-; CHECK-NEXT: [[C:%.*]] = icmp sge i8 [[B]], 0
-; CHECK-NEXT: ret i1 [[C]]
+; CHECK-NEXT: ret i1 true
;
%b = call i8 @llvm.ssub.sat.i8(i8 %a, i8 -128)
%c = icmp sge i8 %b, 0
OpenPOWER on IntegriCloud