1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

[InstCombine] Add additional saturating add/sub + icmp tests; NFC

These test comparisons with saturating add/sub in non-canonical
form.

llvm-svn: 349309
This commit is contained in:
Nikita Popov 2018-12-16 17:45:25 +00:00
parent c0a71fd8c3
commit d0b1b3dede

View File

@ -406,8 +406,30 @@ define <2 x i8> @ssub_vector_same(<2 x i8> %a) {
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
}