1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -verify-regalloc -start-before=machine-scheduler -stop-after=greedy,0 -o - %s | FileCheck %s
4 # Make sure liveness is correctly updated when folding the cndmask and
8 name: cndmask_same_block
9 tracksRegLiveness: true
11 ; CHECK-LABEL: name: cndmask_same_block
13 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
15 ; CHECK-NEXT: [[DEF:%[0-9]+]]:sreg_64_xexec = IMPLICIT_DEF
16 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.2, implicit undef $vcc
19 ; CHECK-NEXT: successors: %bb.4(0x80000000)
21 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.4, implicit undef $vcc
22 ; CHECK-NEXT: S_BRANCH %bb.4
25 ; CHECK-NEXT: successors: %bb.4(0x40000000), %bb.3(0x40000000)
27 ; CHECK-NEXT: $vcc = S_ANDN2_B64 $exec, [[DEF]], implicit-def $scc
28 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.4, implicit $vcc
29 ; CHECK-NEXT: S_BRANCH %bb.3
32 ; CHECK-NEXT: successors: %bb.4(0x80000000)
34 ; CHECK-NEXT: S_BRANCH %bb.4
38 %0:sreg_64_xexec = IMPLICIT_DEF
39 S_CBRANCH_VCCNZ %bb.2, implicit undef $vcc
42 S_CBRANCH_VCCNZ %bb.4, implicit undef $vcc
46 %1:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, %0, implicit $exec
47 %2:sreg_64_xexec = V_CMP_NE_U32_e64 1, %1, implicit $exec
48 $vcc = S_AND_B64 $exec, %2, implicit-def $scc
49 S_CBRANCH_VCCNZ %bb.4, implicit $vcc
59 name: cndmask_separate_block
60 tracksRegLiveness: true
62 ; CHECK-LABEL: name: cndmask_separate_block
64 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
66 ; CHECK-NEXT: [[DEF:%[0-9]+]]:sreg_64_xexec = IMPLICIT_DEF
67 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.2, implicit undef $vcc
70 ; CHECK-NEXT: successors: %bb.4(0x80000000)
72 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.4, implicit undef $vcc
73 ; CHECK-NEXT: S_BRANCH %bb.4
76 ; CHECK-NEXT: successors: %bb.4(0x40000000), %bb.3(0x40000000)
78 ; CHECK-NEXT: $vcc = S_ANDN2_B64 $exec, [[DEF]], implicit-def $scc
79 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.4, implicit $vcc
80 ; CHECK-NEXT: S_BRANCH %bb.3
83 ; CHECK-NEXT: successors: %bb.4(0x80000000)
85 ; CHECK-NEXT: S_BRANCH %bb.4
89 %0:sreg_64_xexec = IMPLICIT_DEF
90 %1:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, %0, implicit $exec
91 S_CBRANCH_VCCNZ %bb.2, implicit undef $vcc
94 S_CBRANCH_VCCNZ %bb.4, implicit undef $vcc
98 %2:sreg_64_xexec = V_CMP_NE_U32_e64 1, %1, implicit $exec
99 $vcc = S_AND_B64 $exec, %2, implicit-def $scc
100 S_CBRANCH_VCCNZ %bb.4, implicit $vcc
110 name: cndmask_same_block_other_cmpreg_use
111 tracksRegLiveness: true
113 ; CHECK-LABEL: name: cndmask_same_block_other_cmpreg_use
115 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
117 ; CHECK-NEXT: [[DEF:%[0-9]+]]:sreg_64_xexec = IMPLICIT_DEF
118 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.2, implicit undef $vcc
121 ; CHECK-NEXT: successors: %bb.4(0x80000000)
123 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.4, implicit undef $vcc
124 ; CHECK-NEXT: S_BRANCH %bb.4
127 ; CHECK-NEXT: successors: %bb.4(0x40000000), %bb.3(0x40000000)
129 ; CHECK-NEXT: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, [[DEF]], implicit $exec
130 ; CHECK-NEXT: [[V_CMP_NE_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_NE_U32_e64 1, [[V_CNDMASK_B32_e64_]], implicit $exec
131 ; CHECK-NEXT: $vcc = S_ANDN2_B64 $exec, [[DEF]], implicit-def $scc
132 ; CHECK-NEXT: S_NOP 0, implicit [[V_CMP_NE_U32_e64_]]
133 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.4, implicit $vcc
134 ; CHECK-NEXT: S_BRANCH %bb.3
137 ; CHECK-NEXT: successors: %bb.4(0x80000000)
139 ; CHECK-NEXT: S_BRANCH %bb.4
143 %0:sreg_64_xexec = IMPLICIT_DEF
144 S_CBRANCH_VCCNZ %bb.2, implicit undef $vcc
147 S_CBRANCH_VCCNZ %bb.4, implicit undef $vcc
151 %1:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, %0, implicit $exec
152 %2:sreg_64_xexec = V_CMP_NE_U32_e64 1, %1, implicit $exec
154 $vcc = S_AND_B64 $exec, %2, implicit-def $scc
155 S_CBRANCH_VCCNZ %bb.4, implicit $vcc
165 name: cndmask_same_block_liveout_use
166 tracksRegLiveness: true
168 ; CHECK-LABEL: name: cndmask_same_block_liveout_use
170 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
172 ; CHECK-NEXT: [[DEF:%[0-9]+]]:sreg_64_xexec = IMPLICIT_DEF
173 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.2, implicit undef $vcc
176 ; CHECK-NEXT: successors: %bb.4(0x80000000)
178 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.4, implicit undef $vcc
179 ; CHECK-NEXT: S_BRANCH %bb.4
182 ; CHECK-NEXT: successors: %bb.4(0x40000000), %bb.3(0x40000000)
184 ; CHECK-NEXT: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, [[DEF]], implicit $exec
185 ; CHECK-NEXT: $vcc = S_ANDN2_B64 $exec, [[DEF]], implicit-def $scc
186 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.4, implicit $vcc
187 ; CHECK-NEXT: S_BRANCH %bb.3
190 ; CHECK-NEXT: successors: %bb.4(0x80000000)
192 ; CHECK-NEXT: S_NOP 0, implicit [[V_CNDMASK_B32_e64_]]
193 ; CHECK-NEXT: S_BRANCH %bb.4
197 %0:sreg_64_xexec = IMPLICIT_DEF
198 S_CBRANCH_VCCNZ %bb.2, implicit undef $vcc
201 S_CBRANCH_VCCNZ %bb.4, implicit undef $vcc
205 %1:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, %0, implicit $exec
206 %2:sreg_64_xexec = V_CMP_NE_U32_e64 1, %1, implicit $exec
207 $vcc = S_AND_B64 $exec, %2, implicit-def $scc
208 S_CBRANCH_VCCNZ %bb.4, implicit $vcc
218 # The legality check for removing the compare used to rely on
219 # use_nodbg_empty, which fails on the undef use of %2. We would then
220 # fail to update the interval correctly.
223 name: cmp_reg_extra_undef_use
224 tracksRegLiveness: true
226 ; CHECK-LABEL: name: cmp_reg_extra_undef_use
228 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
230 ; CHECK-NEXT: $vcc = S_ANDN2_B64 $exec, undef %1:sreg_64_xexec, implicit-def dead $scc
231 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.2, implicit $vcc
234 ; CHECK-NEXT: successors: %bb.2(0x80000000)
236 ; CHECK-NEXT: $vcc = S_AND_B64 $exec, undef %2:sreg_64_xexec, implicit-def dead $scc
240 %0:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, undef %1:sreg_64_xexec, implicit $exec
241 %2:sreg_64_xexec = V_CMP_NE_U32_e64 1, %0, implicit $exec
242 $vcc = S_AND_B64 $exec, %2, implicit-def dead $scc
243 S_CBRANCH_VCCNZ %bb.3, implicit killed $vcc
246 $vcc = S_AND_B64 $exec, undef %2, implicit-def dead $scc
252 # use_nodbg_empty is insufficient for erasing %1's def when removing
256 name: cndmask_undef_extra_use
257 tracksRegLiveness: true
259 ; CHECK-LABEL: name: cndmask_undef_extra_use
261 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
263 ; CHECK-NEXT: [[DEF:%[0-9]+]]:sreg_64_xexec = IMPLICIT_DEF
264 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.2, implicit undef $vcc
267 ; CHECK-NEXT: successors: %bb.4(0x80000000)
269 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.4, implicit undef $vcc
270 ; CHECK-NEXT: S_BRANCH %bb.4
273 ; CHECK-NEXT: successors: %bb.4(0x40000000), %bb.3(0x40000000)
275 ; CHECK-NEXT: dead %1:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, [[DEF]], implicit $exec
276 ; CHECK-NEXT: $vcc = S_ANDN2_B64 $exec, [[DEF]], implicit-def $scc
277 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.4, implicit $vcc
278 ; CHECK-NEXT: S_BRANCH %bb.3
281 ; CHECK-NEXT: successors: %bb.4(0x80000000)
283 ; CHECK-NEXT: S_NOP 0, implicit undef %1
284 ; CHECK-NEXT: S_BRANCH %bb.4
288 %0:sreg_64_xexec = IMPLICIT_DEF
289 S_CBRANCH_VCCNZ %bb.2, implicit undef $vcc
292 S_CBRANCH_VCCNZ %bb.4, implicit undef $vcc
296 %1:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, %0, implicit $exec
297 %2:sreg_64_xexec = V_CMP_NE_U32_e64 1, %1, implicit $exec
298 $vcc = S_AND_B64 $exec, %2, implicit-def $scc
299 S_CBRANCH_VCCNZ %bb.4, implicit $vcc
303 S_NOP 0, implicit undef %1
310 name: cndmask_is_undef
311 tracksRegLiveness: true
313 ; CHECK-LABEL: name: cndmask_is_undef
315 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
317 ; CHECK-NEXT: dead %0:sreg_64_xexec = S_MOV_B64 0
318 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.2, implicit undef $vcc
321 ; CHECK-NEXT: successors: %bb.4(0x80000000)
323 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.4, implicit undef $vcc
324 ; CHECK-NEXT: S_BRANCH %bb.4
327 ; CHECK-NEXT: successors: %bb.4(0x40000000), %bb.3(0x40000000)
329 ; CHECK-NEXT: $vcc = S_ANDN2_B64 $exec, undef %0, implicit-def $scc
330 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.4, implicit $vcc
331 ; CHECK-NEXT: S_BRANCH %bb.3
334 ; CHECK-NEXT: successors: %bb.4(0x80000000)
336 ; CHECK-NEXT: S_BRANCH %bb.4
340 %0:sreg_64_xexec = S_MOV_B64 0
341 S_CBRANCH_VCCNZ %bb.2, implicit undef $vcc
344 S_CBRANCH_VCCNZ %bb.4, implicit undef $vcc
348 %1:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, undef %0, implicit $exec
349 %2:sreg_64_xexec = V_CMP_NE_U32_e64 1, %1, implicit $exec
350 $vcc = S_AND_B64 $exec, %2, implicit-def $scc
351 S_CBRANCH_VCCNZ %bb.4, implicit $vcc
360 # Liveness of V_CNDMASK_B32 source (%0) must be extended through loop.
363 name: cndmask_loop_cndmask
364 tracksRegLiveness: true
366 ; CHECK-LABEL: name: cndmask_loop_cndmask
368 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
370 ; CHECK-NEXT: [[DEF:%[0-9]+]]:sreg_32 = IMPLICIT_DEF
371 ; CHECK-NEXT: [[DEF1:%[0-9]+]]:sreg_64_xexec = IMPLICIT_DEF
372 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.2, implicit undef $vcc
375 ; CHECK-NEXT: successors: %bb.4(0x40000000), %bb.2(0x40000000)
377 ; CHECK-NEXT: [[S_ADD_I32_:%[0-9]+]]:sreg_32 = S_ADD_I32 [[S_ADD_I32_]], -1, implicit-def $scc
378 ; CHECK-NEXT: S_CBRANCH_SCC0 %bb.4, implicit $scc
381 ; CHECK-NEXT: successors: %bb.4(0x40000000), %bb.3(0x40000000)
383 ; CHECK-NEXT: $vcc = S_ANDN2_B64 $exec, [[DEF1]], implicit-def $scc
384 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.4, implicit $vcc
385 ; CHECK-NEXT: S_BRANCH %bb.3
388 ; CHECK-NEXT: successors: %bb.1(0x80000000)
390 ; CHECK-NEXT: S_BRANCH %bb.1
394 %0:sreg_64_xexec = IMPLICIT_DEF
395 %1:sreg_32 = IMPLICIT_DEF
396 %2:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, %0, implicit $exec
397 S_CBRANCH_VCCNZ %bb.2, implicit undef $vcc
400 %1:sreg_32 = S_ADD_I32 %1, -1, implicit-def $scc
401 S_CBRANCH_SCC0 %bb.4, implicit $scc
404 %4:sreg_64_xexec = V_CMP_NE_U32_e64 1, %2, implicit $exec
405 $vcc = S_AND_B64 $exec, %4, implicit-def $scc
406 S_CBRANCH_VCCNZ %bb.4, implicit $vcc
416 name: cndmask_loop_cndmask_split
417 tracksRegLiveness: true
419 ; CHECK-LABEL: name: cndmask_loop_cndmask_split
421 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
423 ; CHECK-NEXT: $vcc = IMPLICIT_DEF
424 ; CHECK-NEXT: [[DEF:%[0-9]+]]:sreg_32 = IMPLICIT_DEF
425 ; CHECK-NEXT: [[DEF1:%[0-9]+]]:sreg_64_xexec = IMPLICIT_DEF
426 ; CHECK-NEXT: S_CBRANCH_VCCZ %bb.1, implicit $vcc
427 ; CHECK-NEXT: S_BRANCH %bb.2
430 ; CHECK-NEXT: successors: %bb.5(0x80000000)
432 ; CHECK-NEXT: S_BRANCH %bb.5
435 ; CHECK-NEXT: successors: %bb.4(0x40000000), %bb.3(0x40000000)
437 ; CHECK-NEXT: $vcc = S_ANDN2_B64 $exec, [[DEF1]], implicit-def $scc
438 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.4, implicit $vcc
441 ; CHECK-NEXT: successors: %bb.5(0x40000000), %bb.4(0x40000000)
443 ; CHECK-NEXT: [[S_ADD_I32_:%[0-9]+]]:sreg_32 = S_ADD_I32 [[S_ADD_I32_]], -1, implicit-def $scc
444 ; CHECK-NEXT: S_CBRANCH_SCC0 %bb.5, implicit $scc
447 ; CHECK-NEXT: successors: %bb.2(0x80000000)
449 ; CHECK-NEXT: S_BRANCH %bb.2
454 %0:sreg_64_xexec = IMPLICIT_DEF
455 %1:sreg_32 = IMPLICIT_DEF
456 %2:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, %0, implicit $exec
457 S_CBRANCH_VCCZ %bb.5, implicit $vcc
464 %4:sreg_64_xexec = V_CMP_NE_U32_e64 1, %2, implicit $exec
465 $vcc = S_AND_B64 $exec, %4, implicit-def $scc
466 S_CBRANCH_VCCNZ %bb.3, implicit $vcc
469 %1:sreg_32 = S_ADD_I32 %1, -1, implicit-def $scc
470 S_CBRANCH_SCC0 %bb.4, implicit $scc
478 # We would need to extend the live range of %0 to be live out of %bb.2
481 name: register_not_marked_liveout
482 tracksRegLiveness: true
484 isEntryFunction: true
485 scratchRSrcReg: '$sgpr0_sgpr1_sgpr2_sgpr3'
486 stackPtrOffsetReg: '$sgpr32'
489 ; CHECK-LABEL: name: register_not_marked_liveout
491 ; CHECK-NEXT: successors: %bb.1(0x80000000)
492 ; CHECK-NEXT: liveins: $vgpr0, $sgpr4_sgpr5, $sgpr6_sgpr7, $sgpr8_sgpr9, $sgpr10_sgpr11, $sgpr14, $sgpr15, $sgpr16
494 ; CHECK-NEXT: [[S_MOV_B64_:%[0-9]+]]:sreg_64_xexec = S_MOV_B64 0
495 ; CHECK-NEXT: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, [[S_MOV_B64_]], implicit $exec
496 ; CHECK-NEXT: [[V_CMP_GT_I32_e64_:%[0-9]+]]:sreg_64 = V_CMP_GT_I32_e64 0, [[V_CNDMASK_B32_e64_]], implicit $exec
497 ; CHECK-NEXT: $exec = S_MOV_B64_term [[V_CMP_GT_I32_e64_]]
500 ; CHECK-NEXT: successors: %bb.3(0x40000000), %bb.2(0x40000000)
502 ; CHECK-NEXT: $exec = S_MOV_B64_term [[V_CMP_GT_I32_e64_]]
503 ; CHECK-NEXT: S_CBRANCH_EXECZ %bb.3, implicit $exec
506 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.3(0x40000000)
508 ; CHECK-NEXT: $vcc = S_ANDN2_B64 $exec, [[S_MOV_B64_]], implicit-def dead $scc
509 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.1, implicit $vcc
513 liveins: $vgpr0, $sgpr4_sgpr5, $sgpr6_sgpr7, $sgpr8_sgpr9, $sgpr10_sgpr11, $sgpr14, $sgpr15, $sgpr16
515 %0:sreg_64_xexec = S_MOV_B64 0
516 %1:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, %0, implicit $exec
517 %2:sreg_64 = V_CMP_GT_I32_e64 0, %1, implicit $exec
518 $exec = S_MOV_B64_term %2
521 $exec = S_MOV_B64_term %2
522 S_CBRANCH_EXECZ %bb.3, implicit $exec
525 %3:sreg_64_xexec = V_CMP_NE_U32_e64 1, %1, implicit $exec
526 $vcc = S_AND_B64 $exec, %3, implicit-def dead $scc
527 S_CBRANCH_VCCNZ %bb.1, implicit killed $vcc
533 # Can't delete V_CNDMASK_B32 when folding into the use in %bb.3 since
534 # it's also used in %bb.0
536 name: cndmask_multiple_uses
537 tracksRegLiveness: true
539 ; CHECK-LABEL: name: cndmask_multiple_uses
541 ; CHECK-NEXT: successors: %bb.1(0x80000000)
542 ; CHECK-NEXT: liveins: $vgpr0, $sgpr4_sgpr5, $sgpr6_sgpr7, $sgpr8_sgpr9, $sgpr10_sgpr11, $sgpr14, $sgpr15, $sgpr16
544 ; CHECK-NEXT: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, undef %1:sreg_64_xexec, implicit $exec
545 ; CHECK-NEXT: [[V_CMP_NE_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_NE_U32_e64 1, [[V_CNDMASK_B32_e64_]], implicit $exec
548 ; CHECK-NEXT: successors: %bb.3(0x40000000), %bb.2(0x40000000)
550 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.3, implicit undef $vcc
553 ; CHECK-NEXT: successors: %bb.5(0x40000000), %bb.3(0x40000000)
555 ; CHECK-NEXT: $vcc = S_AND_B64 $exec, [[V_CMP_NE_U32_e64_]], implicit-def dead $scc
556 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.5, implicit $vcc
559 ; CHECK-NEXT: successors: %bb.5(0x40000000), %bb.4(0x40000000)
561 ; CHECK-NEXT: $vcc = S_ANDN2_B64 $exec, undef %1:sreg_64_xexec, implicit-def dead $scc
562 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.5, implicit $vcc
565 ; CHECK-NEXT: successors: %bb.5(0x80000000)
570 liveins: $vgpr0, $sgpr4_sgpr5, $sgpr6_sgpr7, $sgpr8_sgpr9, $sgpr10_sgpr11, $sgpr14, $sgpr15, $sgpr16
572 %0:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, undef %1:sreg_64_xexec, implicit $exec
573 %2:sreg_64_xexec = V_CMP_NE_U32_e64 1, %0, implicit $exec
576 S_CBRANCH_VCCNZ %bb.3, implicit undef $vcc
579 $vcc = S_AND_B64 $exec, %2, implicit-def dead $scc
580 S_CBRANCH_VCCNZ %bb.6, implicit killed $vcc
583 %3:sreg_64_xexec = V_CMP_NE_U32_e64 1, %0, implicit $exec
584 $vcc = S_AND_B64 $exec, %3, implicit-def dead $scc
585 S_CBRANCH_VCCNZ %bb.6, implicit killed $vcc
593 # The live segment of %1 from V_CMP_GT_I32 needs to be shrunk after the use in %bb.1 is deleted
595 name: leftover_use_of_selreg_extends_liverange
596 tracksRegLiveness: true
598 ; CHECK-LABEL: name: leftover_use_of_selreg_extends_liverange
600 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
601 ; CHECK-NEXT: liveins: $vgpr0, $sgpr4_sgpr5, $sgpr6_sgpr7, $sgpr8_sgpr9, $sgpr10_sgpr11, $sgpr14, $sgpr15, $sgpr16
603 ; CHECK-NEXT: [[DEF:%[0-9]+]]:sreg_64_xexec = IMPLICIT_DEF
604 ; CHECK-NEXT: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, [[DEF]], implicit $exec
605 ; CHECK-NEXT: [[V_CMP_GT_I32_e64_:%[0-9]+]]:sreg_64 = V_CMP_GT_I32_e64 0, [[V_CNDMASK_B32_e64_]], implicit $exec
606 ; CHECK-NEXT: $exec = S_MOV_B64_term [[V_CMP_GT_I32_e64_]]
607 ; CHECK-NEXT: S_CBRANCH_EXECZ %bb.2, implicit $exec
610 ; CHECK-NEXT: successors: %bb.3(0x40000000), %bb.2(0x40000000)
612 ; CHECK-NEXT: $vcc = S_ANDN2_B64 $exec, [[DEF]], implicit-def dead $scc
613 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.3, implicit $vcc
616 ; CHECK-NEXT: successors: %bb.3(0x80000000)
621 liveins: $vgpr0, $sgpr4_sgpr5, $sgpr6_sgpr7, $sgpr8_sgpr9, $sgpr10_sgpr11, $sgpr14, $sgpr15, $sgpr16
623 %0:sreg_64_xexec = IMPLICIT_DEF
624 %1:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, %0, implicit $exec
625 %2:sreg_64 = V_CMP_GT_I32_e64 0, %1, implicit $exec
626 $exec = S_MOV_B64_term %2
627 S_CBRANCH_EXECZ %bb.2, implicit $exec
630 %3:sreg_64_xexec = V_CMP_NE_U32_e64 1, %1, implicit $exec
631 $vcc = S_AND_B64 $exec, %3, implicit-def dead $scc
632 S_CBRANCH_VCCNZ %bb.3, implicit killed $vcc
641 name: leftover_use_of_selreg_extends_liverange_subrange
642 tracksRegLiveness: true
644 ; CHECK-LABEL: name: leftover_use_of_selreg_extends_liverange_subrange
646 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
647 ; CHECK-NEXT: liveins: $vgpr0, $sgpr4_sgpr5, $sgpr6_sgpr7, $sgpr8_sgpr9, $sgpr10_sgpr11, $sgpr14, $sgpr15, $sgpr16
649 ; CHECK-NEXT: [[DEF:%[0-9]+]]:sreg_64_xexec = IMPLICIT_DEF
650 ; CHECK-NEXT: undef %1.sub1:vreg_64 = V_CNDMASK_B32_e64 0, 0, 0, 1, [[DEF]], implicit $exec
651 ; CHECK-NEXT: [[V_CMP_GT_I32_e64_:%[0-9]+]]:sreg_64 = V_CMP_GT_I32_e64 0, %1.sub1, implicit $exec
652 ; CHECK-NEXT: %1.sub0:vreg_64 = V_MOV_B32_e32 123, implicit $exec
653 ; CHECK-NEXT: $exec = S_MOV_B64_term [[V_CMP_GT_I32_e64_]]
654 ; CHECK-NEXT: S_CBRANCH_EXECZ %bb.2, implicit $exec
657 ; CHECK-NEXT: successors: %bb.3(0x40000000), %bb.2(0x40000000)
659 ; CHECK-NEXT: $vcc = S_ANDN2_B64 $exec, [[DEF]], implicit-def dead $scc
660 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.3, implicit $vcc
663 ; CHECK-NEXT: successors: %bb.3(0x80000000)
665 ; CHECK-NEXT: S_NOP 0, implicit %1.sub0
669 liveins: $vgpr0, $sgpr4_sgpr5, $sgpr6_sgpr7, $sgpr8_sgpr9, $sgpr10_sgpr11, $sgpr14, $sgpr15, $sgpr16
671 %0:sreg_64_xexec = IMPLICIT_DEF
672 undef %1.sub1:vreg_64 = V_CNDMASK_B32_e64 0, 0, 0, 1, %0, implicit $exec
673 %1.sub0 = V_MOV_B32_e32 123, implicit $exec
674 %2:sreg_64 = V_CMP_GT_I32_e64 0, %1.sub1, implicit $exec
675 $exec = S_MOV_B64_term %2
676 S_CBRANCH_EXECZ %bb.2, implicit $exec
679 %3:sreg_64_xexec = V_CMP_NE_U32_e64 1, %1.sub1, implicit $exec
680 $vcc = S_AND_B64 $exec, %3, implicit-def dead $scc
681 S_CBRANCH_VCCNZ %bb.3, implicit killed $vcc
684 S_NOP 0, implicit %1.sub0
690 # This was trying to extend the liverange of %0 farther than needed,
691 # following %1's segment to %bb3
694 name: cannot_create_empty_or_backwards_segment
695 tracksRegLiveness: true
697 ; CHECK-LABEL: name: cannot_create_empty_or_backwards_segment
699 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
700 ; CHECK-NEXT: liveins: $sgpr4_sgpr5
702 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sreg_64_xexec = COPY $sgpr4_sgpr5
703 ; CHECK-NEXT: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, [[COPY]], implicit $exec
704 ; CHECK-NEXT: $vcc = S_ANDN2_B64 $exec, [[COPY]], implicit-def dead $scc
705 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.2, implicit $vcc
708 ; CHECK-NEXT: successors: %bb.3(0x40000000), %bb.2(0x40000000)
710 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.3, implicit undef $vcc
713 ; CHECK-NEXT: S_ENDPGM 0
716 ; CHECK-NEXT: S_ENDPGM 0, implicit [[V_CNDMASK_B32_e64_]]
718 liveins: $sgpr4_sgpr5
720 %0:sreg_64_xexec = COPY $sgpr4_sgpr5
721 %1:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, %0, implicit $exec
722 %2:sreg_64_xexec = V_CMP_NE_U32_e64 1, %1, implicit $exec
723 $vcc = S_AND_B64 $exec, %2, implicit-def dead $scc
724 S_CBRANCH_VCCNZ %bb.2, implicit killed $vcc
727 S_CBRANCH_VCCNZ %bb.3, implicit killed undef $vcc
733 S_ENDPGM 0, implicit %1
737 name: cannot_create_empty_or_backwards_segment_2
738 tracksRegLiveness: true
740 ; CHECK-LABEL: name: cannot_create_empty_or_backwards_segment_2
742 ; CHECK-NEXT: successors: %bb.1(0x80000000)
743 ; CHECK-NEXT: liveins: $sgpr4_sgpr5
747 ; CHECK-NEXT: successors: %bb.2(0x80000000)
748 ; CHECK-NEXT: liveins: $sgpr4_sgpr5
750 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sreg_64_xexec = COPY $sgpr4_sgpr5
751 ; CHECK-NEXT: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, [[COPY]], implicit $exec
752 ; CHECK-NEXT: $vcc = S_ANDN2_B64 $exec, [[COPY]], implicit-def dead $scc
753 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.2, implicit $vcc
756 ; CHECK-NEXT: successors: %bb.4(0x40000000), %bb.1(0x40000000)
757 ; CHECK-NEXT: liveins: $sgpr4_sgpr5
759 ; CHECK-NEXT: S_NOP 0, implicit-def dead [[V_CNDMASK_B32_e64_]], implicit [[V_CNDMASK_B32_e64_]]
760 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.4, implicit undef $vcc
761 ; CHECK-NEXT: S_BRANCH %bb.1
764 ; CHECK-NEXT: S_ENDPGM 0
767 ; CHECK-NEXT: S_ENDPGM 0
769 liveins: $sgpr4_sgpr5
772 liveins: $sgpr4_sgpr5
774 %0:sreg_64_xexec = COPY $sgpr4_sgpr5
775 %1:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, %0, implicit $exec
776 %2:sreg_64_xexec = V_CMP_NE_U32_e64 1, %1, implicit $exec
777 $vcc = S_AND_B64 $exec, %2, implicit-def dead $scc
778 S_CBRANCH_VCCNZ %bb.2, implicit killed $vcc
781 liveins: $sgpr4_sgpr5
782 S_NOP 0, implicit-def %1, implicit %1
783 S_CBRANCH_VCCNZ %bb.4, implicit killed undef $vcc