1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=arm-- -mcpu=cortex-a8 | FileCheck %s -check-prefixes=CHECK,ARM
3 ; RUN: llc < %s -mtriple=thumb-- -mcpu=cortex-a8 | FileCheck %s -check-prefixes=CHECK,T2
6 define i32 @t1(i32 %a, i32 %b, i32 %c) nounwind {
10 ; ARM-NEXT: cmp r2, #10
11 ; ARM-NEXT: suble r0, r0, #-2147483647
17 ; T2-NEXT: mvn r1, #-2147483648
18 ; T2-NEXT: cmp r2, #10
20 ; T2-NEXT: addle r0, r1
22 %tmp1 = icmp sgt i32 %c, 10
23 %tmp2 = select i1 %tmp1, i32 0, i32 2147483647
24 %tmp3 = add i32 %tmp2, %b
28 define i32 @t2(i32 %a, i32 %b, i32 %c, i32 %d) nounwind {
31 ; ARM-NEXT: mov r0, r1
32 ; ARM-NEXT: cmp r2, #10
33 ; ARM-NEXT: suble r0, r0, #10
39 ; T2-NEXT: cmp r2, #10
41 ; T2-NEXT: suble r0, #10
43 %tmp1 = icmp sgt i32 %c, 10
44 %tmp2 = select i1 %tmp1, i32 0, i32 10
45 %tmp3 = sub i32 %b, %tmp2
49 define i32 @t3(i32 %a, i32 %b, i32 %x, i32 %y) nounwind {
52 ; ARM-NEXT: cmp r0, r1
53 ; ARM-NEXT: andge r3, r3, r2
54 ; ARM-NEXT: mov r0, r3
61 ; T2-NEXT: andge r3, r2
64 %cond = icmp slt i32 %a, %b
65 %z = select i1 %cond, i32 -1, i32 %x
70 define i32 @t4(i32 %a, i32 %b, i32 %x, i32 %y) nounwind {
73 ; ARM-NEXT: cmp r0, r1
74 ; ARM-NEXT: orrge r3, r3, r2
75 ; ARM-NEXT: mov r0, r3
82 ; T2-NEXT: orrge r3, r2
85 %cond = icmp slt i32 %a, %b
86 %z = select i1 %cond, i32 0, i32 %x
91 define i32 @t5(i32 %a, i32 %b, i32 %c) nounwind {
93 ; ARM: @ %bb.0: @ %entry
94 ; ARM-NEXT: cmp r0, r1
95 ; ARM-NEXT: orreq r2, r2, #1
96 ; ARM-NEXT: mov r0, r2
100 ; T2: @ %bb.0: @ %entry
101 ; T2-NEXT: cmp r0, r1
103 ; T2-NEXT: orreq r2, r2, #1
104 ; T2-NEXT: mov r0, r2
107 %tmp1 = icmp eq i32 %a, %b
108 %tmp2 = zext i1 %tmp1 to i32
109 %tmp3 = or i32 %tmp2, %c
113 define i32 @t6(i32 %a, i32 %b, i32 %c, i32 %d) nounwind {
116 ; ARM-NEXT: cmp r0, r1
117 ; ARM-NEXT: eorlt r3, r3, r2
118 ; ARM-NEXT: mov r0, r3
123 ; T2-NEXT: cmp r0, r1
125 ; T2-NEXT: eorlt r3, r2
126 ; T2-NEXT: mov r0, r3
128 %cond = icmp slt i32 %a, %b
129 %tmp1 = select i1 %cond, i32 %c, i32 0
130 %tmp2 = xor i32 %tmp1, %d
134 define i32 @t7(i32 %a, i32 %b, i32 %c) nounwind {
136 ; ARM: @ %bb.0: @ %entry
137 ; ARM-NEXT: cmp r0, r1
138 ; ARM-NEXT: andeq r2, r2, r2, lsl #1
139 ; ARM-NEXT: mov r0, r2
143 ; T2: @ %bb.0: @ %entry
144 ; T2-NEXT: cmp r0, r1
146 ; T2-NEXT: andeq.w r2, r2, r2, lsl #1
147 ; T2-NEXT: mov r0, r2
150 %tmp1 = shl i32 %c, 1
151 %cond = icmp eq i32 %a, %b
152 %tmp2 = select i1 %cond, i32 %tmp1, i32 -1
153 %tmp3 = and i32 %c, %tmp2
157 ; Fold ORRri into movcc.
158 define i32 @t8(i32 %a, i32 %b) nounwind {
161 ; ARM-NEXT: cmp r0, r1
162 ; ARM-NEXT: orrge r0, r1, #1
167 ; T2-NEXT: cmp r0, r1
169 ; T2-NEXT: orrge r0, r1, #1
172 %cond = icmp slt i32 %a, %b
173 %tmp1 = select i1 %cond, i32 %a, i32 %x
177 ; Fold ANDrr into movcc.
178 define i32 @t9(i32 %a, i32 %b, i32 %c) nounwind {
181 ; ARM-NEXT: cmp r0, r1
182 ; ARM-NEXT: andge r0, r1, r2
187 ; T2-NEXT: cmp r0, r1
189 ; T2-NEXT: andge.w r0, r1, r2
192 %cond = icmp slt i32 %a, %b
193 %tmp1 = select i1 %cond, i32 %a, i32 %x
197 ; Fold EORrs into movcc.
198 define i32 @t10(i32 %a, i32 %b, i32 %c, i32 %d) nounwind {
201 ; ARM-NEXT: cmp r0, r1
202 ; ARM-NEXT: eorge r0, r1, r2, lsl #7
207 ; T2-NEXT: cmp r0, r1
209 ; T2-NEXT: eorge.w r0, r1, r2, lsl #7
213 %cond = icmp slt i32 %a, %b
214 %tmp1 = select i1 %cond, i32 %a, i32 %x
218 ; Fold ORRri into movcc, reversing the condition.
219 define i32 @t11(i32 %a, i32 %b) nounwind {
222 ; ARM-NEXT: cmp r0, r1
223 ; ARM-NEXT: orrlt r0, r1, #1
228 ; T2-NEXT: cmp r0, r1
230 ; T2-NEXT: orrlt r0, r1, #1
233 %cond = icmp slt i32 %a, %b
234 %tmp1 = select i1 %cond, i32 %x, i32 %a
238 ; Fold ADDri12 into movcc
239 define i32 @t12(i32 %a, i32 %b) nounwind {
242 ; ARM-NEXT: cmp r0, r1
243 ; ARM-NEXT: movw r2, #3000
244 ; ARM-NEXT: addge r0, r1, r2
249 ; T2-NEXT: cmp r0, r1
251 ; T2-NEXT: addwge r0, r1, #3000
253 %x = add i32 %b, 3000
254 %cond = icmp slt i32 %a, %b
255 %tmp1 = select i1 %cond, i32 %a, i32 %x
259 ; Handle frame index operands.
260 define void @pr13628() nounwind uwtable align 2 {
261 ; ARM-LABEL: pr13628:
263 ; ARM-NEXT: push {r11, lr}
264 ; ARM-NEXT: sub sp, sp, #256
265 ; ARM-NEXT: ldrb r1, [r0]
266 ; ARM-NEXT: mov r0, sp
267 ; ARM-NEXT: cmp r1, #0
268 ; ARM-NEXT: moveq r0, r1
270 ; ARM-NEXT: add sp, sp, #256
271 ; ARM-NEXT: pop {r11, pc}
275 ; T2-NEXT: push {r7, lr}
276 ; T2-NEXT: sub sp, #256
277 ; T2-NEXT: ldrb r1, [r0]
278 ; T2-NEXT: mov r0, sp
279 ; T2-NEXT: cmp r1, #0
281 ; T2-NEXT: moveq r0, r1
283 ; T2-NEXT: add sp, #256
284 ; T2-NEXT: pop {r7, pc}
285 %x3 = alloca i8, i32 256, align 8
286 %x4 = load i8, ptr undef, align 1
287 %x5 = icmp ne i8 %x4, 0
288 %x6 = select i1 %x5, ptr %x3, ptr null
289 call void @bar(ptr %x6) nounwind
292 declare void @bar(ptr)
294 ; Fold zext i1 into predicated add
295 define i32 @t13(i32 %c, i32 %a) nounwind readnone ssp {
297 ; ARM: @ %bb.0: @ %entry
298 ; ARM-NEXT: cmp r1, #10
299 ; ARM-NEXT: addgt r0, r0, #1
303 ; T2: @ %bb.0: @ %entry
304 ; T2-NEXT: cmp r1, #10
306 ; T2-NEXT: addgt r0, #1
309 %cmp = icmp sgt i32 %a, 10
310 %conv = zext i1 %cmp to i32
311 %add = add i32 %conv, %c
315 ; Fold sext i1 into predicated sub
316 define i32 @t14(i32 %c, i32 %a) nounwind readnone ssp {
318 ; ARM: @ %bb.0: @ %entry
319 ; ARM-NEXT: cmp r1, #10
320 ; ARM-NEXT: subgt r0, r0, #1
324 ; T2: @ %bb.0: @ %entry
325 ; T2-NEXT: cmp r1, #10
327 ; T2-NEXT: subgt r0, #1
330 %cmp = icmp sgt i32 %a, 10
331 %conv = sext i1 %cmp to i32
332 %add = add i32 %conv, %c
336 ; Fold the xor into the select.
337 define i32 @t15(i32 %p) {
339 ; ARM: @ %bb.0: @ %entry
340 ; ARM-NEXT: mov r1, #3
341 ; ARM-NEXT: cmp r0, #8
342 ; ARM-NEXT: movwgt r1, #0
343 ; ARM-NEXT: mov r0, r1
347 ; T2: @ %bb.0: @ %entry
348 ; T2-NEXT: movs r1, #3
349 ; T2-NEXT: cmp r0, #8
351 ; T2-NEXT: movgt r1, #0
352 ; T2-NEXT: mov r0, r1
355 %cmp = icmp sgt i32 %p, 8
356 %a = select i1 %cmp, i32 1, i32 2
361 define i32 @t16(i32 %x, i32 %y) {
363 ; ARM: @ %bb.0: @ %entry
364 ; ARM-NEXT: cmp r0, #0
365 ; ARM-NEXT: mov r2, #2
366 ; ARM-NEXT: movweq r2, #5
367 ; ARM-NEXT: mov r0, #4
368 ; ARM-NEXT: cmp r1, #0
369 ; ARM-NEXT: movweq r0, #3
370 ; ARM-NEXT: and r0, r0, r2
374 ; T2: @ %bb.0: @ %entry
375 ; T2-NEXT: cmp r0, #0
376 ; T2-NEXT: mov.w r2, #2
377 ; T2-NEXT: mov.w r0, #4
379 ; T2-NEXT: moveq r2, #5
380 ; T2-NEXT: cmp r1, #0
382 ; T2-NEXT: moveq r0, #3
383 ; T2-NEXT: ands r0, r2
386 %cmp = icmp eq i32 %x, 0
387 %cond = select i1 %cmp, i32 5, i32 2
388 %cmp1 = icmp eq i32 %y, 0
389 %cond2 = select i1 %cmp1, i32 3, i32 4
390 %and = and i32 %cond2, %cond
394 define i32 @t17(i32 %x, i32 %y) #0 {
396 ; ARM: @ %bb.0: @ %entry
397 ; ARM-NEXT: cmn r0, #1
398 ; ARM-NEXT: mov r2, #2
399 ; ARM-NEXT: movweq r2, #5
400 ; ARM-NEXT: mov r0, #4
401 ; ARM-NEXT: cmn r1, #1
402 ; ARM-NEXT: movweq r0, #3
403 ; ARM-NEXT: and r0, r0, r2
407 ; T2: @ %bb.0: @ %entry
408 ; T2-NEXT: adds r0, #1
409 ; T2-NEXT: mov.w r0, #2
411 ; T2-NEXT: moveq r0, #5
412 ; T2-NEXT: adds r1, #1
413 ; T2-NEXT: mov.w r1, #4
415 ; T2-NEXT: moveq r1, #3
416 ; T2-NEXT: ands r0, r1
419 %cmp = icmp eq i32 %x, -1
420 %cond = select i1 %cmp, i32 5, i32 2
421 %cmp1 = icmp eq i32 %y, -1
422 %cond2 = select i1 %cmp1, i32 3, i32 4
423 %and = and i32 %cond2, %cond
427 define i32 @t18(i32 %x, i32 %y) #0 {
429 ; ARM: @ %bb.0: @ %entry
430 ; ARM-NEXT: mov r1, #2
431 ; ARM-NEXT: cmp r0, #0
432 ; ARM-NEXT: movwne r1, #5
433 ; ARM-NEXT: mov r2, #4
434 ; ARM-NEXT: cmn r0, #1
435 ; ARM-NEXT: movwne r2, #3
436 ; ARM-NEXT: and r0, r2, r1
440 ; T2: @ %bb.0: @ %entry
441 ; T2-NEXT: movs r1, #2
442 ; T2-NEXT: cmp r0, #0
444 ; T2-NEXT: movne r1, #5
445 ; T2-NEXT: adds r0, #1
446 ; T2-NEXT: mov.w r0, #4
448 ; T2-NEXT: movne r0, #3
449 ; T2-NEXT: ands r0, r1
452 %cmp = icmp ne i32 %x, 0
453 %cond = select i1 %cmp, i32 5, i32 2
454 %cmp1 = icmp ne i32 %x, -1
455 %cond2 = select i1 %cmp1, i32 3, i32 4
456 %and = and i32 %cond2, %cond
460 define i32 @t19(i32 %x, i32 %y) #0 {
462 ; ARM: @ %bb.0: @ %entry
463 ; ARM-NEXT: cmp r0, #0
464 ; ARM-NEXT: mov r2, #2
465 ; ARM-NEXT: movwne r2, #5
466 ; ARM-NEXT: mov r0, #4
467 ; ARM-NEXT: cmp r1, #0
468 ; ARM-NEXT: movwne r0, #3
469 ; ARM-NEXT: orr r0, r0, r2
473 ; T2: @ %bb.0: @ %entry
474 ; T2-NEXT: cmp r0, #0
475 ; T2-NEXT: mov.w r2, #2
476 ; T2-NEXT: mov.w r0, #4
478 ; T2-NEXT: movne r2, #5
479 ; T2-NEXT: cmp r1, #0
481 ; T2-NEXT: movne r0, #3
482 ; T2-NEXT: orrs r0, r2
485 %cmp = icmp ne i32 %x, 0
486 %cond = select i1 %cmp, i32 5, i32 2
487 %cmp1 = icmp ne i32 %y, 0
488 %cond2 = select i1 %cmp1, i32 3, i32 4
489 %or = or i32 %cond2, %cond
493 define i32 @t20(i32 %x, i32 %y) #0 {
495 ; ARM: @ %bb.0: @ %entry
496 ; ARM-NEXT: cmn r0, #1
497 ; ARM-NEXT: mov r2, #2
498 ; ARM-NEXT: movwne r2, #5
499 ; ARM-NEXT: mov r0, #4
500 ; ARM-NEXT: cmn r1, #1
501 ; ARM-NEXT: movwne r0, #3
502 ; ARM-NEXT: orr r0, r0, r2
506 ; T2: @ %bb.0: @ %entry
507 ; T2-NEXT: adds r0, #1
508 ; T2-NEXT: mov.w r0, #2
510 ; T2-NEXT: movne r0, #5
511 ; T2-NEXT: adds r1, #1
512 ; T2-NEXT: mov.w r1, #4
514 ; T2-NEXT: movne r1, #3
515 ; T2-NEXT: orrs r0, r1
518 %cmp = icmp ne i32 %x, -1
519 %cond = select i1 %cmp, i32 5, i32 2
520 %cmp1 = icmp ne i32 %y, -1
521 %cond2 = select i1 %cmp1, i32 3, i32 4
522 %or = or i32 %cond2, %cond
526 define <2 x i32> @t21(<2 x i32> %lhs, <2 x i32> %rhs) {
529 ; CHECK-NEXT: vmov d16, r2, r3
530 ; CHECK-NEXT: vmov d17, r0, r1
531 ; CHECK-NEXT: vceq.i32 d16, d17, d16
532 ; CHECK-NEXT: vmvn d16, d16
533 ; CHECK-NEXT: vshl.i32 d16, d16, #31
534 ; CHECK-NEXT: vshr.s32 d16, d16, #31
535 ; CHECK-NEXT: vmov r0, r1, d16
537 %tst = icmp eq <2 x i32> %lhs, %rhs
538 %ntst = xor <2 x i1> %tst, <i1 1 , i1 undef>
539 %btst = sext <2 x i1> %ntst to <2 x i32>