1 ; Test 32-bit signed comparison in which the second operand is constant.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5 ; Check comparisons with 0.
6 define double @f1(double %a, double %b, i32 %i1) {
11 %cond = icmp slt i32 %i1, 0
12 %res = select i1 %cond, double %a, double %b
16 ; Check comparisons with 2.
17 define double @f2(double %a, double %b, i32 %i1) {
22 %cond = icmp slt i32 %i1, 2
23 %res = select i1 %cond, double %a, double %b
27 ; Check the high end of the CIJ range.
28 define double @f3(double %a, double %b, i32 %i1) {
30 ; CHECK: cijl %r2, 127
33 %cond = icmp slt i32 %i1, 127
34 %res = select i1 %cond, double %a, double %b
38 ; Check the next value up, which must use CHI instead.
39 define double @f4(double %a, double %b, i32 %i1) {
45 %cond = icmp slt i32 %i1, 128
46 %res = select i1 %cond, double %a, double %b
50 ; Check the high end of the CHI range.
51 define double @f5(double %a, double %b, i32 %i1) {
53 ; CHECK: chi %r2, 32767
57 %cond = icmp slt i32 %i1, 32767
58 %res = select i1 %cond, double %a, double %b
62 ; Check the next value up, which must use CFI.
63 define double @f6(double %a, double %b, i32 %i1) {
65 ; CHECK: cfi %r2, 32768
69 %cond = icmp slt i32 %i1, 32768
70 %res = select i1 %cond, double %a, double %b
74 ; Check the high end of the signed 32-bit range.
75 define double @f7(double %a, double %b, i32 %i1) {
77 ; CHECK: cfi %r2, 2147483647
81 %cond = icmp eq i32 %i1, 2147483647
82 %res = select i1 %cond, double %a, double %b
86 ; Check the next value up, which should be treated as a negative value.
87 define double @f8(double %a, double %b, i32 %i1) {
89 ; CHECK: cfi %r2, -2147483648
93 %cond = icmp eq i32 %i1, 2147483648
94 %res = select i1 %cond, double %a, double %b
98 ; Check the high end of the negative CIJ range.
99 define double @f9(double %a, double %b, i32 %i1) {
101 ; CHECK: cijl %r2, -1
102 ; CHECK: ldr %f0, %f2
104 %cond = icmp slt i32 %i1, -1
105 %res = select i1 %cond, double %a, double %b
109 ; Check the low end of the CIJ range.
110 define double @f10(double %a, double %b, i32 %i1) {
112 ; CHECK: cijl %r2, -128
113 ; CHECK: ldr %f0, %f2
115 %cond = icmp slt i32 %i1, -128
116 %res = select i1 %cond, double %a, double %b
120 ; Check the next value down, which must use CHI instead.
121 define double @f11(double %a, double %b, i32 %i1) {
123 ; CHECK: chi %r2, -129
125 ; CHECK: ldr %f0, %f2
127 %cond = icmp slt i32 %i1, -129
128 %res = select i1 %cond, double %a, double %b
132 ; Check the low end of the CHI range.
133 define double @f12(double %a, double %b, i32 %i1) {
135 ; CHECK: chi %r2, -32768
137 ; CHECK: ldr %f0, %f2
139 %cond = icmp slt i32 %i1, -32768
140 %res = select i1 %cond, double %a, double %b
144 ; Check the next value down, which must use CFI instead.
145 define double @f13(double %a, double %b, i32 %i1) {
147 ; CHECK: cfi %r2, -32769
149 ; CHECK: ldr %f0, %f2
151 %cond = icmp slt i32 %i1, -32769
152 %res = select i1 %cond, double %a, double %b
156 ; Check the low end of the signed 32-bit range.
157 define double @f14(double %a, double %b, i32 %i1) {
159 ; CHECK: cfi %r2, -2147483648
161 ; CHECK: ldr %f0, %f2
163 %cond = icmp eq i32 %i1, -2147483648
164 %res = select i1 %cond, double %a, double %b
168 ; Check the next value down, which should be treated as a positive value.
169 define double @f15(double %a, double %b, i32 %i1) {
171 ; CHECK: cfi %r2, 2147483647
173 ; CHECK: ldr %f0, %f2
175 %cond = icmp eq i32 %i1, -2147483649
176 %res = select i1 %cond, double %a, double %b
180 ; Check that < 1 becomes <= 0.
181 define double @f16(double %a, double %b, i32 %i1) {
183 ; CHECK: cijle %r2, 0
184 ; CHECK: ldr %f0, %f2
186 %cond = icmp slt i32 %i1, 1
187 %res = select i1 %cond, double %a, double %b
191 ; Check that >= 1 becomes > 0.
192 define double @f17(double %a, double %b, i32 %i1) {
195 ; CHECK: ldr %f0, %f2
197 %cond = icmp sge i32 %i1, 1
198 %res = select i1 %cond, double %a, double %b
202 ; Check that > -1 becomes >= 0.
203 define double @f18(double %a, double %b, i32 %i1) {
205 ; CHECK: cijhe %r2, 0
206 ; CHECK: ldr %f0, %f2
208 %cond = icmp sgt i32 %i1, -1
209 %res = select i1 %cond, double %a, double %b
213 ; Check that <= -1 becomes < 0.
214 define double @f19(double %a, double %b, i32 %i1) {
217 ; CHECK: ldr %f0, %f2
219 %cond = icmp sle i32 %i1, -1
220 %res = select i1 %cond, double %a, double %b