1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py 2# RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -start-after=phi-node-elimination -stop-before=greedy -o - %s | FileCheck -check-prefix=GFX9 %s 3 4# Make sure that the V_MOV_B32 isn't rematerialized out of the loop. This was also breaking RenameIndependentSubregisters which missed the use of all subregisters. 5 6--- 7name: index_vgpr_waterfall_loop 8tracksRegLiveness: true 9liveins: 10 - { reg: '$vgpr0', virtual-reg: '%0' } 11 - { reg: '$vgpr1', virtual-reg: '%1' } 12 - { reg: '$vgpr2', virtual-reg: '%2' } 13 - { reg: '$vgpr3', virtual-reg: '%3' } 14 - { reg: '$vgpr4', virtual-reg: '%4' } 15 - { reg: '$vgpr5', virtual-reg: '%5' } 16 - { reg: '$vgpr6', virtual-reg: '%6' } 17 - { reg: '$vgpr7', virtual-reg: '%7' } 18 - { reg: '$vgpr8', virtual-reg: '%8' } 19 - { reg: '$vgpr9', virtual-reg: '%9' } 20 - { reg: '$vgpr10', virtual-reg: '%10' } 21 - { reg: '$vgpr11', virtual-reg: '%11' } 22 - { reg: '$vgpr12', virtual-reg: '%12' } 23 - { reg: '$vgpr13', virtual-reg: '%13' } 24 - { reg: '$vgpr14', virtual-reg: '%14' } 25 - { reg: '$vgpr15', virtual-reg: '%15' } 26 - { reg: '$vgpr16', virtual-reg: '%16' } 27 - { reg: '$sgpr30_sgpr31', virtual-reg: '%17' } 28body: | 29 ; GFX9-LABEL: name: index_vgpr_waterfall_loop 30 ; GFX9: bb.0: 31 ; GFX9: successors: %bb.1(0x80000000) 32 ; GFX9: liveins: $vgpr0, $vgpr1, $vgpr2, $vgpr3, $vgpr4, $vgpr5, $vgpr6, $vgpr7, $vgpr8, $vgpr9, $vgpr10, $vgpr11, $vgpr12, $vgpr13, $vgpr14, $vgpr15, $vgpr16, $sgpr30_sgpr31 33 ; GFX9: [[COPY:%[0-9]+]]:sreg_64 = COPY $sgpr30_sgpr31 34 ; GFX9: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr16 35 ; GFX9: undef %18.sub15:vreg_512 = COPY $vgpr15 36 ; GFX9: %18.sub14:vreg_512 = COPY $vgpr14 37 ; GFX9: %18.sub13:vreg_512 = COPY $vgpr13 38 ; GFX9: %18.sub12:vreg_512 = COPY $vgpr12 39 ; GFX9: %18.sub11:vreg_512 = COPY $vgpr11 40 ; GFX9: %18.sub10:vreg_512 = COPY $vgpr10 41 ; GFX9: %18.sub9:vreg_512 = COPY $vgpr9 42 ; GFX9: %18.sub8:vreg_512 = COPY $vgpr8 43 ; GFX9: %18.sub7:vreg_512 = COPY $vgpr7 44 ; GFX9: %18.sub6:vreg_512 = COPY $vgpr6 45 ; GFX9: %18.sub5:vreg_512 = COPY $vgpr5 46 ; GFX9: %18.sub4:vreg_512 = COPY $vgpr4 47 ; GFX9: %18.sub3:vreg_512 = COPY $vgpr3 48 ; GFX9: %18.sub2:vreg_512 = COPY $vgpr2 49 ; GFX9: %18.sub1:vreg_512 = COPY $vgpr1 50 ; GFX9: %18.sub0:vreg_512 = COPY $vgpr0 51 ; GFX9: [[V_AND_B32_e32_:%[0-9]+]]:vgpr_32 = V_AND_B32_e32 15, [[COPY1]], implicit $exec 52 ; GFX9: [[S_MOV_B64_:%[0-9]+]]:sreg_64_xexec = S_MOV_B64 $exec 53 ; GFX9: bb.1: 54 ; GFX9: successors: %bb.1(0x40000000), %bb.2(0x40000000) 55 ; GFX9: [[V_READFIRSTLANE_B32_:%[0-9]+]]:sgpr_32 = V_READFIRSTLANE_B32 [[V_AND_B32_e32_]], implicit $exec 56 ; GFX9: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64 = V_CMP_EQ_U32_e64 [[V_READFIRSTLANE_B32_]], [[V_AND_B32_e32_]], implicit $exec 57 ; GFX9: [[S_AND_SAVEEXEC_B64_:%[0-9]+]]:sreg_64 = S_AND_SAVEEXEC_B64 [[V_CMP_EQ_U32_e64_]], implicit-def $exec, implicit-def dead $scc, implicit $exec 58 ; GFX9: S_SET_GPR_IDX_ON [[V_READFIRSTLANE_B32_]], 1, implicit-def $m0, implicit-def $mode, implicit undef $m0, implicit $mode 59 ; GFX9: [[V_MOV_B32_e32_:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 undef %18.sub0, implicit $exec, implicit %18, implicit $m0 60 ; GFX9: S_SET_GPR_IDX_OFF implicit-def $mode, implicit $mode 61 ; GFX9: $exec = S_XOR_B64_term $exec, [[S_AND_SAVEEXEC_B64_]], implicit-def dead $scc 62 ; GFX9: S_CBRANCH_EXECNZ %bb.1, implicit $exec 63 ; GFX9: bb.2: 64 ; GFX9: $exec = S_MOV_B64 [[S_MOV_B64_]] 65 ; GFX9: $sgpr30_sgpr31 = COPY [[COPY]] 66 ; GFX9: $vgpr0 = COPY [[V_MOV_B32_e32_]] 67 ; GFX9: S_SETPC_B64_return $sgpr30_sgpr31, implicit $vgpr0, implicit undef $vgpr1, implicit undef $vgpr2, implicit undef $vgpr3 68 bb.0: 69 successors: %bb.1 70 liveins: $vgpr0, $vgpr1, $vgpr2, $vgpr3, $vgpr4, $vgpr5, $vgpr6, $vgpr7, $vgpr8, $vgpr9, $vgpr10, $vgpr11, $vgpr12, $vgpr13, $vgpr14, $vgpr15, $vgpr16, $sgpr30_sgpr31 71 72 %17:sreg_64 = COPY killed $sgpr30_sgpr31 73 %16:vgpr_32 = COPY killed $vgpr16 74 %15:vgpr_32 = COPY killed $vgpr15 75 %14:vgpr_32 = COPY killed $vgpr14 76 %13:vgpr_32 = COPY killed $vgpr13 77 %12:vgpr_32 = COPY killed $vgpr12 78 %11:vgpr_32 = COPY killed $vgpr11 79 %10:vgpr_32 = COPY killed $vgpr10 80 %9:vgpr_32 = COPY killed $vgpr9 81 %8:vgpr_32 = COPY killed $vgpr8 82 %7:vgpr_32 = COPY killed $vgpr7 83 %6:vgpr_32 = COPY killed $vgpr6 84 %5:vgpr_32 = COPY killed $vgpr5 85 %4:vgpr_32 = COPY killed $vgpr4 86 %3:vgpr_32 = COPY killed $vgpr3 87 %2:vgpr_32 = COPY killed $vgpr2 88 %1:vgpr_32 = COPY killed $vgpr1 89 %0:vgpr_32 = COPY killed $vgpr0 90 %18:vreg_512 = REG_SEQUENCE killed %0, %subreg.sub0, killed %1, %subreg.sub1, killed %2, %subreg.sub2, killed %3, %subreg.sub3, killed %4, %subreg.sub4, killed %5, %subreg.sub5, killed %6, %subreg.sub6, killed %7, %subreg.sub7, killed %8, %subreg.sub8, killed %9, %subreg.sub9, killed %10, %subreg.sub10, killed %11, %subreg.sub11, killed %12, %subreg.sub12, killed %13, %subreg.sub13, killed %14, %subreg.sub14, killed %15, %subreg.sub15 91 %19:vgpr_32 = V_AND_B32_e32 15, killed %16, implicit $exec 92 %20:sreg_64_xexec = S_MOV_B64 $exec 93 94 bb.1: 95 successors: %bb.1, %bb.2 96 97 %21:sgpr_32 = V_READFIRSTLANE_B32 %19, implicit $exec 98 %22:sreg_64 = V_CMP_EQ_U32_e64 %21, %19, implicit $exec 99 %23:sreg_64 = S_AND_SAVEEXEC_B64 killed %22, implicit-def $exec, implicit-def dead $scc, implicit $exec 100 S_SET_GPR_IDX_ON killed %21, 1, implicit-def $m0, implicit-def $mode, implicit undef $m0, implicit $mode 101 %24:vgpr_32 = V_MOV_B32_e32 undef %18.sub0, implicit $exec, implicit %18, implicit $m0 102 S_SET_GPR_IDX_OFF implicit-def $mode, implicit $mode 103 $exec = S_XOR_B64_term $exec, killed %23, implicit-def dead $scc 104 S_CBRANCH_EXECNZ %bb.1, implicit $exec 105 106 bb.2: 107 $exec = S_MOV_B64 killed %20 108 $sgpr30_sgpr31 = COPY killed %17 109 $vgpr0 = COPY killed %24 110 S_SETPC_B64_return killed $sgpr30_sgpr31, implicit killed $vgpr0, implicit undef $vgpr1, implicit undef $vgpr2, implicit undef $vgpr3 111 112... 113