1 ; Test 32-bit floating-point comparison. The tests assume a z10 implementation
2 ; of select, using conditional branches rather than LOCGR.
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z10 \
5 ; RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK-SCALAR %s
6 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z14 \
7 ; RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK-VECTOR %s
11 ; Check comparison with registers.
12 define i64 @f1(i64 %a, i64 %b, float %f1, float %f2) {
14 ; CHECK: cebr %f0, %f2
15 ; CHECK-SCALAR-NEXT: ber %r14
16 ; CHECK-SCALAR: lgr %r2, %r3
17 ; CHECK-VECTOR-NEXT: locgrne %r2, %r3
19 %cond = fcmp oeq float %f1, %f2
20 %res = select i1 %cond, i64 %a, i64 %b
24 ; Check the low end of the CEB range.
25 define i64 @f2(i64 %a, i64 %b, float %f1, ptr %ptr) {
27 ; CHECK: ceb %f0, 0(%r4)
28 ; CHECK-SCALAR-NEXT: ber %r14
29 ; CHECK-SCALAR: lgr %r2, %r3
30 ; CHECK-VECTOR-NEXT: locgrne %r2, %r3
32 %f2 = load float, ptr %ptr
33 %cond = fcmp oeq float %f1, %f2
34 %res = select i1 %cond, i64 %a, i64 %b
38 ; Check the high end of the aligned CEB range.
39 define i64 @f3(i64 %a, i64 %b, float %f1, ptr %base) {
41 ; CHECK: ceb %f0, 4092(%r4)
42 ; CHECK-SCALAR-NEXT: ber %r14
43 ; CHECK-SCALAR: lgr %r2, %r3
44 ; CHECK-VECTOR-NEXT: locgrne %r2, %r3
46 %ptr = getelementptr float, ptr %base, i64 1023
47 %f2 = load float, ptr %ptr
48 %cond = fcmp oeq float %f1, %f2
49 %res = select i1 %cond, i64 %a, i64 %b
53 ; Check the next word up, which needs separate address logic.
54 ; Other sequences besides this one would be OK.
55 define i64 @f4(i64 %a, i64 %b, float %f1, ptr %base) {
57 ; CHECK: aghi %r4, 4096
58 ; CHECK: ceb %f0, 0(%r4)
59 ; CHECK-SCALAR-NEXT: ber %r14
60 ; CHECK-SCALAR: lgr %r2, %r3
61 ; CHECK-VECTOR-NEXT: locgrne %r2, %r3
63 %ptr = getelementptr float, ptr %base, i64 1024
64 %f2 = load float, ptr %ptr
65 %cond = fcmp oeq float %f1, %f2
66 %res = select i1 %cond, i64 %a, i64 %b
70 ; Check negative displacements, which also need separate address logic.
71 define i64 @f5(i64 %a, i64 %b, float %f1, ptr %base) {
74 ; CHECK: ceb %f0, 0(%r4)
75 ; CHECK-SCALAR-NEXT: ber %r14
76 ; CHECK-SCALAR: lgr %r2, %r3
77 ; CHECK-VECTOR-NEXT: locgrne %r2, %r3
79 %ptr = getelementptr float, ptr %base, i64 -1
80 %f2 = load float, ptr %ptr
81 %cond = fcmp oeq float %f1, %f2
82 %res = select i1 %cond, i64 %a, i64 %b
86 ; Check that CEB allows indices.
87 define i64 @f6(i64 %a, i64 %b, float %f1, ptr %base, i64 %index) {
89 ; CHECK: sllg %r1, %r5, 2
90 ; CHECK: ceb %f0, 400(%r1,%r4)
91 ; CHECK-SCALAR-NEXT: ber %r14
92 ; CHECK-SCALAR: lgr %r2, %r3
93 ; CHECK-VECTOR-NEXT: locgrne %r2, %r3
95 %ptr1 = getelementptr float, ptr %base, i64 %index
96 %ptr2 = getelementptr float, ptr %ptr1, i64 100
97 %f2 = load float, ptr %ptr2
98 %cond = fcmp oeq float %f1, %f2
99 %res = select i1 %cond, i64 %a, i64 %b
103 ; Check that comparisons of spilled values can use CEB rather than CEBR.
104 define float @f7(ptr %ptr0) {
106 ; CHECK: brasl %r14, foo@PLT
107 ; CHECK-SCALAR: ceb {{%f[0-9]+}}, 16{{[04]}}(%r15)
109 %ptr1 = getelementptr float, ptr %ptr0, i64 2
110 %ptr2 = getelementptr float, ptr %ptr0, i64 4
111 %ptr3 = getelementptr float, ptr %ptr0, i64 6
112 %ptr4 = getelementptr float, ptr %ptr0, i64 8
113 %ptr5 = getelementptr float, ptr %ptr0, i64 10
114 %ptr6 = getelementptr float, ptr %ptr0, i64 12
115 %ptr7 = getelementptr float, ptr %ptr0, i64 14
116 %ptr8 = getelementptr float, ptr %ptr0, i64 16
117 %ptr9 = getelementptr float, ptr %ptr0, i64 18
118 %ptr10 = getelementptr float, ptr %ptr0, i64 20
120 %val0 = load float, ptr %ptr0
121 %val1 = load float, ptr %ptr1
122 %val2 = load float, ptr %ptr2
123 %val3 = load float, ptr %ptr3
124 %val4 = load float, ptr %ptr4
125 %val5 = load float, ptr %ptr5
126 %val6 = load float, ptr %ptr6
127 %val7 = load float, ptr %ptr7
128 %val8 = load float, ptr %ptr8
129 %val9 = load float, ptr %ptr9
130 %val10 = load float, ptr %ptr10
132 %ret = call float @foo()
134 %cmp0 = fcmp olt float %ret, %val0
135 %cmp1 = fcmp olt float %ret, %val1
136 %cmp2 = fcmp olt float %ret, %val2
137 %cmp3 = fcmp olt float %ret, %val3
138 %cmp4 = fcmp olt float %ret, %val4
139 %cmp5 = fcmp olt float %ret, %val5
140 %cmp6 = fcmp olt float %ret, %val6
141 %cmp7 = fcmp olt float %ret, %val7
142 %cmp8 = fcmp olt float %ret, %val8
143 %cmp9 = fcmp olt float %ret, %val9
144 %cmp10 = fcmp olt float %ret, %val10
146 %sel0 = select i1 %cmp0, float %ret, float 0.0
147 %sel1 = select i1 %cmp1, float %sel0, float 1.0
148 %sel2 = select i1 %cmp2, float %sel1, float 2.0
149 %sel3 = select i1 %cmp3, float %sel2, float 3.0
150 %sel4 = select i1 %cmp4, float %sel3, float 4.0
151 %sel5 = select i1 %cmp5, float %sel4, float 5.0
152 %sel6 = select i1 %cmp6, float %sel5, float 6.0
153 %sel7 = select i1 %cmp7, float %sel6, float 7.0
154 %sel8 = select i1 %cmp8, float %sel7, float 8.0
155 %sel9 = select i1 %cmp9, float %sel8, float 9.0
156 %sel10 = select i1 %cmp10, float %sel9, float 10.0
161 ; Check comparison with zero.
162 define i64 @f8(i64 %a, i64 %b, float %f) {
164 ; CHECK: ltebr %f0, %f0
165 ; CHECK-SCALAR-NEXT: ber %r14
166 ; CHECK-SCALAR: lgr %r2, %r3
167 ; CHECK-VECTOR-NEXT: locgrne %r2, %r3
169 %cond = fcmp oeq float %f, 0.0
170 %res = select i1 %cond, i64 %a, i64 %b
174 ; Check the comparison can be reversed if that allows CEB to be used,
176 define i64 @f9(i64 %a, i64 %b, float %f2, ptr %ptr) {
178 ; CHECK: ceb %f0, 0(%r4)
179 ; CHECK-SCALAR-NEXT: ber %r14
180 ; CHECK-SCALAR: lgr %r2, %r3
181 ; CHECK-VECTOR-NEXT: locgrne %r2, %r3
183 %f1 = load float, ptr %ptr
184 %cond = fcmp oeq float %f1, %f2
185 %res = select i1 %cond, i64 %a, i64 %b
190 define i64 @f10(i64 %a, i64 %b, float %f2, ptr %ptr) {
192 ; CHECK: ceb %f0, 0(%r4)
193 ; CHECK-SCALAR-NEXT: blhr %r14
194 ; CHECK-SCALAR: lgr %r2, %r3
195 ; CHECK-VECTOR-NEXT: locgrnlh %r2, %r3
197 %f1 = load float, ptr %ptr
198 %cond = fcmp one float %f1, %f2
199 %res = select i1 %cond, i64 %a, i64 %b
204 define i64 @f11(i64 %a, i64 %b, float %f2, ptr %ptr) {
206 ; CHECK: ceb %f0, 0(%r4)
207 ; CHECK-SCALAR-NEXT: bhr %r14
208 ; CHECK-SCALAR: lgr %r2, %r3
209 ; CHECK-VECTOR-NEXT: locgrnh %r2, %r3
211 %f1 = load float, ptr %ptr
212 %cond = fcmp olt float %f1, %f2
213 %res = select i1 %cond, i64 %a, i64 %b
218 define i64 @f12(i64 %a, i64 %b, float %f2, ptr %ptr) {
220 ; CHECK: ceb %f0, 0(%r4)
221 ; CHECK-SCALAR-NEXT: bher %r14
222 ; CHECK-SCALAR: lgr %r2, %r3
223 ; CHECK-VECTOR-NEXT: locgrnhe %r2, %r3
225 %f1 = load float, ptr %ptr
226 %cond = fcmp ole float %f1, %f2
227 %res = select i1 %cond, i64 %a, i64 %b
232 define i64 @f13(i64 %a, i64 %b, float %f2, ptr %ptr) {
234 ; CHECK: ceb %f0, 0(%r4)
235 ; CHECK-SCALAR-NEXT: bler %r14
236 ; CHECK-SCALAR: lgr %r2, %r3
237 ; CHECK-VECTOR-NEXT: locgrnle %r2, %r3
239 %f1 = load float, ptr %ptr
240 %cond = fcmp oge float %f1, %f2
241 %res = select i1 %cond, i64 %a, i64 %b
246 define i64 @f14(i64 %a, i64 %b, float %f2, ptr %ptr) {
248 ; CHECK: ceb %f0, 0(%r4)
249 ; CHECK-SCALAR-NEXT: blr %r14
250 ; CHECK-SCALAR: lgr %r2, %r3
251 ; CHECK-VECTOR-NEXT: locgrnl %r2, %r3
253 %f1 = load float, ptr %ptr
254 %cond = fcmp ogt float %f1, %f2
255 %res = select i1 %cond, i64 %a, i64 %b
260 define i64 @f15(i64 %a, i64 %b, float %f2, ptr %ptr) {
262 ; CHECK: ceb %f0, 0(%r4)
263 ; CHECK-SCALAR-NEXT: bnlhr %r14
264 ; CHECK-SCALAR: lgr %r2, %r3
265 ; CHECK-VECTOR-NEXT: locgrlh %r2, %r3
267 %f1 = load float, ptr %ptr
268 %cond = fcmp ueq float %f1, %f2
269 %res = select i1 %cond, i64 %a, i64 %b
274 define i64 @f16(i64 %a, i64 %b, float %f2, ptr %ptr) {
276 ; CHECK: ceb %f0, 0(%r4)
277 ; CHECK-SCALAR-NEXT: bner %r14
278 ; CHECK-SCALAR: lgr %r2, %r3
279 ; CHECK-VECTOR-NEXT: locgre %r2, %r3
281 %f1 = load float, ptr %ptr
282 %cond = fcmp une float %f1, %f2
283 %res = select i1 %cond, i64 %a, i64 %b
288 define i64 @f17(i64 %a, i64 %b, float %f2, ptr %ptr) {
290 ; CHECK: ceb %f0, 0(%r4)
291 ; CHECK-SCALAR-NEXT: bnler %r14
292 ; CHECK-SCALAR: lgr %r2, %r3
293 ; CHECK-VECTOR-NEXT: locgrle %r2, %r3
295 %f1 = load float, ptr %ptr
296 %cond = fcmp ult float %f1, %f2
297 %res = select i1 %cond, i64 %a, i64 %b
302 define i64 @f18(i64 %a, i64 %b, float %f2, ptr %ptr) {
304 ; CHECK: ceb %f0, 0(%r4)
305 ; CHECK-SCALAR-NEXT: bnlr %r14
306 ; CHECK-SCALAR: lgr %r2, %r3
307 ; CHECK-VECTOR-NEXT: locgrl %r2, %r3
309 %f1 = load float, ptr %ptr
310 %cond = fcmp ule float %f1, %f2
311 %res = select i1 %cond, i64 %a, i64 %b
316 define i64 @f19(i64 %a, i64 %b, float %f2, ptr %ptr) {
318 ; CHECK: ceb %f0, 0(%r4)
319 ; CHECK-SCALAR-NEXT: bnhr %r14
320 ; CHECK-SCALAR: lgr %r2, %r3
321 ; CHECK-VECTOR-NEXT: locgrh %r2, %r3
323 %f1 = load float, ptr %ptr
324 %cond = fcmp uge float %f1, %f2
325 %res = select i1 %cond, i64 %a, i64 %b
330 define i64 @f20(i64 %a, i64 %b, float %f2, ptr %ptr) {
332 ; CHECK: ceb %f0, 0(%r4)
333 ; CHECK-SCALAR-NEXT: bnher %r14
334 ; CHECK-SCALAR: lgr %r2, %r3
335 ; CHECK-VECTOR-NEXT: locgrhe %r2, %r3
337 %f1 = load float, ptr %ptr
338 %cond = fcmp ugt float %f1, %f2
339 %res = select i1 %cond, i64 %a, i64 %b