1; Test 32-bit signed comparison in which the second operand is constant.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4
5; Check comparisons with 0.
6define double @f1(double %a, double %b, i32 %i1) {
7; CHECK-LABEL: f1:
8; CHECK: cijl %r2, 0
9; CHECK: ldr %f0, %f2
10; CHECK: br %r14
11  %cond = icmp slt i32 %i1, 0
12  %tmp = select i1 %cond, double %a, double %b
13  %res = fadd double %tmp, 1.0
14  ret double %res
15}
16
17; Check comparisons with 2.
18define double @f2(double %a, double %b, i32 %i1) {
19; CHECK-LABEL: f2:
20; CHECK: cijl %r2, 2
21; CHECK: ldr %f0, %f2
22; CHECK: br %r14
23  %cond = icmp slt i32 %i1, 2
24  %tmp = select i1 %cond, double %a, double %b
25  %res = fadd double %tmp, 1.0
26  ret double %res
27}
28
29; Check the high end of the CIJ range.
30define double @f3(double %a, double %b, i32 %i1) {
31; CHECK-LABEL: f3:
32; CHECK: cijl %r2, 127
33; CHECK: ldr %f0, %f2
34; CHECK: br %r14
35  %cond = icmp slt i32 %i1, 127
36  %tmp = select i1 %cond, double %a, double %b
37  %res = fadd double %tmp, 1.0
38  ret double %res
39}
40
41; Check the next value up, which must use CHI instead.
42define double @f4(double %a, double %b, i32 %i1) {
43; CHECK-LABEL: f4:
44; CHECK: chi %r2, 128
45; CHECK-NEXT: jl
46; CHECK: ldr %f0, %f2
47; CHECK: br %r14
48  %cond = icmp slt i32 %i1, 128
49  %tmp = select i1 %cond, double %a, double %b
50  %res = fadd double %tmp, 1.0
51  ret double %res
52}
53
54; Check the high end of the CHI range.
55define double @f5(double %a, double %b, i32 %i1) {
56; CHECK-LABEL: f5:
57; CHECK: chi %r2, 32767
58; CHECK-NEXT: jl
59; CHECK: ldr %f0, %f2
60; CHECK: br %r14
61  %cond = icmp slt i32 %i1, 32767
62  %tmp = select i1 %cond, double %a, double %b
63  %res = fadd double %tmp, 1.0
64  ret double %res
65}
66
67; Check the next value up, which must use CFI.
68define double @f6(double %a, double %b, i32 %i1) {
69; CHECK-LABEL: f6:
70; CHECK: cfi %r2, 32768
71; CHECK-NEXT: jl
72; CHECK: ldr %f0, %f2
73; CHECK: br %r14
74  %cond = icmp slt i32 %i1, 32768
75  %tmp = select i1 %cond, double %a, double %b
76  %res = fadd double %tmp, 1.0
77  ret double %res
78}
79
80; Check the high end of the signed 32-bit range.
81define double @f7(double %a, double %b, i32 %i1) {
82; CHECK-LABEL: f7:
83; CHECK: cfi %r2, 2147483647
84; CHECK-NEXT: je
85; CHECK: ldr %f0, %f2
86; CHECK: br %r14
87  %cond = icmp eq i32 %i1, 2147483647
88  %tmp = select i1 %cond, double %a, double %b
89  %res = fadd double %tmp, 1.0
90  ret double %res
91}
92
93; Check the next value up, which should be treated as a negative value.
94define double @f8(double %a, double %b, i32 %i1) {
95; CHECK-LABEL: f8:
96; CHECK: cfi %r2, -2147483648
97; CHECK-NEXT: je
98; CHECK: ldr %f0, %f2
99; CHECK: br %r14
100  %cond = icmp eq i32 %i1, 2147483648
101  %tmp = select i1 %cond, double %a, double %b
102  %res = fadd double %tmp, 1.0
103  ret double %res
104}
105
106; Check the high end of the negative CIJ range.
107define double @f9(double %a, double %b, i32 %i1) {
108; CHECK-LABEL: f9:
109; CHECK: cijl %r2, -1
110; CHECK: ldr %f0, %f2
111; CHECK: br %r14
112  %cond = icmp slt i32 %i1, -1
113  %tmp = select i1 %cond, double %a, double %b
114  %res = fadd double %tmp, 1.0
115  ret double %res
116}
117
118; Check the low end of the CIJ range.
119define double @f10(double %a, double %b, i32 %i1) {
120; CHECK-LABEL: f10:
121; CHECK: cijl %r2, -128
122; CHECK: ldr %f0, %f2
123; CHECK: br %r14
124  %cond = icmp slt i32 %i1, -128
125  %tmp = select i1 %cond, double %a, double %b
126  %res = fadd double %tmp, 1.0
127  ret double %res
128}
129
130; Check the next value down, which must use CHI instead.
131define double @f11(double %a, double %b, i32 %i1) {
132; CHECK-LABEL: f11:
133; CHECK: chi %r2, -129
134; CHECK-NEXT: jl
135; CHECK: ldr %f0, %f2
136; CHECK: br %r14
137  %cond = icmp slt i32 %i1, -129
138  %tmp = select i1 %cond, double %a, double %b
139  %res = fadd double %tmp, 1.0
140  ret double %res
141}
142
143; Check the low end of the CHI range.
144define double @f12(double %a, double %b, i32 %i1) {
145; CHECK-LABEL: f12:
146; CHECK: chi %r2, -32768
147; CHECK-NEXT: jl
148; CHECK: ldr %f0, %f2
149; CHECK: br %r14
150  %cond = icmp slt i32 %i1, -32768
151  %tmp = select i1 %cond, double %a, double %b
152  %res = fadd double %tmp, 1.0
153  ret double %res
154}
155
156; Check the next value down, which must use CFI instead.
157define double @f13(double %a, double %b, i32 %i1) {
158; CHECK-LABEL: f13:
159; CHECK: cfi %r2, -32769
160; CHECK-NEXT: jl
161; CHECK: ldr %f0, %f2
162; CHECK: br %r14
163  %cond = icmp slt i32 %i1, -32769
164  %tmp = select i1 %cond, double %a, double %b
165  %res = fadd double %tmp, 1.0
166  ret double %res
167}
168
169; Check the low end of the signed 32-bit range.
170define double @f14(double %a, double %b, i32 %i1) {
171; CHECK-LABEL: f14:
172; CHECK: cfi %r2, -2147483648
173; CHECK-NEXT: je
174; CHECK: ldr %f0, %f2
175; CHECK: br %r14
176  %cond = icmp eq i32 %i1, -2147483648
177  %tmp = select i1 %cond, double %a, double %b
178  %res = fadd double %tmp, 1.0
179  ret double %res
180}
181
182; Check the next value down, which should be treated as a positive value.
183define double @f15(double %a, double %b, i32 %i1) {
184; CHECK-LABEL: f15:
185; CHECK: cfi %r2, 2147483647
186; CHECK-NEXT: je
187; CHECK: ldr %f0, %f2
188; CHECK: br %r14
189  %cond = icmp eq i32 %i1, -2147483649
190  %tmp = select i1 %cond, double %a, double %b
191  %res = fadd double %tmp, 1.0
192  ret double %res
193}
194
195; Check that < 1 becomes <= 0.
196define double @f16(double %a, double %b, i32 %i1) {
197; CHECK-LABEL: f16:
198; CHECK: cijle %r2, 0
199; CHECK: ldr %f0, %f2
200; CHECK: br %r14
201  %cond = icmp slt i32 %i1, 1
202  %tmp = select i1 %cond, double %a, double %b
203  %res = fadd double %tmp, 1.0
204  ret double %res
205}
206
207; Check that >= 1 becomes > 0.
208define double @f17(double %a, double %b, i32 %i1) {
209; CHECK-LABEL: f17:
210; CHECK: cijh %r2, 0
211; CHECK: ldr %f0, %f2
212; CHECK: br %r14
213  %cond = icmp sge i32 %i1, 1
214  %tmp = select i1 %cond, double %a, double %b
215  %res = fadd double %tmp, 1.0
216  ret double %res
217}
218
219; Check that > -1 becomes >= 0.
220define double @f18(double %a, double %b, i32 %i1) {
221; CHECK-LABEL: f18:
222; CHECK: cijhe %r2, 0
223; CHECK: ldr %f0, %f2
224; CHECK: br %r14
225  %cond = icmp sgt i32 %i1, -1
226  %tmp = select i1 %cond, double %a, double %b
227  %res = fadd double %tmp, 1.0
228  ret double %res
229}
230
231; Check that <= -1 becomes < 0.
232define double @f19(double %a, double %b, i32 %i1) {
233; CHECK-LABEL: f19:
234; CHECK: cijl %r2, 0
235; CHECK: ldr %f0, %f2
236; CHECK: br %r14
237  %cond = icmp sle i32 %i1, -1
238  %tmp = select i1 %cond, double %a, double %b
239  %res = fadd double %tmp, 1.0
240  ret double %res
241}
242