1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx908 -start-before=greedy,0 -stop-after=virtregrewriter,0 -o - %s | FileCheck %s
4 # This testcase used to fail due to introducing a spill of an SGPR
5 # 1024 for every subregister use inside the loop. With overlapping
6 # unspillable split ranges, it wasn't able to allocate one of the
7 # tuples. We avoid this by ensuring wide tuples are always allocated
8 # first (although the allocator should probably have been smart enough
9 # to handle this without that hint. Ideally it would understand we
10 # only need to spill/restore single subregisters at a time).
13 name: greedy_fail_alloc_sgpr1024_spill
14 tracksRegLiveness: true
18 explicitKernArgSize: 16
22 scratchRSrcReg: '$sgpr0_sgpr1_sgpr2_sgpr3'
23 stackPtrOffsetReg: '$sgpr32'
26 ; CHECK-LABEL: name: greedy_fail_alloc_sgpr1024_spill
28 ; CHECK-NEXT: successors: %bb.1(0x80000000)
29 ; CHECK-NEXT: liveins: $sgpr14, $sgpr15, $vgpr0, $vgpr1, $vgpr2, $sgpr4_sgpr5, $sgpr6_sgpr7, $sgpr8_sgpr9, $sgpr10_sgpr11
31 ; CHECK-NEXT: renamable $sgpr34_sgpr35 = COPY $sgpr8_sgpr9
32 ; CHECK-NEXT: renamable $sgpr33 = COPY $sgpr15
33 ; CHECK-NEXT: renamable $sgpr42 = COPY $sgpr14
34 ; CHECK-NEXT: renamable $sgpr36_sgpr37 = COPY $sgpr10_sgpr11
35 ; CHECK-NEXT: renamable $sgpr38_sgpr39 = COPY $sgpr6_sgpr7
36 ; CHECK-NEXT: renamable $sgpr40_sgpr41 = COPY $sgpr4_sgpr5
37 ; CHECK-NEXT: renamable $sgpr66_sgpr67 = S_LOAD_DWORDX2_IMM renamable $sgpr34_sgpr35, 0, 0 :: (dereferenceable invariant load (s64), align 16, addrspace 4)
38 ; CHECK-NEXT: renamable $sgpr44 = S_MOV_B32 0
39 ; CHECK-NEXT: renamable $sgpr45 = S_MOV_B32 0
40 ; CHECK-NEXT: renamable $sgpr46 = S_MOV_B32 0
41 ; CHECK-NEXT: renamable $sgpr47 = S_MOV_B32 0
42 ; CHECK-NEXT: renamable $sgpr48 = S_MOV_B32 0
43 ; CHECK-NEXT: renamable $sgpr49 = S_MOV_B32 0
44 ; CHECK-NEXT: renamable $sgpr50 = S_MOV_B32 0
45 ; CHECK-NEXT: renamable $sgpr51 = S_MOV_B32 0
46 ; CHECK-NEXT: renamable $sgpr52 = S_MOV_B32 0
47 ; CHECK-NEXT: renamable $sgpr53 = S_MOV_B32 0
48 ; CHECK-NEXT: renamable $sgpr54 = S_MOV_B32 0
49 ; CHECK-NEXT: renamable $sgpr55 = S_MOV_B32 0
50 ; CHECK-NEXT: renamable $sgpr56 = S_MOV_B32 0
51 ; CHECK-NEXT: renamable $sgpr57 = S_MOV_B32 0
52 ; CHECK-NEXT: renamable $sgpr58 = S_MOV_B32 0
53 ; CHECK-NEXT: renamable $sgpr59 = S_MOV_B32 0
54 ; CHECK-NEXT: renamable $sgpr60 = S_MOV_B32 0
55 ; CHECK-NEXT: renamable $sgpr61 = S_MOV_B32 0
56 ; CHECK-NEXT: renamable $sgpr62 = S_MOV_B32 0
57 ; CHECK-NEXT: renamable $sgpr63 = S_MOV_B32 0
58 ; CHECK-NEXT: renamable $sgpr64 = S_MOV_B32 0
59 ; CHECK-NEXT: renamable $sgpr68_sgpr69 = IMPLICIT_DEF
60 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $scc, implicit-def $sgpr32, implicit $sgpr32
61 ; CHECK-NEXT: dead $sgpr30_sgpr31 = SI_CALL renamable $sgpr68_sgpr69, 0, csr_amdgpu, implicit $sgpr0_sgpr1_sgpr2_sgpr3
62 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $scc, implicit-def $sgpr32, implicit $sgpr32
63 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $scc, implicit-def $sgpr32, implicit $sgpr32
64 ; CHECK-NEXT: $sgpr4_sgpr5 = COPY killed renamable $sgpr40_sgpr41
65 ; CHECK-NEXT: $sgpr6_sgpr7 = COPY killed renamable $sgpr38_sgpr39
66 ; CHECK-NEXT: $sgpr8_sgpr9 = COPY killed renamable $sgpr34_sgpr35
67 ; CHECK-NEXT: $sgpr10_sgpr11 = COPY killed renamable $sgpr36_sgpr37
68 ; CHECK-NEXT: $sgpr12 = COPY killed renamable $sgpr42
69 ; CHECK-NEXT: $sgpr13 = COPY killed renamable $sgpr33
70 ; CHECK-NEXT: dead $sgpr30_sgpr31 = SI_CALL killed renamable $sgpr68_sgpr69, 0, csr_amdgpu, implicit $sgpr4_sgpr5, implicit $sgpr6_sgpr7, implicit $sgpr8_sgpr9, implicit $sgpr10_sgpr11, implicit killed $sgpr12, implicit killed $sgpr13, implicit $sgpr0_sgpr1_sgpr2_sgpr3
71 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $scc, implicit-def $sgpr32, implicit $sgpr32
72 ; CHECK-NEXT: renamable $sgpr4_sgpr5 = COPY $exec, implicit-def $exec
73 ; CHECK-NEXT: dead renamable $sgpr6_sgpr7 = IMPLICIT_DEF
76 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.4(0x40000000)
77 ; CHECK-NEXT: liveins: $sgpr44_sgpr45_sgpr46_sgpr47_sgpr48_sgpr49_sgpr50_sgpr51_sgpr52_sgpr53_sgpr54_sgpr55_sgpr56_sgpr57_sgpr58_sgpr59_sgpr60_sgpr61_sgpr62_sgpr63_sgpr64_sgpr65_sgpr66_sgpr67_sgpr68_sgpr69_sgpr70_sgpr71_sgpr72_sgpr73_sgpr74_sgpr75:0x000003FFFFFFFFFF, $sgpr4_sgpr5, $sgpr66_sgpr67:0x000000000000000F
79 ; CHECK-NEXT: renamable $sgpr6_sgpr7 = COPY $exec, implicit-def $exec
80 ; CHECK-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
83 ; CHECK-NEXT: successors: %bb.3(0x80000000)
84 ; CHECK-NEXT: liveins: $sgpr44_sgpr45_sgpr46_sgpr47_sgpr48_sgpr49_sgpr50_sgpr51_sgpr52_sgpr53_sgpr54_sgpr55_sgpr56_sgpr57_sgpr58_sgpr59_sgpr60_sgpr61_sgpr62_sgpr63_sgpr64_sgpr65_sgpr66_sgpr67_sgpr68_sgpr69_sgpr70_sgpr71_sgpr72_sgpr73_sgpr74_sgpr75:0x000003FFFFFFFFFF, $sgpr4_sgpr5, $sgpr66_sgpr67:0x000000000000000F
86 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vreg_1024 = COPY renamable $sgpr44_sgpr45_sgpr46_sgpr47_sgpr48_sgpr49_sgpr50_sgpr51_sgpr52_sgpr53_sgpr54_sgpr55_sgpr56_sgpr57_sgpr58_sgpr59_sgpr60_sgpr61_sgpr62_sgpr63_sgpr64_sgpr65_sgpr66_sgpr67_sgpr68_sgpr69_sgpr70_sgpr71_sgpr72_sgpr73_sgpr74_sgpr75
87 ; CHECK-NEXT: renamable $sgpr6 = S_LSHL_B32 renamable $sgpr67, 1, implicit-def dead $scc
88 ; CHECK-NEXT: dead [[COPY]]:vreg_1024 = V_INDIRECT_REG_WRITE_GPR_IDX_B32_V32 [[COPY]], 0, killed $sgpr6, 3, implicit-def $m0, implicit $m0, implicit $exec
91 ; CHECK-NEXT: successors: %bb.5(0x40000000), %bb.1(0x40000000)
92 ; CHECK-NEXT: liveins: $sgpr44_sgpr45_sgpr46_sgpr47_sgpr48_sgpr49_sgpr50_sgpr51_sgpr52_sgpr53_sgpr54_sgpr55_sgpr56_sgpr57_sgpr58_sgpr59_sgpr60_sgpr61_sgpr62_sgpr63_sgpr64_sgpr65_sgpr66_sgpr67_sgpr68_sgpr69_sgpr70_sgpr71_sgpr72_sgpr73_sgpr74_sgpr75:0x000003FFFFFFFFFF, $sgpr4_sgpr5, $sgpr66_sgpr67:0x000000000000000F
94 ; CHECK-NEXT: renamable $sgpr6_sgpr7 = S_OR_SAVEEXEC_B64 renamable $sgpr4_sgpr5, implicit-def $exec, implicit-def $scc, implicit $exec
95 ; CHECK-NEXT: renamable $sgpr68 = COPY renamable $sgpr44
96 ; CHECK-NEXT: renamable $sgpr69 = COPY renamable $sgpr44
97 ; CHECK-NEXT: renamable $sgpr70 = COPY renamable $sgpr44
98 ; CHECK-NEXT: renamable $sgpr71 = COPY renamable $sgpr44
99 ; CHECK-NEXT: renamable $sgpr72 = COPY renamable $sgpr44
100 ; CHECK-NEXT: renamable $sgpr73 = COPY renamable $sgpr44
101 ; CHECK-NEXT: renamable $sgpr74 = COPY renamable $sgpr44
102 ; CHECK-NEXT: renamable $sgpr75 = COPY renamable $sgpr44
103 ; CHECK-NEXT: renamable $sgpr76 = COPY renamable $sgpr44
104 ; CHECK-NEXT: renamable $sgpr77 = COPY renamable $sgpr44
105 ; CHECK-NEXT: renamable $sgpr78 = COPY renamable $sgpr44
106 ; CHECK-NEXT: renamable $sgpr79 = COPY renamable $sgpr44
107 ; CHECK-NEXT: renamable $sgpr80 = COPY renamable $sgpr44
108 ; CHECK-NEXT: renamable $sgpr81 = COPY renamable $sgpr44
109 ; CHECK-NEXT: renamable $sgpr82 = COPY renamable $sgpr44
110 ; CHECK-NEXT: renamable $sgpr83 = COPY renamable $sgpr44
111 ; CHECK-NEXT: renamable $sgpr84 = COPY renamable $sgpr44
112 ; CHECK-NEXT: renamable $sgpr85 = COPY renamable $sgpr44
113 ; CHECK-NEXT: renamable $sgpr86 = COPY renamable $sgpr44
114 ; CHECK-NEXT: renamable $sgpr87 = COPY renamable $sgpr44
115 ; CHECK-NEXT: renamable $sgpr88 = COPY renamable $sgpr44
116 ; CHECK-NEXT: renamable $sgpr89 = COPY renamable $sgpr44
117 ; CHECK-NEXT: dead %18:vreg_1024 = COPY renamable $sgpr68_sgpr69_sgpr70_sgpr71_sgpr72_sgpr73_sgpr74_sgpr75_sgpr76_sgpr77_sgpr78_sgpr79_sgpr80_sgpr81_sgpr82_sgpr83_sgpr84_sgpr85_sgpr86_sgpr87_sgpr88_sgpr89_sgpr90_sgpr91_sgpr92_sgpr93_sgpr94_sgpr95_sgpr96_sgpr97_sgpr98_sgpr99, implicit $exec
118 ; CHECK-NEXT: $exec = S_XOR_B64_term $exec, killed renamable $sgpr6_sgpr7, implicit-def $scc
119 ; CHECK-NEXT: S_CBRANCH_EXECZ %bb.5, implicit $exec
120 ; CHECK-NEXT: S_BRANCH %bb.1
123 ; CHECK-NEXT: successors: %bb.5(0x80000000)
124 ; CHECK-NEXT: liveins: $sgpr44_sgpr45_sgpr46_sgpr47_sgpr48_sgpr49_sgpr50_sgpr51_sgpr52_sgpr53_sgpr54_sgpr55_sgpr56_sgpr57_sgpr58_sgpr59_sgpr60_sgpr61_sgpr62_sgpr63_sgpr64_sgpr65_sgpr66_sgpr67_sgpr68_sgpr69_sgpr70_sgpr71_sgpr72_sgpr73_sgpr74_sgpr75:0x000003FFFFFFFFFF, $sgpr6_sgpr7, $sgpr66_sgpr67:0x0000000000000003
126 ; CHECK-NEXT: $exec = S_OR_B64 $exec, killed renamable $sgpr6_sgpr7, implicit-def $scc
127 ; CHECK-NEXT: dead renamable $sgpr4 = S_LSHL_B32 killed renamable $sgpr66, 1, implicit-def dead $scc
128 ; CHECK-NEXT: dead %16:vreg_1024 = COPY renamable $sgpr44_sgpr45_sgpr46_sgpr47_sgpr48_sgpr49_sgpr50_sgpr51_sgpr52_sgpr53_sgpr54_sgpr55_sgpr56_sgpr57_sgpr58_sgpr59_sgpr60_sgpr61_sgpr62_sgpr63_sgpr64_sgpr65_sgpr66_sgpr67_sgpr68_sgpr69_sgpr70_sgpr71_sgpr72_sgpr73_sgpr74_sgpr75
132 liveins: $vgpr0, $vgpr1, $vgpr2, $sgpr4_sgpr5, $sgpr6_sgpr7, $sgpr8_sgpr9, $sgpr10_sgpr11, $sgpr14, $sgpr15
134 %0:sgpr_64 = COPY $sgpr8_sgpr9
135 %1:sgpr_32 = COPY $sgpr15
136 %2:sgpr_32 = COPY $sgpr14
137 %3:sgpr_64 = COPY $sgpr10_sgpr11
138 %4:sgpr_64 = COPY $sgpr6_sgpr7
139 %5:sgpr_64 = COPY $sgpr4_sgpr5
140 %6:sreg_64_xexec = S_LOAD_DWORDX2_IMM %0, 0, 0 :: (dereferenceable invariant load (s64), align 16, addrspace 4)
141 undef %7.sub0:sgpr_1024 = S_MOV_B32 0
142 %7.sub1:sgpr_1024 = S_MOV_B32 0
143 %7.sub2:sgpr_1024 = S_MOV_B32 0
144 %7.sub3:sgpr_1024 = S_MOV_B32 0
145 %7.sub4:sgpr_1024 = S_MOV_B32 0
146 %7.sub5:sgpr_1024 = S_MOV_B32 0
147 %7.sub6:sgpr_1024 = S_MOV_B32 0
148 %7.sub7:sgpr_1024 = S_MOV_B32 0
149 %7.sub8:sgpr_1024 = S_MOV_B32 0
150 %7.sub9:sgpr_1024 = S_MOV_B32 0
151 %7.sub10:sgpr_1024 = S_MOV_B32 0
152 %7.sub11:sgpr_1024 = S_MOV_B32 0
153 %7.sub12:sgpr_1024 = S_MOV_B32 0
154 %7.sub13:sgpr_1024 = S_MOV_B32 0
155 %7.sub14:sgpr_1024 = S_MOV_B32 0
156 %7.sub15:sgpr_1024 = S_MOV_B32 0
157 %7.sub16:sgpr_1024 = S_MOV_B32 0
158 %7.sub17:sgpr_1024 = S_MOV_B32 0
159 %7.sub18:sgpr_1024 = S_MOV_B32 0
160 %7.sub19:sgpr_1024 = S_MOV_B32 0
161 %7.sub20:sgpr_1024 = S_MOV_B32 0
162 %8:sreg_64 = IMPLICIT_DEF
163 ADJCALLSTACKUP 0, 0, implicit-def dead $scc, implicit-def $sgpr32, implicit $sgpr32
164 dead $sgpr30_sgpr31 = SI_CALL %8, 0, csr_amdgpu, implicit $sgpr0_sgpr1_sgpr2_sgpr3
165 ADJCALLSTACKDOWN 0, 0, implicit-def dead $scc, implicit-def $sgpr32, implicit $sgpr32
166 ADJCALLSTACKUP 0, 0, implicit-def dead $scc, implicit-def $sgpr32, implicit $sgpr32
167 $sgpr4_sgpr5 = COPY %5
168 $sgpr6_sgpr7 = COPY %4
169 $sgpr8_sgpr9 = COPY %0
170 $sgpr10_sgpr11 = COPY %3
173 dead $sgpr30_sgpr31 = SI_CALL %8, 0, csr_amdgpu, implicit $sgpr4_sgpr5, implicit $sgpr6_sgpr7, implicit $sgpr8_sgpr9, implicit $sgpr10_sgpr11, implicit killed $sgpr12, implicit killed $sgpr13, implicit $sgpr0_sgpr1_sgpr2_sgpr3
174 ADJCALLSTACKDOWN 0, 0, implicit-def dead $scc, implicit-def $sgpr32, implicit $sgpr32
175 %9:sreg_64 = COPY $exec, implicit-def $exec
176 %10:sreg_64 = IMPLICIT_DEF
179 successors: %bb.2, %bb.4
181 %11:sreg_64 = COPY $exec, implicit-def $exec
182 S_CBRANCH_EXECZ %bb.4, implicit $exec
185 %12:vreg_1024 = COPY %7
186 %13:sreg_32 = S_LSHL_B32 %6.sub1, 1, implicit-def dead $scc
187 %12:vreg_1024 = V_INDIRECT_REG_WRITE_GPR_IDX_B32_V32 %12, 0, %13, 3, implicit-def $m0, implicit $m0, implicit $exec
190 %14:sreg_64 = S_OR_SAVEEXEC_B64 %9, implicit-def $exec, implicit-def $scc, implicit $exec
191 undef %15.sub0:sgpr_1024 = COPY %7.sub0
192 %15.sub1:sgpr_1024 = COPY %7.sub0
193 %15.sub2:sgpr_1024 = COPY %7.sub0
194 %15.sub3:sgpr_1024 = COPY %7.sub0
195 %15.sub4:sgpr_1024 = COPY %7.sub0
196 %15.sub5:sgpr_1024 = COPY %7.sub0
197 %15.sub6:sgpr_1024 = COPY %7.sub0
198 %15.sub7:sgpr_1024 = COPY %7.sub0
199 %15.sub8:sgpr_1024 = COPY %7.sub0
200 %15.sub9:sgpr_1024 = COPY %7.sub0
201 %15.sub10:sgpr_1024 = COPY %7.sub0
202 %15.sub11:sgpr_1024 = COPY %7.sub0
203 %15.sub12:sgpr_1024 = COPY %7.sub0
204 %15.sub13:sgpr_1024 = COPY %7.sub0
205 %15.sub14:sgpr_1024 = COPY %7.sub0
206 %15.sub15:sgpr_1024 = COPY %7.sub0
207 %15.sub16:sgpr_1024 = COPY %7.sub0
208 %15.sub17:sgpr_1024 = COPY %7.sub0
209 %15.sub18:sgpr_1024 = COPY %7.sub0
210 %15.sub19:sgpr_1024 = COPY %7.sub0
211 %15.sub20:sgpr_1024 = COPY %7.sub0
212 %15.sub21:sgpr_1024 = COPY %7.sub0
213 ; Spill code ends up getting inserted here, and we end up with many unspillable sgpr1024 ranges
214 %16:vreg_1024 = COPY %15, implicit $exec
215 $exec = S_XOR_B64_term $exec, %14, implicit-def $scc
216 S_CBRANCH_EXECZ %bb.5, implicit $exec
220 $exec = S_OR_B64 $exec, %11, implicit-def $scc
221 %17:sreg_32 = S_LSHL_B32 %6.sub0, 1, implicit-def dead $scc
222 %16:vreg_1024 = COPY %7