[llvm] r349309 - [InstCombine] Add additional saturating add/sub + icmp tests; NFC
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 16 09:45:25 PST 2018
Author: nikic
Date: Sun Dec 16 09:45:25 2018
New Revision: 349309
URL: http://llvm.org/viewvc/llvm-project?rev=349309&view=rev
Log:
[InstCombine] Add additional saturating add/sub + icmp tests; NFC
These test comparisons with saturating add/sub in non-canonical
form.
Modified:
llvm/trunk/test/Transforms/InstSimplify/saturating-add-sub.ll
Modified: llvm/trunk/test/Transforms/InstSimplify/saturating-add-sub.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/saturating-add-sub.ll?rev=349309&r1=349308&r2=349309&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstSimplify/saturating-add-sub.ll (original)
+++ llvm/trunk/test/Transforms/InstSimplify/saturating-add-sub.ll Sun Dec 16 09:45:25 2018
@@ -406,8 +406,30 @@ define <2 x i8> @ssub_vector_same(<2 x i
ret <2 x i8> %y6v
}
-define i1 @uadd_icmp_known(i8 %a) {
-; CHECK-LABEL: @uadd_icmp_known(
+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]]
+;
+ %b = call i8 @llvm.uadd.sat.i8(i8 10, i8 %a)
+ %c = icmp uge i8 %b, 10
+ ret i1 %c
+}
+
+define i1 @uadd_icmp_op0_unknown(i8 %a) {
+; CHECK-LABEL: @uadd_icmp_op0_unknown(
+; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.uadd.sat.i8(i8 10, i8 [[A:%.*]])
+; CHECK-NEXT: [[C:%.*]] = icmp ugt i8 [[B]], 10
+; CHECK-NEXT: ret i1 [[C]]
+;
+ %b = call i8 @llvm.uadd.sat.i8(i8 10, i8 %a)
+ %c = icmp ugt i8 %b, 10
+ ret i1 %c
+}
+
+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]]
@@ -417,8 +439,8 @@ define i1 @uadd_icmp_known(i8 %a) {
ret i1 %c
}
-define i1 @uadd_icmp_unknown(i8 %a) {
-; CHECK-LABEL: @uadd_icmp_unknown(
+define i1 @uadd_icmp_op1_unknown(i8 %a) {
+; CHECK-LABEL: @uadd_icmp_op1_unknown(
; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.uadd.sat.i8(i8 [[A:%.*]], i8 10)
; CHECK-NEXT: [[C:%.*]] = icmp ugt i8 [[B]], 10
; CHECK-NEXT: ret i1 [[C]]
@@ -428,8 +450,52 @@ define i1 @uadd_icmp_unknown(i8 %a) {
ret i1 %c
}
-define i1 @sadd_icmp_pos_known(i8 %a) {
-; CHECK-LABEL: @sadd_icmp_pos_known(
+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]]
+;
+ %b = call i8 @llvm.sadd.sat.i8(i8 10, i8 %a)
+ %c = icmp sge i8 %b, -118
+ ret i1 %c
+}
+
+define i1 @sadd_icmp_op0_pos_unknown(i8 %a) {
+; CHECK-LABEL: @sadd_icmp_op0_pos_unknown(
+; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.sadd.sat.i8(i8 10, i8 [[A:%.*]])
+; CHECK-NEXT: [[C:%.*]] = icmp sgt i8 [[B]], -118
+; CHECK-NEXT: ret i1 [[C]]
+;
+ %b = call i8 @llvm.sadd.sat.i8(i8 10, i8 %a)
+ %c = icmp sgt i8 %b, -118
+ ret i1 %c
+}
+
+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]]
+;
+ %b = call i8 @llvm.sadd.sat.i8(i8 -10, i8 %a)
+ %c = icmp sle i8 %b, 117
+ ret i1 %c
+}
+
+define i1 @sadd_icmp_op0_neg_unknown(i8 %a) {
+; CHECK-LABEL: @sadd_icmp_op0_neg_unknown(
+; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.sadd.sat.i8(i8 -10, i8 [[A:%.*]])
+; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[B]], 117
+; CHECK-NEXT: ret i1 [[C]]
+;
+ %b = call i8 @llvm.sadd.sat.i8(i8 -10, i8 %a)
+ %c = icmp slt i8 %b, 117
+ ret i1 %c
+}
+
+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]]
@@ -439,8 +505,8 @@ define i1 @sadd_icmp_pos_known(i8 %a) {
ret i1 %c
}
-define i1 @sadd_icmp_pos_unknown(i8 %a) {
-; CHECK-LABEL: @sadd_icmp_pos_unknown(
+define i1 @sadd_icmp_op1_pos_unknown(i8 %a) {
+; CHECK-LABEL: @sadd_icmp_op1_pos_unknown(
; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.sadd.sat.i8(i8 [[A:%.*]], i8 10)
; CHECK-NEXT: [[C:%.*]] = icmp sgt i8 [[B]], -118
; CHECK-NEXT: ret i1 [[C]]
@@ -450,8 +516,8 @@ define i1 @sadd_icmp_pos_unknown(i8 %a)
ret i1 %c
}
-define i1 @sadd_icmp_neg_known(i8 %a) {
-; CHECK-LABEL: @sadd_icmp_neg_known(
+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]]
@@ -461,8 +527,8 @@ define i1 @sadd_icmp_neg_known(i8 %a) {
ret i1 %c
}
-define i1 @sadd_icmp_neg_unknown(i8 %a) {
-; CHECK-LABEL: @sadd_icmp_neg_unknown(
+define i1 @sadd_icmp_op1_neg_unknown(i8 %a) {
+; CHECK-LABEL: @sadd_icmp_op1_neg_unknown(
; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.sadd.sat.i8(i8 [[A:%.*]], i8 -10)
; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[B]], 117
; CHECK-NEXT: ret i1 [[C]]
@@ -571,3 +637,58 @@ define i1 @ssub_icmp_op0_zero(i8 %a) {
%c = icmp ne i8 %b, -128
ret i1 %c
}
+
+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]]
+;
+ %b = call i8 @llvm.ssub.sat.i8(i8 %a, i8 10)
+ %c = icmp sle i8 %b, 117
+ ret i1 %c
+}
+
+define i1 @ssub_icmp_op1_pos_unknown(i8 %a) {
+; CHECK-LABEL: @ssub_icmp_op1_pos_unknown(
+; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.ssub.sat.i8(i8 [[A:%.*]], i8 10)
+; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[B]], 117
+; CHECK-NEXT: ret i1 [[C]]
+;
+ %b = call i8 @llvm.ssub.sat.i8(i8 %a, i8 10)
+ %c = icmp slt i8 %b, 117
+ ret i1 %c
+}
+
+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]]
+;
+ %b = call i8 @llvm.ssub.sat.i8(i8 %a, i8 -10)
+ %c = icmp sge i8 %b, -118
+ ret i1 %c
+}
+
+define i1 @ssub_icmp_op1_neg_unknown(i8 %a) {
+; CHECK-LABEL: @ssub_icmp_op1_neg_unknown(
+; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.ssub.sat.i8(i8 [[A:%.*]], i8 -10)
+; CHECK-NEXT: [[C:%.*]] = icmp sgt i8 [[B]], -118
+; CHECK-NEXT: ret i1 [[C]]
+;
+ %b = call i8 @llvm.ssub.sat.i8(i8 %a, i8 -10)
+ %c = icmp sgt i8 %b, -118
+ ret i1 %c
+}
+
+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]]
+;
+ %b = call i8 @llvm.ssub.sat.i8(i8 %a, i8 -128)
+ %c = icmp sge i8 %b, 0
+ ret i1 %c
+}
More information about the llvm-commits
mailing list