1 ; RUN: llc -mtriple=xtensa -disable-block-placement -verify-machineinstrs < %s \
4 define i32 @f_eq(i32 %a, ptr %b) nounwind {
6 ; CHECK: l32i a8, a3, 0
7 ; CHECK-NEXT: beq a2, a8, .LBB0_2
9 ; CHECK-NEXT: or a2, a8, a8
10 ; CHECK-NEXT: .LBB0_2:
12 %val1 = load i32, ptr %b
13 %tst1 = icmp eq i32 %a, %val1
14 %val2 = select i1 %tst1, i32 %a, i32 %val1
18 define i32 @f_ne(i32 %a, ptr %b) nounwind {
20 ; CHECK: l32i a8, a3, 0
21 ; CHECK-NEXT: bne a2, a8, .LBB1_2
22 ; CHECK-NEXT: # %bb.1:
23 ; CHECK-NEXT: or a2, a8, a8
24 ; CHECK-NEXT: .LBB1_2:
26 %val1 = load i32, ptr %b
27 %tst1 = icmp ne i32 %a, %val1
28 %val2 = select i1 %tst1, i32 %a, i32 %val1
32 define i32 @f_ugt(i32 %a, ptr %b) nounwind {
34 ; CHECK: or a8, a2, a2
35 ; CHECK-NEXT: l32i a2, a3, 0
36 ; CHECK-NEXT: bgeu a2, a8, .LBB2_2
37 ; CHECK-NEXT: # %bb.1:
38 ; CHECK-NEXT: or a2, a8, a8
39 ; CHECK-NEXT: .LBB2_2:
41 %val1 = load i32, ptr %b
42 %tst1 = icmp ugt i32 %a, %val1
43 %val2 = select i1 %tst1, i32 %a, i32 %val1
47 define i32 @f_uge(i32 %a, ptr %b) nounwind {
49 ; CHECK: l32i a8, a3, 0
50 ; CHECK-NEXT: bgeu a2, a8, .LBB3_2
51 ; CHECK-NEXT: # %bb.1:
52 ; CHECK-NEXT: or a2, a8, a8
53 ; CHECK-NEXT: .LBB3_2:
55 %val1 = load i32, ptr %b
56 %tst1 = icmp uge i32 %a, %val1
57 %val2 = select i1 %tst1, i32 %a, i32 %val1
61 define i32 @f_ult(i32 %a, ptr %b) nounwind {
63 ; CHECK: l32i a8, a3, 0
64 ; CHECK-NEXT: bltu a2, a8, .LBB4_2
65 ; CHECK-NEXT: # %bb.1:
66 ; CHECK-NEXT: or a2, a8, a8
67 ; CHECK-NEXT: .LBB4_2:
69 %val1 = load i32, ptr %b
70 %tst1 = icmp ult i32 %a, %val1
71 %val2 = select i1 %tst1, i32 %a, i32 %val1
75 define i32 @f_ule(i32 %a, ptr %b) nounwind {
77 ; CHECK: or a8, a2, a2
78 ; CHECK-NEXT: l32i a2, a3, 0
79 ; CHECK-NEXT: bltu a2, a8, .LBB5_2
80 ; CHECK-NEXT: # %bb.1:
81 ; CHECK-NEXT: or a2, a8, a8
82 ; CHECK-NEXT: .LBB5_2:
84 %val1 = load i32, ptr %b
85 %tst1 = icmp ule i32 %a, %val1
86 %val2 = select i1 %tst1, i32 %a, i32 %val1
90 define i32 @f_sgt(i32 %a, ptr %b) nounwind {
92 ; CHECK: or a8, a2, a2
93 ; CHECK-NEXT: l32i a2, a3, 0
94 ; CHECK-NEXT: bge a2, a8, .LBB6_2
95 ; CHECK-NEXT: # %bb.1:
96 ; CHECK-NEXT: or a2, a8, a8
97 ; CHECK-NEXT: .LBB6_2:
99 %val1 = load i32, ptr %b
100 %tst1 = icmp sgt i32 %a, %val1
101 %val2 = select i1 %tst1, i32 %a, i32 %val1
105 define i32 @f_sge(i32 %a, ptr %b) nounwind {
106 ; CHECK-LABEL: f_sge:
107 ; CHECK: l32i a8, a3, 0
108 ; CHECK-NEXT: bge a2, a8, .LBB7_2
109 ; CHECK-NEXT: # %bb.1:
110 ; CHECK-NEXT: or a2, a8, a8
111 ; CHECK-NEXT: .LBB7_2:
113 %val1 = load i32, ptr %b
114 %tst1 = icmp sge i32 %a, %val1
115 %val2 = select i1 %tst1, i32 %a, i32 %val1
119 define i32 @f_slt(i32 %a, ptr %b) nounwind {
120 ; CHECK-LABEL: f_slt:
121 ; CHECK: l32i a8, a3, 0
122 ; CHECK-NEXT: blt a2, a8, .LBB8_2
123 ; CHECK-NEXT: # %bb.1:
124 ; CHECK-NEXT: or a2, a8, a8
125 ; CHECK-NEXT: .LBB8_2:
127 %val1 = load i32, ptr %b
128 %tst1 = icmp slt i32 %a, %val1
129 %val2 = select i1 %tst1, i32 %a, i32 %val1
133 define i32 @f_sle(i32 %a, ptr %b) nounwind {
134 ; CHECK-LABEL: f_sle:
135 ; CHECK: or a8, a2, a2
136 ; CHECK-NEXT: l32i a2, a3, 0
137 ; CHECK-NEXT: blt a2, a8, .LBB9_2
138 ; CHECK-NEXT: # %bb.1:
139 ; CHECK-NEXT: or a2, a8, a8
140 ; CHECK-NEXT: .LBB9_2:
142 %val1 = load i32, ptr %b
143 %tst1 = icmp sle i32 %a, %val1
144 %val2 = select i1 %tst1, i32 %a, i32 %val1
148 define i32 @f_slt_imm(i32 %a, ptr %b) nounwind {
149 ; CHECK-LABEL: f_slt_imm:
151 ; CHECK-NEXT: blt a2, a8, .LBB10_2
152 ; CHECK-NEXT: # %bb.1:
153 ; CHECK-NEXT: l32i a2, a3, 0
154 ; CHECK-NEXT: .LBB10_2:
156 %val1 = load i32, ptr %b
157 %tst1 = icmp slt i32 %a, 1
158 %val2 = select i1 %tst1, i32 %a, i32 %val1
162 define i32 @f_sgt_imm(i32 %a, ptr %b) nounwind {
163 ; CHECK-LABEL: f_sgt_imm:
164 ; CHECK: or a8, a2, a2
165 ; CHECK-NEXT: l32i a2, a3, 0
166 ; CHECK-NEXT: movi a9, -1
167 ; CHECK-NEXT: bge a9, a8, .LBB11_2
168 ; CHECK-NEXT: # %bb.1:
169 ; CHECK-NEXT: or a2, a8, a8
170 ; CHECK-NEXT: .LBB11_2:
172 %val1 = load i32, ptr %b
173 %tst1 = icmp sgt i32 %a, -1
174 %val2 = select i1 %tst1, i32 %a, i32 %val1
178 define i32 @f_ult_imm(i32 %a, ptr %b) nounwind {
179 ; CHECK-LABEL: f_ult_imm:
180 ; CHECK: movi a8, 1024
181 ; CHECK-NEXT: bltu a2, a8, .LBB12_2
182 ; CHECK-NEXT: # %bb.1:
183 ; CHECK-NEXT: l32i a2, a3, 0
184 ; CHECK-NEXT: .LBB12_2:
186 %val1 = load i32, ptr %b
187 %tst1 = icmp ult i32 %a, 1024
188 %val2 = select i1 %tst1, i32 %a, i32 %val1
192 ; Tests for i64 operands
194 define i64 @f_eq_i64(i64 %a, ptr %b) nounwind {
195 ; CHECK-LABEL: f_eq_i64:
196 ; CHECK: l32i a8, a4, 4
197 ; CHECK-NEXT: xor a9, a3, a8
198 ; CHECK-NEXT: l32i a11, a4, 0
199 ; CHECK-NEXT: xor a10, a2, a11
200 ; CHECK-NEXT: or a9, a10, a9
201 ; CHECK-NEXT: movi a10, 0
202 ; CHECK-NEXT: beq a9, a10, .LBB13_2
203 ; CHECK-NEXT: # %bb.1:
204 ; CHECK-NEXT: or a2, a11, a11
205 ; CHECK-NEXT: .LBB13_2:
206 ; CHECK-NEXT: beq a9, a10, .LBB13_4
207 ; CHECK-NEXT: # %bb.3:
208 ; CHECK-NEXT: or a3, a8, a8
209 ; CHECK-NEXT: .LBB13_4:
211 %val1 = load i64, ptr %b
212 %tst1 = icmp eq i64 %a, %val1
213 %val2 = select i1 %tst1, i64 %a, i64 %val1
217 define i64 @f_ne_i64(i64 %a, ptr %b) nounwind {
218 ; CHECK-LABEL: f_ne_i64:
219 ; CHECK: l32i a8, a4, 4
220 ; CHECK-NEXT: xor a9, a3, a8
221 ; CHECK-NEXT: l32i a11, a4, 0
222 ; CHECK-NEXT: xor a10, a2, a11
223 ; CHECK-NEXT: or a9, a10, a9
224 ; CHECK-NEXT: movi a10, 0
225 ; CHECK-NEXT: bne a9, a10, .LBB14_2
226 ; CHECK-NEXT: # %bb.1:
227 ; CHECK-NEXT: or a2, a11, a11
228 ; CHECK-NEXT: .LBB14_2:
229 ; CHECK-NEXT: bne a9, a10, .LBB14_4
230 ; CHECK-NEXT: # %bb.3:
231 ; CHECK-NEXT: or a3, a8, a8
232 ; CHECK-NEXT: .LBB14_4:
234 %val1 = load i64, ptr %b
235 %tst1 = icmp ne i64 %a, %val1
236 %val2 = select i1 %tst1, i64 %a, i64 %val1
240 define i64 @f_ugt_i64(i64 %a, ptr %b) nounwind {
241 ; CHECK-LABEL: f_ugt_i64:
242 ; CHECK: l32i a8, a4, 4
243 ; CHECK-NEXT: movi a9, 0
244 ; CHECK-NEXT: movi a10, 1
245 ; CHECK-NEXT: or a7, a10, a10
246 ; CHECK-NEXT: bltu a8, a3, .LBB15_2
247 ; CHECK-NEXT: # %bb.1:
248 ; CHECK-NEXT: or a7, a9, a9
249 ; CHECK-NEXT: .LBB15_2:
250 ; CHECK-NEXT: l32i a11, a4, 0
251 ; CHECK-NEXT: bltu a11, a2, .LBB15_4
252 ; CHECK-NEXT: # %bb.3:
253 ; CHECK-NEXT: or a10, a9, a9
254 ; CHECK-NEXT: .LBB15_4:
255 ; CHECK-NEXT: beq a3, a8, .LBB15_6
256 ; CHECK-NEXT: # %bb.5:
257 ; CHECK-NEXT: or a10, a7, a7
258 ; CHECK-NEXT: .LBB15_6:
259 ; CHECK-NEXT: bne a10, a9, .LBB15_8
260 ; CHECK-NEXT: # %bb.7:
261 ; CHECK-NEXT: or a2, a11, a11
262 ; CHECK-NEXT: .LBB15_8:
263 ; CHECK-NEXT: bne a10, a9, .LBB15_10
264 ; CHECK-NEXT: # %bb.9:
265 ; CHECK-NEXT: or a3, a8, a8
266 ; CHECK-NEXT: .LBB15_10:
268 %val1 = load i64, ptr %b
269 %tst1 = icmp ugt i64 %a, %val1
270 %val2 = select i1 %tst1, i64 %a, i64 %val1
274 define i64 @f_uge_i64(i64 %a, ptr %b) nounwind {
275 ; CHECK-LABEL: f_uge_i64:
276 ; CHECK: l32i a8, a4, 4
277 ; CHECK-NEXT: movi a9, 0
278 ; CHECK-NEXT: movi a10, 1
279 ; CHECK-NEXT: or a7, a10, a10
280 ; CHECK-NEXT: bgeu a3, a8, .LBB16_2
281 ; CHECK-NEXT: # %bb.1:
282 ; CHECK-NEXT: or a7, a9, a9
283 ; CHECK-NEXT: .LBB16_2:
284 ; CHECK-NEXT: l32i a11, a4, 0
285 ; CHECK-NEXT: bgeu a2, a11, .LBB16_4
286 ; CHECK-NEXT: # %bb.3:
287 ; CHECK-NEXT: or a10, a9, a9
288 ; CHECK-NEXT: .LBB16_4:
289 ; CHECK-NEXT: beq a3, a8, .LBB16_6
290 ; CHECK-NEXT: # %bb.5:
291 ; CHECK-NEXT: or a10, a7, a7
292 ; CHECK-NEXT: .LBB16_6:
293 ; CHECK-NEXT: bne a10, a9, .LBB16_8
294 ; CHECK-NEXT: # %bb.7:
295 ; CHECK-NEXT: or a2, a11, a11
296 ; CHECK-NEXT: .LBB16_8:
297 ; CHECK-NEXT: bne a10, a9, .LBB16_10
298 ; CHECK-NEXT: # %bb.9:
299 ; CHECK-NEXT: or a3, a8, a8
300 ; CHECK-NEXT: .LBB16_10:
302 %val1 = load i64, ptr %b
303 %tst1 = icmp uge i64 %a, %val1
304 %val2 = select i1 %tst1, i64 %a, i64 %val1
308 define i64 @f_ult_i64(i64 %a, ptr %b) nounwind {
309 ; CHECK-LABEL: f_ult_i64:
310 ; CHECK: l32i a8, a4, 4
311 ; CHECK-NEXT: movi a9, 0
312 ; CHECK-NEXT: movi a10, 1
313 ; CHECK-NEXT: or a7, a10, a10
314 ; CHECK-NEXT: bltu a3, a8, .LBB17_2
315 ; CHECK-NEXT: # %bb.1:
316 ; CHECK-NEXT: or a7, a9, a9
317 ; CHECK-NEXT: .LBB17_2:
318 ; CHECK-NEXT: l32i a11, a4, 0
319 ; CHECK-NEXT: bltu a2, a11, .LBB17_4
320 ; CHECK-NEXT: # %bb.3:
321 ; CHECK-NEXT: or a10, a9, a9
322 ; CHECK-NEXT: .LBB17_4:
323 ; CHECK-NEXT: beq a3, a8, .LBB17_6
324 ; CHECK-NEXT: # %bb.5:
325 ; CHECK-NEXT: or a10, a7, a7
326 ; CHECK-NEXT: .LBB17_6:
327 ; CHECK-NEXT: bne a10, a9, .LBB17_8
328 ; CHECK-NEXT: # %bb.7:
329 ; CHECK-NEXT: or a2, a11, a11
330 ; CHECK-NEXT: .LBB17_8:
331 ; CHECK-NEXT: bne a10, a9, .LBB17_10
332 ; CHECK-NEXT: # %bb.9:
333 ; CHECK-NEXT: or a3, a8, a8
334 ; CHECK-NEXT: .LBB17_10:
336 %val1 = load i64, ptr %b
337 %tst1 = icmp ult i64 %a, %val1
338 %val2 = select i1 %tst1, i64 %a, i64 %val1
342 define i64 @f_ule_i64(i64 %a, ptr %b) nounwind {
343 ; CHECK-LABEL: f_ule_i64:
344 ; CHECK: l32i a8, a4, 4
345 ; CHECK-NEXT: movi a9, 0
346 ; CHECK-NEXT: movi a10, 1
347 ; CHECK-NEXT: or a7, a10, a10
348 ; CHECK-NEXT: bgeu a8, a3, .LBB18_2
349 ; CHECK-NEXT: # %bb.1:
350 ; CHECK-NEXT: or a7, a9, a9
351 ; CHECK-NEXT: .LBB18_2:
352 ; CHECK-NEXT: l32i a11, a4, 0
353 ; CHECK-NEXT: bgeu a11, a2, .LBB18_4
354 ; CHECK-NEXT: # %bb.3:
355 ; CHECK-NEXT: or a10, a9, a9
356 ; CHECK-NEXT: .LBB18_4:
357 ; CHECK-NEXT: beq a3, a8, .LBB18_6
358 ; CHECK-NEXT: # %bb.5:
359 ; CHECK-NEXT: or a10, a7, a7
360 ; CHECK-NEXT: .LBB18_6:
361 ; CHECK-NEXT: bne a10, a9, .LBB18_8
362 ; CHECK-NEXT: # %bb.7:
363 ; CHECK-NEXT: or a2, a11, a11
364 ; CHECK-NEXT: .LBB18_8:
365 ; CHECK-NEXT: bne a10, a9, .LBB18_10
366 ; CHECK-NEXT: # %bb.9:
367 ; CHECK-NEXT: or a3, a8, a8
368 ; CHECK-NEXT: .LBB18_10:
370 %val1 = load i64, ptr %b
371 %tst1 = icmp ule i64 %a, %val1
372 %val2 = select i1 %tst1, i64 %a, i64 %val1
376 define i64 @f_sgt_i64(i64 %a, ptr %b) nounwind {
377 ; CHECK-LABEL: f_sgt_i64:
378 ; CHECK: l32i a8, a4, 4
379 ; CHECK-NEXT: movi a9, 0
380 ; CHECK-NEXT: movi a10, 1
381 ; CHECK-NEXT: or a7, a10, a10
382 ; CHECK-NEXT: blt a8, a3, .LBB19_2
383 ; CHECK-NEXT: # %bb.1:
384 ; CHECK-NEXT: or a7, a9, a9
385 ; CHECK-NEXT: .LBB19_2:
386 ; CHECK-NEXT: l32i a11, a4, 0
387 ; CHECK-NEXT: bltu a11, a2, .LBB19_4
388 ; CHECK-NEXT: # %bb.3:
389 ; CHECK-NEXT: or a10, a9, a9
390 ; CHECK-NEXT: .LBB19_4:
391 ; CHECK-NEXT: beq a3, a8, .LBB19_6
392 ; CHECK-NEXT: # %bb.5:
393 ; CHECK-NEXT: or a10, a7, a7
394 ; CHECK-NEXT: .LBB19_6:
395 ; CHECK-NEXT: bne a10, a9, .LBB19_8
396 ; CHECK-NEXT: # %bb.7:
397 ; CHECK-NEXT: or a2, a11, a11
398 ; CHECK-NEXT: .LBB19_8:
399 ; CHECK-NEXT: bne a10, a9, .LBB19_10
400 ; CHECK-NEXT: # %bb.9:
401 ; CHECK-NEXT: or a3, a8, a8
402 ; CHECK-NEXT: .LBB19_10:
404 %val1 = load i64, ptr %b
405 %tst1 = icmp sgt i64 %a, %val1
406 %val2 = select i1 %tst1, i64 %a, i64 %val1
410 define i64 @f_sge_i64(i64 %a, ptr %b) nounwind {
411 ; CHECK-LABEL: f_sge_i64:
412 ; CHECK: l32i a8, a4, 4
413 ; CHECK-NEXT: movi a9, 0
414 ; CHECK-NEXT: movi a10, 1
415 ; CHECK-NEXT: or a7, a10, a10
416 ; CHECK-NEXT: bge a3, a8, .LBB20_2
417 ; CHECK-NEXT: # %bb.1:
418 ; CHECK-NEXT: or a7, a9, a9
419 ; CHECK-NEXT: .LBB20_2:
420 ; CHECK-NEXT: l32i a11, a4, 0
421 ; CHECK-NEXT: bgeu a2, a11, .LBB20_4
422 ; CHECK-NEXT: # %bb.3:
423 ; CHECK-NEXT: or a10, a9, a9
424 ; CHECK-NEXT: .LBB20_4:
425 ; CHECK-NEXT: beq a3, a8, .LBB20_6
426 ; CHECK-NEXT: # %bb.5:
427 ; CHECK-NEXT: or a10, a7, a7
428 ; CHECK-NEXT: .LBB20_6:
429 ; CHECK-NEXT: bne a10, a9, .LBB20_8
430 ; CHECK-NEXT: # %bb.7:
431 ; CHECK-NEXT: or a2, a11, a11
432 ; CHECK-NEXT: .LBB20_8:
433 ; CHECK-NEXT: bne a10, a9, .LBB20_10
434 ; CHECK-NEXT: # %bb.9:
435 ; CHECK-NEXT: or a3, a8, a8
436 ; CHECK-NEXT: .LBB20_10:
438 %val1 = load i64, ptr %b
439 %tst1 = icmp sge i64 %a, %val1
440 %val2 = select i1 %tst1, i64 %a, i64 %val1
444 define i64 @f_slt_i64(i64 %a, ptr %b) nounwind {
445 ; CHECK-LABEL: f_slt_i64:
446 ; CHECK: l32i a8, a4, 4
447 ; CHECK-NEXT: movi a9, 0
448 ; CHECK-NEXT: movi a10, 1
449 ; CHECK-NEXT: or a7, a10, a10
450 ; CHECK-NEXT: blt a3, a8, .LBB21_2
451 ; CHECK-NEXT: # %bb.1:
452 ; CHECK-NEXT: or a7, a9, a9
453 ; CHECK-NEXT: .LBB21_2:
454 ; CHECK-NEXT: l32i a11, a4, 0
455 ; CHECK-NEXT: bltu a2, a11, .LBB21_4
456 ; CHECK-NEXT: # %bb.3:
457 ; CHECK-NEXT: or a10, a9, a9
458 ; CHECK-NEXT: .LBB21_4:
459 ; CHECK-NEXT: beq a3, a8, .LBB21_6
460 ; CHECK-NEXT: # %bb.5:
461 ; CHECK-NEXT: or a10, a7, a7
462 ; CHECK-NEXT: .LBB21_6:
463 ; CHECK-NEXT: bne a10, a9, .LBB21_8
464 ; CHECK-NEXT: # %bb.7:
465 ; CHECK-NEXT: or a2, a11, a11
466 ; CHECK-NEXT: .LBB21_8:
467 ; CHECK-NEXT: bne a10, a9, .LBB21_10
468 ; CHECK-NEXT: # %bb.9:
469 ; CHECK-NEXT: or a3, a8, a8
470 ; CHECK-NEXT: .LBB21_10:
472 %val1 = load i64, ptr %b
473 %tst1 = icmp slt i64 %a, %val1
474 %val2 = select i1 %tst1, i64 %a, i64 %val1
478 define i64 @f_sle_i64(i64 %a, ptr %b) nounwind {
479 ; CHECK-LABEL: f_sle_i64:
480 ; CHECK: l32i a8, a4, 4
481 ; CHECK-NEXT: movi a9, 0
482 ; CHECK-NEXT: movi a10, 1
483 ; CHECK-NEXT: or a7, a10, a10
484 ; CHECK-NEXT: bge a8, a3, .LBB22_2
485 ; CHECK-NEXT: # %bb.1:
486 ; CHECK-NEXT: or a7, a9, a9
487 ; CHECK-NEXT: .LBB22_2:
488 ; CHECK-NEXT: l32i a11, a4, 0
489 ; CHECK-NEXT: bgeu a11, a2, .LBB22_4
490 ; CHECK-NEXT: # %bb.3:
491 ; CHECK-NEXT: or a10, a9, a9
492 ; CHECK-NEXT: .LBB22_4:
493 ; CHECK-NEXT: beq a3, a8, .LBB22_6
494 ; CHECK-NEXT: # %bb.5:
495 ; CHECK-NEXT: or a10, a7, a7
496 ; CHECK-NEXT: .LBB22_6:
497 ; CHECK-NEXT: bne a10, a9, .LBB22_8
498 ; CHECK-NEXT: # %bb.7:
499 ; CHECK-NEXT: or a2, a11, a11
500 ; CHECK-NEXT: .LBB22_8:
501 ; CHECK-NEXT: bne a10, a9, .LBB22_10
502 ; CHECK-NEXT: # %bb.9:
503 ; CHECK-NEXT: or a3, a8, a8
504 ; CHECK-NEXT: .LBB22_10:
506 %val1 = load i64, ptr %b
507 %tst1 = icmp sle i64 %a, %val1
508 %val2 = select i1 %tst1, i64 %a, i64 %val1