1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=x86_64-linux-gnu -run-pass=legalizer %s -o - | FileCheck %s
6 define zeroext i1 @test_i1(i32 %a, i1 zeroext %f, i1 zeroext %t) {
8 %cmp = icmp sgt i32 %a, 0
9 br i1 %cmp, label %cond.true, label %cond.false
11 cond.true: ; preds = %entry
14 cond.false: ; preds = %entry
17 cond.end: ; preds = %cond.false, %cond.true
18 %cond = phi i1 [ %f, %cond.true ], [ %t, %cond.false ]
22 define i8 @test_i8(i32 %a, i8 %f, i8 %t) {
24 %cmp = icmp sgt i32 %a, 0
25 br i1 %cmp, label %cond.true, label %cond.false
27 cond.true: ; preds = %entry
30 cond.false: ; preds = %entry
33 cond.end: ; preds = %cond.false, %cond.true
34 %cond = phi i8 [ %f, %cond.true ], [ %t, %cond.false ]
38 define i16 @test_i16(i32 %a, i16 %f, i16 %t) {
40 %cmp = icmp sgt i32 %a, 0
41 br i1 %cmp, label %cond.true, label %cond.false
43 cond.true: ; preds = %entry
46 cond.false: ; preds = %entry
49 cond.end: ; preds = %cond.false, %cond.true
50 %cond = phi i16 [ %f, %cond.true ], [ %t, %cond.false ]
54 define i32 @test_i32(i32 %a, i32 %f, i32 %t) {
56 %cmp = icmp sgt i32 %a, 0
57 br i1 %cmp, label %cond.true, label %cond.false
59 cond.true: ; preds = %entry
62 cond.false: ; preds = %entry
65 cond.end: ; preds = %cond.false, %cond.true
66 %cond = phi i32 [ %f, %cond.true ], [ %t, %cond.false ]
70 define i64 @test_i64(i32 %a, i64 %f, i64 %t) {
72 %cmp = icmp sgt i32 %a, 0
73 br i1 %cmp, label %cond.true, label %cond.false
75 cond.true: ; preds = %entry
78 cond.false: ; preds = %entry
81 cond.end: ; preds = %cond.false, %cond.true
82 %cond = phi i64 [ %f, %cond.true ], [ %t, %cond.false ]
86 define float @test_float(i32 %a, float %f, float %t) {
88 %cmp = icmp sgt i32 %a, 0
89 br i1 %cmp, label %cond.true, label %cond.false
91 cond.true: ; preds = %entry
94 cond.false: ; preds = %entry
97 cond.end: ; preds = %cond.false, %cond.true
98 %cond = phi float [ %f, %cond.true ], [ %t, %cond.false ]
102 define double @test_double(i32 %a, double %f, double %t) {
104 %cmp = icmp sgt i32 %a, 0
105 br i1 %cmp, label %cond.true, label %cond.false
107 cond.true: ; preds = %entry
110 cond.false: ; preds = %entry
113 cond.end: ; preds = %cond.false, %cond.true
114 %cond = phi double [ %f, %cond.true ], [ %t, %cond.false ]
123 regBankSelected: false
124 tracksRegLiveness: true
126 - { id: 0, class: _, preferred-register: '' }
127 - { id: 1, class: _, preferred-register: '' }
128 - { id: 2, class: _, preferred-register: '' }
129 - { id: 3, class: _, preferred-register: '' }
130 - { id: 4, class: _, preferred-register: '' }
131 - { id: 5, class: _, preferred-register: '' }
132 - { id: 6, class: _, preferred-register: '' }
133 - { id: 7, class: _, preferred-register: '' }
134 - { id: 8, class: _, preferred-register: '' }
144 ; CHECK-LABEL: name: test_i1
146 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
147 ; CHECK-NEXT: liveins: $edi, $edx, $esi
149 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $edi
150 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $esi
151 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $edx
152 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
153 ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s8) = G_ICMP intpred(sgt), [[COPY]](s32), [[C]]
154 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s8)
155 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[COPY1]](s32)
156 ; CHECK-NEXT: G_BRCOND [[TRUNC]](s1), %bb.2
158 ; CHECK-NEXT: bb.1.cond.false:
159 ; CHECK-NEXT: successors: %bb.2(0x80000000)
161 ; CHECK-NEXT: [[TRUNC2:%[0-9]+]]:_(s8) = G_TRUNC [[COPY2]](s32)
163 ; CHECK-NEXT: bb.2.cond.end:
164 ; CHECK-NEXT: [[PHI:%[0-9]+]]:_(s8) = G_PHI [[TRUNC2]](s8), %bb.1, [[TRUNC1]](s8), %bb.0
165 ; CHECK-NEXT: $al = COPY [[PHI]](s8)
166 ; CHECK-NEXT: RET 0, implicit $al
168 successors: %bb.3(0x40000000), %bb.2(0x40000000)
169 liveins: $edi, $edx, $esi
171 %0:_(s32) = COPY $edi
172 %3:_(s32) = COPY $esi
173 %1:_(s1) = G_TRUNC %3(s32)
174 %4:_(s32) = COPY $edx
175 %2:_(s1) = G_TRUNC %4(s32)
176 %5:_(s32) = G_CONSTANT i32 0
177 %6:_(s1) = G_ICMP intpred(sgt), %0(s32), %5
178 G_BRCOND %6(s1), %bb.3
181 successors: %bb.3(0x80000000)
185 %7:_(s1) = G_PHI %2(s1), %bb.2, %1(s1), %bb.1
186 %8:_(s8) = G_ANYEXT %7(s1)
195 regBankSelected: false
196 tracksRegLiveness: true
198 - { id: 0, class: _, preferred-register: '' }
199 - { id: 1, class: _, preferred-register: '' }
200 - { id: 2, class: _, preferred-register: '' }
201 - { id: 3, class: _, preferred-register: '' }
202 - { id: 4, class: _, preferred-register: '' }
203 - { id: 5, class: _, preferred-register: '' }
204 - { id: 6, class: _, preferred-register: '' }
205 - { id: 7, class: _, preferred-register: '' }
214 ; CHECK-LABEL: name: test_i8
216 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
217 ; CHECK-NEXT: liveins: $edi, $edx, $esi
219 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $edi
220 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $esi
221 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[COPY1]](s32)
222 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $edx
223 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[COPY2]](s32)
224 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
225 ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s8) = G_ICMP intpred(sgt), [[COPY]](s32), [[C]]
226 ; CHECK-NEXT: [[TRUNC2:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s8)
227 ; CHECK-NEXT: G_BRCOND [[TRUNC2]](s1), %bb.2
229 ; CHECK-NEXT: bb.1.cond.false:
230 ; CHECK-NEXT: successors: %bb.2(0x80000000)
232 ; CHECK-NEXT: bb.2.cond.end:
233 ; CHECK-NEXT: [[PHI:%[0-9]+]]:_(s8) = G_PHI [[TRUNC1]](s8), %bb.1, [[TRUNC]](s8), %bb.0
234 ; CHECK-NEXT: $al = COPY [[PHI]](s8)
235 ; CHECK-NEXT: RET 0, implicit $al
237 successors: %bb.3(0x40000000), %bb.2(0x40000000)
238 liveins: $edi, $edx, $esi
240 %0:_(s32) = COPY $edi
241 %3:_(s32) = COPY $esi
242 %1:_(s8) = G_TRUNC %3(s32)
243 %4:_(s32) = COPY $edx
244 %2:_(s8) = G_TRUNC %4(s32)
245 %5:_(s32) = G_CONSTANT i32 0
246 %6:_(s1) = G_ICMP intpred(sgt), %0(s32), %5
247 G_BRCOND %6(s1), %bb.3
250 successors: %bb.3(0x80000000)
254 %7:_(s8) = G_PHI %2(s8), %bb.2, %1(s8), %bb.1
263 regBankSelected: false
264 tracksRegLiveness: true
266 - { id: 0, class: _, preferred-register: '' }
267 - { id: 1, class: _, preferred-register: '' }
268 - { id: 2, class: _, preferred-register: '' }
269 - { id: 3, class: _, preferred-register: '' }
270 - { id: 4, class: _, preferred-register: '' }
271 - { id: 5, class: _, preferred-register: '' }
272 - { id: 6, class: _, preferred-register: '' }
273 - { id: 7, class: _, preferred-register: '' }
282 ; CHECK-LABEL: name: test_i16
284 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
285 ; CHECK-NEXT: liveins: $edi, $edx, $esi
287 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $edi
288 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $esi
289 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY1]](s32)
290 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $edx
291 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[COPY2]](s32)
292 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
293 ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s8) = G_ICMP intpred(sgt), [[COPY]](s32), [[C]]
294 ; CHECK-NEXT: [[TRUNC2:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s8)
295 ; CHECK-NEXT: G_BRCOND [[TRUNC2]](s1), %bb.2
297 ; CHECK-NEXT: bb.1.cond.false:
298 ; CHECK-NEXT: successors: %bb.2(0x80000000)
300 ; CHECK-NEXT: bb.2.cond.end:
301 ; CHECK-NEXT: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC1]](s16), %bb.1, [[TRUNC]](s16), %bb.0
302 ; CHECK-NEXT: $ax = COPY [[PHI]](s16)
303 ; CHECK-NEXT: RET 0, implicit $ax
305 successors: %bb.3(0x40000000), %bb.2(0x40000000)
306 liveins: $edi, $edx, $esi
308 %0:_(s32) = COPY $edi
309 %3:_(s32) = COPY $esi
310 %1:_(s16) = G_TRUNC %3(s32)
311 %4:_(s32) = COPY $edx
312 %2:_(s16) = G_TRUNC %4(s32)
313 %5:_(s32) = G_CONSTANT i32 0
314 %6:_(s1) = G_ICMP intpred(sgt), %0(s32), %5
315 G_BRCOND %6(s1), %bb.3
318 successors: %bb.3(0x80000000)
322 %7:_(s16) = G_PHI %2(s16), %bb.2, %1(s16), %bb.1
331 regBankSelected: false
332 tracksRegLiveness: true
334 - { id: 0, class: _, preferred-register: '' }
335 - { id: 1, class: _, preferred-register: '' }
336 - { id: 2, class: _, preferred-register: '' }
337 - { id: 3, class: _, preferred-register: '' }
338 - { id: 4, class: _, preferred-register: '' }
339 - { id: 5, class: _, preferred-register: '' }
348 ; CHECK-LABEL: name: test_i32
350 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
351 ; CHECK-NEXT: liveins: $edi, $edx, $esi
353 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $edi
354 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $esi
355 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $edx
356 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
357 ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s8) = G_ICMP intpred(sgt), [[COPY]](s32), [[C]]
358 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s8)
359 ; CHECK-NEXT: G_BRCOND [[TRUNC]](s1), %bb.1
360 ; CHECK-NEXT: G_BR %bb.2
362 ; CHECK-NEXT: bb.1.cond.true:
363 ; CHECK-NEXT: successors: %bb.3(0x80000000)
365 ; CHECK-NEXT: G_BR %bb.3
367 ; CHECK-NEXT: bb.2.cond.false:
368 ; CHECK-NEXT: successors: %bb.3(0x80000000)
370 ; CHECK-NEXT: bb.3.cond.end:
371 ; CHECK-NEXT: [[PHI:%[0-9]+]]:_(s32) = G_PHI [[COPY1]](s32), %bb.1, [[COPY2]](s32), %bb.2
372 ; CHECK-NEXT: $eax = COPY [[PHI]](s32)
373 ; CHECK-NEXT: RET 0, implicit $eax
375 successors: %bb.2(0x40000000), %bb.3(0x40000000)
376 liveins: $edi, $edx, $esi
381 %3(s32) = G_CONSTANT i32 0
382 %4(s1) = G_ICMP intpred(sgt), %0(s32), %3
383 G_BRCOND %4(s1), %bb.2
387 successors: %bb.4(0x80000000)
392 successors: %bb.4(0x80000000)
396 %5(s32) = G_PHI %1(s32), %bb.2, %2(s32), %bb.3
405 regBankSelected: false
406 tracksRegLiveness: true
408 - { id: 0, class: _, preferred-register: '' }
409 - { id: 1, class: _, preferred-register: '' }
410 - { id: 2, class: _, preferred-register: '' }
411 - { id: 3, class: _, preferred-register: '' }
412 - { id: 4, class: _, preferred-register: '' }
413 - { id: 5, class: _, preferred-register: '' }
422 ; CHECK-LABEL: name: test_i64
424 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
425 ; CHECK-NEXT: liveins: $edi, $rdx, $rsi
427 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $edi
428 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $rsi
429 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $rdx
430 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
431 ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s8) = G_ICMP intpred(sgt), [[COPY]](s32), [[C]]
432 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s8)
433 ; CHECK-NEXT: G_BRCOND [[TRUNC]](s1), %bb.1
434 ; CHECK-NEXT: G_BR %bb.2
436 ; CHECK-NEXT: bb.1.cond.true:
437 ; CHECK-NEXT: successors: %bb.3(0x80000000)
439 ; CHECK-NEXT: G_BR %bb.3
441 ; CHECK-NEXT: bb.2.cond.false:
442 ; CHECK-NEXT: successors: %bb.3(0x80000000)
444 ; CHECK-NEXT: bb.3.cond.end:
445 ; CHECK-NEXT: [[PHI:%[0-9]+]]:_(s64) = G_PHI [[COPY1]](s64), %bb.1, [[COPY2]](s64), %bb.2
446 ; CHECK-NEXT: $rax = COPY [[PHI]](s64)
447 ; CHECK-NEXT: RET 0, implicit $rax
449 successors: %bb.2(0x40000000), %bb.3(0x40000000)
450 liveins: $edi, $rdx, $rsi
455 %3(s32) = G_CONSTANT i32 0
456 %4(s1) = G_ICMP intpred(sgt), %0(s32), %3
457 G_BRCOND %4(s1), %bb.2
461 successors: %bb.4(0x80000000)
466 successors: %bb.4(0x80000000)
470 %5(s64) = G_PHI %1(s64), %bb.2, %2(s64), %bb.3
479 regBankSelected: false
480 tracksRegLiveness: true
482 - { id: 0, class: _, preferred-register: '' }
483 - { id: 1, class: _, preferred-register: '' }
484 - { id: 2, class: _, preferred-register: '' }
485 - { id: 3, class: _, preferred-register: '' }
486 - { id: 4, class: _, preferred-register: '' }
487 - { id: 5, class: _, preferred-register: '' }
488 - { id: 6, class: _, preferred-register: '' }
489 - { id: 7, class: _, preferred-register: '' }
490 - { id: 8, class: _, preferred-register: '' }
499 ; CHECK-LABEL: name: test_float
501 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
502 ; CHECK-NEXT: liveins: $edi, $xmm0, $xmm1
504 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $edi
505 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s128) = COPY $xmm0
506 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s128)
507 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s128) = COPY $xmm1
508 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY2]](s128)
509 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
510 ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s8) = G_ICMP intpred(sgt), [[COPY]](s32), [[C]]
511 ; CHECK-NEXT: [[TRUNC2:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s8)
512 ; CHECK-NEXT: G_BRCOND [[TRUNC2]](s1), %bb.2
514 ; CHECK-NEXT: bb.1.cond.false:
515 ; CHECK-NEXT: successors: %bb.2(0x80000000)
517 ; CHECK-NEXT: bb.2.cond.end:
518 ; CHECK-NEXT: [[PHI:%[0-9]+]]:_(s32) = G_PHI [[TRUNC1]](s32), %bb.1, [[TRUNC]](s32), %bb.0
519 ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s128) = G_ANYEXT [[PHI]](s32)
520 ; CHECK-NEXT: $xmm0 = COPY [[ANYEXT]](s128)
521 ; CHECK-NEXT: RET 0, implicit $xmm0
523 successors: %bb.3(0x40000000), %bb.2(0x40000000)
524 liveins: $edi, $xmm0, $xmm1
526 %0:_(s32) = COPY $edi
527 %3:_(s128) = COPY $xmm0
528 %1:_(s32) = G_TRUNC %3(s128)
529 %4:_(s128) = COPY $xmm1
530 %2:_(s32) = G_TRUNC %4(s128)
531 %5:_(s32) = G_CONSTANT i32 0
532 %6:_(s1) = G_ICMP intpred(sgt), %0(s32), %5
533 G_BRCOND %6(s1), %bb.3
536 successors: %bb.3(0x80000000)
540 %7:_(s32) = G_PHI %2(s32), %bb.2, %1(s32), %bb.1
541 %8:_(s128) = G_ANYEXT %7(s32)
542 $xmm0 = COPY %8(s128)
543 RET 0, implicit $xmm0
550 regBankSelected: false
551 tracksRegLiveness: true
553 - { id: 0, class: _, preferred-register: '' }
554 - { id: 1, class: _, preferred-register: '' }
555 - { id: 2, class: _, preferred-register: '' }
556 - { id: 3, class: _, preferred-register: '' }
557 - { id: 4, class: _, preferred-register: '' }
558 - { id: 5, class: _, preferred-register: '' }
559 - { id: 6, class: _, preferred-register: '' }
560 - { id: 7, class: _, preferred-register: '' }
561 - { id: 8, class: _, preferred-register: '' }
570 ; CHECK-LABEL: name: test_double
572 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
573 ; CHECK-NEXT: liveins: $edi, $xmm0, $xmm1
575 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $edi
576 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s128) = COPY $xmm0
577 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s64) = G_TRUNC [[COPY1]](s128)
578 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s128) = COPY $xmm1
579 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s64) = G_TRUNC [[COPY2]](s128)
580 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
581 ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s8) = G_ICMP intpred(sgt), [[COPY]](s32), [[C]]
582 ; CHECK-NEXT: [[TRUNC2:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s8)
583 ; CHECK-NEXT: G_BRCOND [[TRUNC2]](s1), %bb.2
585 ; CHECK-NEXT: bb.1.cond.false:
586 ; CHECK-NEXT: successors: %bb.2(0x80000000)
588 ; CHECK-NEXT: bb.2.cond.end:
589 ; CHECK-NEXT: [[PHI:%[0-9]+]]:_(s64) = G_PHI [[TRUNC1]](s64), %bb.1, [[TRUNC]](s64), %bb.0
590 ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s128) = G_ANYEXT [[PHI]](s64)
591 ; CHECK-NEXT: $xmm0 = COPY [[ANYEXT]](s128)
592 ; CHECK-NEXT: RET 0, implicit $xmm0
594 successors: %bb.3(0x40000000), %bb.2(0x40000000)
595 liveins: $edi, $xmm0, $xmm1
597 %0:_(s32) = COPY $edi
598 %3:_(s128) = COPY $xmm0
599 %1:_(s64) = G_TRUNC %3(s128)
600 %4:_(s128) = COPY $xmm1
601 %2:_(s64) = G_TRUNC %4(s128)
602 %5:_(s32) = G_CONSTANT i32 0
603 %6:_(s1) = G_ICMP intpred(sgt), %0(s32), %5
604 G_BRCOND %6(s1), %bb.3
607 successors: %bb.3(0x80000000)
611 %7:_(s64) = G_PHI %2(s64), %bb.2, %1(s64), %bb.1
612 %8:_(s128) = G_ANYEXT %7(s64)
613 $xmm0 = COPY %8(s128)
614 RET 0, implicit $xmm0