1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=x86_64-linux-gnu -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=ALL
6 define i8 @test_i8(i32 %a, i8 %f, i8 %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 i8 [ %f, %cond.true ], [ %t, %cond.false ]
22 define i16 @test_i16(i32 %a, i16 %f, i16 %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 i16 [ %f, %cond.true ], [ %t, %cond.false ]
38 define i32 @test_i32(i32 %a, i32 %f, i32 %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 i32 [ %f, %cond.true ], [ %t, %cond.false ]
54 define i64 @test_i64(i32 %a, i64 %f, i64 %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 i64 [ %f, %cond.true ], [ %t, %cond.false ]
70 define float @test_float(i32 %a, float %f, float %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 float [ %f, %cond.true ], [ %t, %cond.false ]
86 define double @test_double(i32 %a, double %f, double %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 double [ %f, %cond.true ], [ %t, %cond.false ]
107 regBankSelected: true
108 tracksRegLiveness: true
110 - { id: 0, class: gpr, preferred-register: '' }
111 - { id: 1, class: gpr, preferred-register: '' }
112 - { id: 2, class: gpr, preferred-register: '' }
113 - { id: 3, class: gpr, preferred-register: '' }
114 - { id: 4, class: gpr, preferred-register: '' }
115 - { id: 5, class: gpr, preferred-register: '' }
116 - { id: 6, class: gpr, preferred-register: '' }
117 - { id: 7, class: gpr, preferred-register: '' }
119 ; ALL-LABEL: name: test_i8
121 ; ALL: successors: %bb.2(0x40000000), %bb.1(0x40000000)
122 ; ALL: liveins: $edi, $edx, $esi
123 ; ALL: [[COPY:%[0-9]+]]:gr32 = COPY $edi
124 ; ALL: [[COPY1:%[0-9]+]]:gr32 = COPY $esi
125 ; ALL: [[COPY2:%[0-9]+]]:gr8 = COPY [[COPY1]].sub_8bit
126 ; ALL: [[COPY3:%[0-9]+]]:gr32 = COPY $edx
127 ; ALL: [[COPY4:%[0-9]+]]:gr8 = COPY [[COPY3]].sub_8bit
128 ; ALL: [[MOV32r0_:%[0-9]+]]:gr32 = MOV32r0 implicit-def $eflags
129 ; ALL: CMP32rr [[COPY]], [[MOV32r0_]], implicit-def $eflags
130 ; ALL: [[SETCCr:%[0-9]+]]:gr8 = SETCCr 15, implicit $eflags
131 ; ALL: TEST8ri [[SETCCr]], 1, implicit-def $eflags
132 ; ALL: JCC_1 %bb.2, 5, implicit $eflags
133 ; ALL: bb.1.cond.false:
134 ; ALL: successors: %bb.2(0x80000000)
135 ; ALL: bb.2.cond.end:
136 ; ALL: [[PHI:%[0-9]+]]:gr8 = PHI [[COPY4]], %bb.1, [[COPY2]], %bb.0
137 ; ALL: $al = COPY [[PHI]]
138 ; ALL: RET 0, implicit $al
140 successors: %bb.3(0x40000000), %bb.2(0x40000000)
141 liveins: $edi, $edx, $esi
143 %0:gpr(s32) = COPY $edi
144 %3:gpr(s32) = COPY $esi
145 %1:gpr(s8) = G_TRUNC %3(s32)
146 %4:gpr(s32) = COPY $edx
147 %2:gpr(s8) = G_TRUNC %4(s32)
148 %5:gpr(s32) = G_CONSTANT i32 0
149 %6:gpr(s1) = G_ICMP intpred(sgt), %0(s32), %5
150 G_BRCOND %6(s1), %bb.3
153 successors: %bb.3(0x80000000)
157 %7:gpr(s8) = G_PHI %2(s8), %bb.2, %1(s8), %bb.1
166 regBankSelected: true
167 tracksRegLiveness: true
169 - { id: 0, class: gpr, preferred-register: '' }
170 - { id: 1, class: gpr, preferred-register: '' }
171 - { id: 2, class: gpr, preferred-register: '' }
172 - { id: 3, class: gpr, preferred-register: '' }
173 - { id: 4, class: gpr, preferred-register: '' }
174 - { id: 5, class: gpr, preferred-register: '' }
175 - { id: 6, class: gpr, preferred-register: '' }
176 - { id: 7, class: gpr, preferred-register: '' }
178 ; ALL-LABEL: name: test_i16
180 ; ALL: successors: %bb.2(0x40000000), %bb.1(0x40000000)
181 ; ALL: liveins: $edi, $edx, $esi
182 ; ALL: [[COPY:%[0-9]+]]:gr32 = COPY $edi
183 ; ALL: [[COPY1:%[0-9]+]]:gr32 = COPY $esi
184 ; ALL: [[COPY2:%[0-9]+]]:gr16 = COPY [[COPY1]].sub_16bit
185 ; ALL: [[COPY3:%[0-9]+]]:gr32 = COPY $edx
186 ; ALL: [[COPY4:%[0-9]+]]:gr16 = COPY [[COPY3]].sub_16bit
187 ; ALL: [[MOV32r0_:%[0-9]+]]:gr32 = MOV32r0 implicit-def $eflags
188 ; ALL: CMP32rr [[COPY]], [[MOV32r0_]], implicit-def $eflags
189 ; ALL: [[SETCCr:%[0-9]+]]:gr8 = SETCCr 15, implicit $eflags
190 ; ALL: TEST8ri [[SETCCr]], 1, implicit-def $eflags
191 ; ALL: JCC_1 %bb.2, 5, implicit $eflags
192 ; ALL: bb.1.cond.false:
193 ; ALL: successors: %bb.2(0x80000000)
194 ; ALL: bb.2.cond.end:
195 ; ALL: [[PHI:%[0-9]+]]:gr16 = PHI [[COPY4]], %bb.1, [[COPY2]], %bb.0
196 ; ALL: $ax = COPY [[PHI]]
197 ; ALL: RET 0, implicit $ax
199 successors: %bb.3(0x40000000), %bb.2(0x40000000)
200 liveins: $edi, $edx, $esi
202 %0:gpr(s32) = COPY $edi
203 %3:gpr(s32) = COPY $esi
204 %1:gpr(s16) = G_TRUNC %3(s32)
205 %4:gpr(s32) = COPY $edx
206 %2:gpr(s16) = G_TRUNC %4(s32)
207 %5:gpr(s32) = G_CONSTANT i32 0
208 %6:gpr(s1) = G_ICMP intpred(sgt), %0(s32), %5
209 G_BRCOND %6(s1), %bb.3
212 successors: %bb.3(0x80000000)
216 %7:gpr(s16) = G_PHI %2(s16), %bb.2, %1(s16), %bb.1
225 regBankSelected: true
226 tracksRegLiveness: true
228 - { id: 0, class: gpr, preferred-register: '' }
229 - { id: 1, class: gpr, preferred-register: '' }
230 - { id: 2, class: gpr, preferred-register: '' }
231 - { id: 3, class: gpr, preferred-register: '' }
232 - { id: 4, class: gpr, preferred-register: '' }
233 - { id: 5, class: gpr, preferred-register: '' }
235 ; ALL-LABEL: name: test_i32
237 ; ALL: successors: %bb.1(0x40000000), %bb.2(0x40000000)
238 ; ALL: liveins: $edi, $edx, $esi
239 ; ALL: [[COPY:%[0-9]+]]:gr32 = COPY $edi
240 ; ALL: [[COPY1:%[0-9]+]]:gr32 = COPY $esi
241 ; ALL: [[COPY2:%[0-9]+]]:gr32 = COPY $edx
242 ; ALL: [[MOV32r0_:%[0-9]+]]:gr32 = MOV32r0 implicit-def $eflags
243 ; ALL: CMP32rr [[COPY]], [[MOV32r0_]], implicit-def $eflags
244 ; ALL: [[SETCCr:%[0-9]+]]:gr8 = SETCCr 15, implicit $eflags
245 ; ALL: TEST8ri [[SETCCr]], 1, implicit-def $eflags
246 ; ALL: JCC_1 %bb.1, 5, implicit $eflags
248 ; ALL: bb.1.cond.true:
249 ; ALL: successors: %bb.3(0x80000000)
251 ; ALL: bb.2.cond.false:
252 ; ALL: successors: %bb.3(0x80000000)
253 ; ALL: bb.3.cond.end:
254 ; ALL: [[PHI:%[0-9]+]]:gr32 = PHI [[COPY1]], %bb.1, [[COPY2]], %bb.2
255 ; ALL: $eax = COPY [[PHI]]
256 ; ALL: RET 0, implicit $eax
258 successors: %bb.2(0x40000000), %bb.3(0x40000000)
259 liveins: $edi, $edx, $esi
264 %3(s32) = G_CONSTANT i32 0
265 %4(s1) = G_ICMP intpred(sgt), %0(s32), %3
266 G_BRCOND %4(s1), %bb.2
270 successors: %bb.4(0x80000000)
275 successors: %bb.4(0x80000000)
279 %5(s32) = G_PHI %1(s32), %bb.2, %2(s32), %bb.3
288 regBankSelected: true
289 tracksRegLiveness: true
291 - { id: 0, class: gpr, preferred-register: '' }
292 - { id: 1, class: gpr, preferred-register: '' }
293 - { id: 2, class: gpr, preferred-register: '' }
294 - { id: 3, class: gpr, preferred-register: '' }
295 - { id: 4, class: gpr, preferred-register: '' }
296 - { id: 5, class: gpr, preferred-register: '' }
298 ; ALL-LABEL: name: test_i64
300 ; ALL: successors: %bb.1(0x40000000), %bb.2(0x40000000)
301 ; ALL: liveins: $edi, $rdx, $rsi
302 ; ALL: [[COPY:%[0-9]+]]:gr32 = COPY $edi
303 ; ALL: [[COPY1:%[0-9]+]]:gr64 = COPY $rsi
304 ; ALL: [[COPY2:%[0-9]+]]:gr64 = COPY $rdx
305 ; ALL: [[MOV32r0_:%[0-9]+]]:gr32 = MOV32r0 implicit-def $eflags
306 ; ALL: CMP32rr [[COPY]], [[MOV32r0_]], implicit-def $eflags
307 ; ALL: [[SETCCr:%[0-9]+]]:gr8 = SETCCr 15, implicit $eflags
308 ; ALL: TEST8ri [[SETCCr]], 1, implicit-def $eflags
309 ; ALL: JCC_1 %bb.1, 5, implicit $eflags
311 ; ALL: bb.1.cond.true:
312 ; ALL: successors: %bb.3(0x80000000)
314 ; ALL: bb.2.cond.false:
315 ; ALL: successors: %bb.3(0x80000000)
316 ; ALL: bb.3.cond.end:
317 ; ALL: [[PHI:%[0-9]+]]:gr64 = PHI [[COPY1]], %bb.1, [[COPY2]], %bb.2
318 ; ALL: $rax = COPY [[PHI]]
319 ; ALL: RET 0, implicit $rax
321 successors: %bb.2(0x40000000), %bb.3(0x40000000)
322 liveins: $edi, $rdx, $rsi
327 %3(s32) = G_CONSTANT i32 0
328 %4(s1) = G_ICMP intpred(sgt), %0(s32), %3
329 G_BRCOND %4(s1), %bb.2
333 successors: %bb.4(0x80000000)
338 successors: %bb.4(0x80000000)
342 %5(s64) = G_PHI %1(s64), %bb.2, %2(s64), %bb.3
351 regBankSelected: true
352 tracksRegLiveness: true
354 - { id: 0, class: gpr, preferred-register: '' }
355 - { id: 1, class: vecr, preferred-register: '' }
356 - { id: 2, class: vecr, preferred-register: '' }
357 - { id: 3, class: vecr, preferred-register: '' }
358 - { id: 4, class: vecr, preferred-register: '' }
359 - { id: 5, class: gpr, preferred-register: '' }
360 - { id: 6, class: gpr, preferred-register: '' }
361 - { id: 7, class: vecr, preferred-register: '' }
362 - { id: 8, class: vecr, preferred-register: '' }
368 ; ALL-LABEL: name: test_float
370 ; ALL: successors: %bb.2(0x40000000), %bb.1(0x40000000)
371 ; ALL: liveins: $edi, $xmm0, $xmm1
372 ; ALL: [[COPY:%[0-9]+]]:gr32 = COPY $edi
373 ; ALL: [[COPY1:%[0-9]+]]:vr128 = COPY $xmm0
374 ; ALL: [[COPY2:%[0-9]+]]:fr32 = COPY [[COPY1]]
375 ; ALL: [[COPY3:%[0-9]+]]:vr128 = COPY $xmm1
376 ; ALL: [[COPY4:%[0-9]+]]:fr32 = COPY [[COPY3]]
377 ; ALL: [[MOV32r0_:%[0-9]+]]:gr32 = MOV32r0 implicit-def $eflags
378 ; ALL: CMP32rr [[COPY]], [[MOV32r0_]], implicit-def $eflags
379 ; ALL: [[SETCCr:%[0-9]+]]:gr8 = SETCCr 15, implicit $eflags
380 ; ALL: TEST8ri [[SETCCr]], 1, implicit-def $eflags
381 ; ALL: JCC_1 %bb.2, 5, implicit $eflags
382 ; ALL: bb.1.cond.false:
383 ; ALL: successors: %bb.2(0x80000000)
384 ; ALL: bb.2.cond.end:
385 ; ALL: [[PHI:%[0-9]+]]:fr32 = PHI [[COPY4]], %bb.1, [[COPY2]], %bb.0
386 ; ALL: [[COPY5:%[0-9]+]]:vr128 = COPY [[PHI]]
387 ; ALL: $xmm0 = COPY [[COPY5]]
388 ; ALL: RET 0, implicit $xmm0
390 successors: %bb.3(0x40000000), %bb.2(0x40000000)
391 liveins: $edi, $xmm0, $xmm1
393 %0:gpr(s32) = COPY $edi
394 %3:vecr(s128) = COPY $xmm0
395 %1:vecr(s32) = G_TRUNC %3(s128)
396 %4:vecr(s128) = COPY $xmm1
397 %2:vecr(s32) = G_TRUNC %4(s128)
398 %5:gpr(s32) = G_CONSTANT i32 0
399 %6:gpr(s1) = G_ICMP intpred(sgt), %0(s32), %5
400 G_BRCOND %6(s1), %bb.3
403 successors: %bb.3(0x80000000)
406 %7:vecr(s32) = G_PHI %2(s32), %bb.2, %1(s32), %bb.1
407 %8:vecr(s128) = G_ANYEXT %7(s32)
408 $xmm0 = COPY %8(s128)
409 RET 0, implicit $xmm0
416 regBankSelected: true
417 tracksRegLiveness: true
419 - { id: 0, class: gpr, preferred-register: '' }
420 - { id: 1, class: vecr, preferred-register: '' }
421 - { id: 2, class: vecr, preferred-register: '' }
422 - { id: 3, class: vecr, preferred-register: '' }
423 - { id: 4, class: vecr, preferred-register: '' }
424 - { id: 5, class: gpr, preferred-register: '' }
425 - { id: 6, class: gpr, preferred-register: '' }
426 - { id: 7, class: vecr, preferred-register: '' }
427 - { id: 8, class: vecr, preferred-register: '' }
429 ; ALL-LABEL: name: test_double
431 ; ALL: successors: %bb.2(0x40000000), %bb.1(0x40000000)
432 ; ALL: liveins: $edi, $xmm0, $xmm1
433 ; ALL: [[COPY:%[0-9]+]]:gr32 = COPY $edi
434 ; ALL: [[COPY1:%[0-9]+]]:vr128 = COPY $xmm0
435 ; ALL: [[COPY2:%[0-9]+]]:fr64 = COPY [[COPY1]]
436 ; ALL: [[COPY3:%[0-9]+]]:vr128 = COPY $xmm1
437 ; ALL: [[COPY4:%[0-9]+]]:fr64 = COPY [[COPY3]]
438 ; ALL: [[MOV32r0_:%[0-9]+]]:gr32 = MOV32r0 implicit-def $eflags
439 ; ALL: CMP32rr [[COPY]], [[MOV32r0_]], implicit-def $eflags
440 ; ALL: [[SETCCr:%[0-9]+]]:gr8 = SETCCr 15, implicit $eflags
441 ; ALL: TEST8ri [[SETCCr]], 1, implicit-def $eflags
442 ; ALL: JCC_1 %bb.2, 5, implicit $eflags
443 ; ALL: bb.1.cond.false:
444 ; ALL: successors: %bb.2(0x80000000)
445 ; ALL: bb.2.cond.end:
446 ; ALL: [[PHI:%[0-9]+]]:fr64 = PHI [[COPY4]], %bb.1, [[COPY2]], %bb.0
447 ; ALL: [[COPY5:%[0-9]+]]:vr128 = COPY [[PHI]]
448 ; ALL: $xmm0 = COPY [[COPY5]]
449 ; ALL: RET 0, implicit $xmm0
451 successors: %bb.3(0x40000000), %bb.2(0x40000000)
452 liveins: $edi, $xmm0, $xmm1
454 %0:gpr(s32) = COPY $edi
455 %3:vecr(s128) = COPY $xmm0
456 %1:vecr(s64) = G_TRUNC %3(s128)
457 %4:vecr(s128) = COPY $xmm1
458 %2:vecr(s64) = G_TRUNC %4(s128)
459 %5:gpr(s32) = G_CONSTANT i32 0
460 %6:gpr(s1) = G_ICMP intpred(sgt), %0(s32), %5
461 G_BRCOND %6(s1), %bb.3
464 successors: %bb.3(0x80000000)
467 %7:vecr(s64) = G_PHI %2(s64), %bb.2, %1(s64), %bb.1
468 %8:vecr(s128) = G_ANYEXT %7(s64)
469 $xmm0 = COPY %8(s128)
470 RET 0, implicit $xmm0