1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
2 # RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx900 -start-before=greedy,2 -stop-after=tailduplication -verify-machineinstrs -o - %s | FileCheck %s
4 # The partial def of %0 introduces a live out undef def of %0.sub1
5 # into bb.3. We need to maintain this liveness with an explicit def of
6 # the physical subregister. Without this, a verifier error would
7 # appear after tail duplication.
10 name: undef_subreg_def_live_out_tailduplicate_vreg64_undef_sub1
11 tracksRegLiveness: true
14 scratchRSrcReg: '$sgpr96_sgpr97_sgpr98_sgpr99'
15 stackPtrOffsetReg: '$sgpr32'
17 ; CHECK-LABEL: name: undef_subreg_def_live_out_tailduplicate_vreg64_undef_sub1
19 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
20 ; CHECK-NEXT: liveins: $sgpr0
22 ; CHECK-NEXT: S_CMP_EQ_U32 $sgpr0, 0, implicit-def $scc
23 ; CHECK-NEXT: S_CBRANCH_SCC0 %bb.2, implicit killed $scc
26 ; CHECK-NEXT: renamable $vgpr0 = V_MOV_B32_e32 0, implicit $exec, implicit-def $vgpr1
27 ; CHECK-NEXT: EXP 0, killed renamable $vgpr0, renamable $vgpr1, undef renamable $vgpr0, undef renamable $vgpr0, 0, 0, 0, implicit $exec
28 ; CHECK-NEXT: S_ENDPGM 0
31 ; CHECK-NEXT: S_NOP 0, implicit-def $sgpr4_sgpr5_sgpr6_sgpr7
32 ; CHECK-NEXT: renamable $vgpr0 = V_MOV_B32_e32 0, implicit $exec
33 ; CHECK-NEXT: renamable $vgpr0_vgpr1 = BUFFER_LOAD_FORMAT_XY_IDXEN killed renamable $vgpr0, $sgpr4_sgpr5_sgpr6_sgpr7, 0, 0, 0, 0, implicit $exec :: (dereferenceable load (s64), addrspace 8)
34 ; CHECK-NEXT: EXP 0, killed renamable $vgpr0, renamable $vgpr1, undef renamable $vgpr0, undef renamable $vgpr0, 0, 0, 0, implicit $exec
35 ; CHECK-NEXT: S_ENDPGM 0
39 S_CMP_EQ_U32 killed $sgpr0, 0, implicit-def $scc
40 S_CBRANCH_SCC0 %bb.2, implicit killed $scc
43 undef %0.sub0:vreg_64 = V_MOV_B32_e32 0, implicit $exec
47 S_NOP 0, implicit-def $sgpr4_sgpr5_sgpr6_sgpr7
48 %1:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
49 %0:vreg_64 = BUFFER_LOAD_FORMAT_XY_IDXEN killed %1, $sgpr4_sgpr5_sgpr6_sgpr7, 0, 0, 0, 0, implicit $exec :: (dereferenceable load (s64), addrspace 8)
52 EXP 0, killed %0.sub0, killed %0.sub1, undef %2:vgpr_32, undef %2:vgpr_32, 0, 0, 0, implicit $exec
58 name: undef_subreg_def_live_out_tailduplicate_vreg96_undef_sub1_sub2
59 tracksRegLiveness: true
62 scratchRSrcReg: '$sgpr96_sgpr97_sgpr98_sgpr99'
63 stackPtrOffsetReg: '$sgpr32'
65 ; CHECK-LABEL: name: undef_subreg_def_live_out_tailduplicate_vreg96_undef_sub1_sub2
67 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
68 ; CHECK-NEXT: liveins: $sgpr0
70 ; CHECK-NEXT: S_CMP_EQ_U32 $sgpr0, 0, implicit-def $scc
71 ; CHECK-NEXT: S_CBRANCH_SCC0 %bb.2, implicit killed $scc
74 ; CHECK-NEXT: renamable $vgpr0 = V_MOV_B32_e32 0, implicit $exec, implicit-def $vgpr1_vgpr2
75 ; CHECK-NEXT: EXP 0, killed renamable $vgpr0, renamable $vgpr1, renamable $vgpr2, undef renamable $vgpr0, 0, 0, 0, implicit $exec
76 ; CHECK-NEXT: S_ENDPGM 0
79 ; CHECK-NEXT: S_NOP 0, implicit-def $sgpr4_sgpr5_sgpr6_sgpr7
80 ; CHECK-NEXT: renamable $vgpr0 = V_MOV_B32_e32 0, implicit $exec
81 ; CHECK-NEXT: renamable $vgpr0_vgpr1_vgpr2 = BUFFER_LOAD_FORMAT_XYZ_IDXEN killed renamable $vgpr0, $sgpr4_sgpr5_sgpr6_sgpr7, 0, 0, 0, 0, implicit $exec :: (dereferenceable load (s96), align 16, addrspace 8)
82 ; CHECK-NEXT: EXP 0, killed renamable $vgpr0, renamable $vgpr1, renamable $vgpr2, undef renamable $vgpr0, 0, 0, 0, implicit $exec
83 ; CHECK-NEXT: S_ENDPGM 0
87 S_CMP_EQ_U32 killed $sgpr0, 0, implicit-def $scc
88 S_CBRANCH_SCC0 %bb.2, implicit killed $scc
91 undef %0.sub0:vreg_96 = V_MOV_B32_e32 0, implicit $exec
95 S_NOP 0, implicit-def $sgpr4_sgpr5_sgpr6_sgpr7
96 %1:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
97 %0:vreg_96 = BUFFER_LOAD_FORMAT_XYZ_IDXEN killed %1, $sgpr4_sgpr5_sgpr6_sgpr7, 0, 0, 0, 0, implicit $exec :: (dereferenceable load (s96), addrspace 8)
100 EXP 0, killed %0.sub0, killed %0.sub1, killed %0.sub2, undef %2:vgpr_32, 0, 0, 0, implicit $exec
106 name: undef_subreg_def_live_out_tailduplicate_vreg96_undef_sub0_sub2
107 tracksRegLiveness: true
109 isEntryFunction: true
110 scratchRSrcReg: '$sgpr96_sgpr97_sgpr98_sgpr99'
111 stackPtrOffsetReg: '$sgpr32'
113 ; CHECK-LABEL: name: undef_subreg_def_live_out_tailduplicate_vreg96_undef_sub0_sub2
115 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
116 ; CHECK-NEXT: liveins: $sgpr0
118 ; CHECK-NEXT: S_CMP_EQ_U32 $sgpr0, 0, implicit-def $scc
119 ; CHECK-NEXT: S_CBRANCH_SCC0 %bb.2, implicit killed $scc
122 ; CHECK-NEXT: renamable $vgpr1 = V_MOV_B32_e32 0, implicit $exec, implicit-def $vgpr2, implicit-def $vgpr0
123 ; CHECK-NEXT: EXP 0, killed renamable $vgpr0, renamable $vgpr1, renamable $vgpr2, undef renamable $vgpr0, 0, 0, 0, implicit $exec
124 ; CHECK-NEXT: S_ENDPGM 0
127 ; CHECK-NEXT: S_NOP 0, implicit-def $sgpr4_sgpr5_sgpr6_sgpr7
128 ; CHECK-NEXT: renamable $vgpr0 = V_MOV_B32_e32 0, implicit $exec
129 ; CHECK-NEXT: renamable $vgpr0_vgpr1_vgpr2 = BUFFER_LOAD_FORMAT_XYZ_IDXEN killed renamable $vgpr0, $sgpr4_sgpr5_sgpr6_sgpr7, 0, 0, 0, 0, implicit $exec :: (dereferenceable load (s96), align 16, addrspace 8)
130 ; CHECK-NEXT: EXP 0, killed renamable $vgpr0, renamable $vgpr1, renamable $vgpr2, undef renamable $vgpr0, 0, 0, 0, implicit $exec
131 ; CHECK-NEXT: S_ENDPGM 0
135 S_CMP_EQ_U32 killed $sgpr0, 0, implicit-def $scc
136 S_CBRANCH_SCC0 %bb.2, implicit killed $scc
139 undef %0.sub1:vreg_96 = V_MOV_B32_e32 0, implicit $exec
143 S_NOP 0, implicit-def $sgpr4_sgpr5_sgpr6_sgpr7
144 %1:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
145 %0:vreg_96 = BUFFER_LOAD_FORMAT_XYZ_IDXEN killed %1, $sgpr4_sgpr5_sgpr6_sgpr7, 0, 0, 0, 0, implicit $exec :: (dereferenceable load (s96), addrspace 8)
148 EXP 0, killed %0.sub0, killed %0.sub1, killed %0.sub2, undef %2:vgpr_32, 0, 0, 0, implicit $exec
153 # Test another use of the value before the block end.
155 name: undef_subreg_def_live_out_tailduplicate_vreg64_undef_sub1_undef_use_in_def_block
156 tracksRegLiveness: true
158 isEntryFunction: true
159 scratchRSrcReg: '$sgpr96_sgpr97_sgpr98_sgpr99'
160 stackPtrOffsetReg: '$sgpr32'
162 ; CHECK-LABEL: name: undef_subreg_def_live_out_tailduplicate_vreg64_undef_sub1_undef_use_in_def_block
164 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
165 ; CHECK-NEXT: liveins: $sgpr0
167 ; CHECK-NEXT: S_CMP_EQ_U32 $sgpr0, 0, implicit-def $scc
168 ; CHECK-NEXT: S_CBRANCH_SCC0 %bb.2, implicit killed $scc
171 ; CHECK-NEXT: renamable $vgpr0 = V_MOV_B32_e32 0, implicit $exec, implicit-def $vgpr1
172 ; CHECK-NEXT: S_NOP 0, implicit renamable $vgpr0_vgpr1
173 ; CHECK-NEXT: EXP 0, killed renamable $vgpr0, renamable $vgpr1, undef renamable $vgpr0, undef renamable $vgpr0, 0, 0, 0, implicit $exec
174 ; CHECK-NEXT: S_ENDPGM 0
177 ; CHECK-NEXT: S_NOP 0, implicit-def $sgpr4_sgpr5_sgpr6_sgpr7
178 ; CHECK-NEXT: renamable $vgpr0 = V_MOV_B32_e32 0, implicit $exec
179 ; CHECK-NEXT: renamable $vgpr0_vgpr1 = BUFFER_LOAD_FORMAT_XY_IDXEN killed renamable $vgpr0, $sgpr4_sgpr5_sgpr6_sgpr7, 0, 0, 0, 0, implicit $exec :: (dereferenceable load (s64), addrspace 8)
180 ; CHECK-NEXT: EXP 0, killed renamable $vgpr0, renamable $vgpr1, undef renamable $vgpr0, undef renamable $vgpr0, 0, 0, 0, implicit $exec
181 ; CHECK-NEXT: S_ENDPGM 0
185 S_CMP_EQ_U32 killed $sgpr0, 0, implicit-def $scc
186 S_CBRANCH_SCC0 %bb.2, implicit killed $scc
189 undef %0.sub0:vreg_64 = V_MOV_B32_e32 0, implicit $exec
194 S_NOP 0, implicit-def $sgpr4_sgpr5_sgpr6_sgpr7
195 %1:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
196 %0:vreg_64 = BUFFER_LOAD_FORMAT_XY_IDXEN killed %1, $sgpr4_sgpr5_sgpr6_sgpr7, 0, 0, 0, 0, implicit $exec :: (dereferenceable load (s64), addrspace 8)
199 EXP 0, killed %0.sub0, killed %0.sub1, undef %2:vgpr_32, undef %2:vgpr_32, 0, 0, 0, implicit $exec
204 # The undef subregister is not live out, no implicit def should be added for it
206 name: undef_subreg_def_live_out_tailduplicate_vreg64_undef_sub1_no_phi_use
207 tracksRegLiveness: true
209 isEntryFunction: true
210 scratchRSrcReg: '$sgpr96_sgpr97_sgpr98_sgpr99'
211 stackPtrOffsetReg: '$sgpr32'
213 ; CHECK-LABEL: name: undef_subreg_def_live_out_tailduplicate_vreg64_undef_sub1_no_phi_use
215 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
216 ; CHECK-NEXT: liveins: $sgpr0
218 ; CHECK-NEXT: S_CMP_EQ_U32 $sgpr0, 0, implicit-def $scc
219 ; CHECK-NEXT: S_CBRANCH_SCC0 %bb.2, implicit killed $scc
222 ; CHECK-NEXT: renamable $vgpr0 = V_MOV_B32_e32 0, implicit $exec
223 ; CHECK-NEXT: EXP 0, killed renamable $vgpr0, renamable $vgpr0, undef renamable $vgpr0, undef renamable $vgpr0, 0, 0, 0, implicit $exec
224 ; CHECK-NEXT: S_ENDPGM 0
227 ; CHECK-NEXT: S_NOP 0, implicit-def $sgpr4_sgpr5_sgpr6_sgpr7
228 ; CHECK-NEXT: renamable $vgpr0 = V_MOV_B32_e32 0, implicit $exec
229 ; CHECK-NEXT: renamable $vgpr0_vgpr1 = BUFFER_LOAD_FORMAT_XY_IDXEN killed renamable $vgpr0, $sgpr4_sgpr5_sgpr6_sgpr7, 0, 0, 0, 0, implicit $exec :: (dereferenceable load (s64), addrspace 8)
230 ; CHECK-NEXT: EXP 0, killed renamable $vgpr0, renamable $vgpr0, undef renamable $vgpr0, undef renamable $vgpr0, 0, 0, 0, implicit $exec
231 ; CHECK-NEXT: S_ENDPGM 0
235 S_CMP_EQ_U32 killed $sgpr0, 0, implicit-def $scc
236 S_CBRANCH_SCC0 %bb.2, implicit killed $scc
239 undef %0.sub0:vreg_64 = V_MOV_B32_e32 0, implicit $exec
243 S_NOP 0, implicit-def $sgpr4_sgpr5_sgpr6_sgpr7
244 %1:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
245 %0:vreg_64 = BUFFER_LOAD_FORMAT_XY_IDXEN killed %1, $sgpr4_sgpr5_sgpr6_sgpr7, 0, 0, 0, 0, implicit $exec :: (dereferenceable load (s64), addrspace 8)
248 EXP 0, killed %0.sub0, killed %0.sub0, undef %2:vgpr_32, undef %2:vgpr_32, 0, 0, 0, implicit $exec
253 # In bb.2, %0 should be assigned to vgpr0_vgpr1. Make sure the value
254 # copied from $vgpr0 into %3 isn't clobbered by the undef phi def for
257 name: assigned_physreg_subregister_interference
258 tracksRegLiveness: true
262 scratchRSrcReg: '$sgpr0_sgpr1_sgpr2_sgpr3'
263 frameOffsetReg: '$sgpr33'
264 stackPtrOffsetReg: '$sgpr32'
268 ; CHECK-LABEL: name: assigned_physreg_subregister_interference
270 ; CHECK-NEXT: successors: %bb.1(0x80000000)
271 ; CHECK-NEXT: liveins: $sgpr30, $sgpr31, $sgpr34, $sgpr35, $sgpr36, $sgpr37, $vgpr0, $vgpr1
273 ; CHECK-NEXT: $sgpr4_sgpr5 = S_OR_SAVEEXEC_B64 -1, implicit-def $exec, implicit-def dead $scc, implicit $exec
274 ; CHECK-NEXT: BUFFER_STORE_DWORD_OFFSET killed $vgpr40, $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr32, 0, 0, 0, implicit $exec :: (store (s32) into %stack.0, addrspace 5)
275 ; CHECK-NEXT: $exec = S_MOV_B64 killed $sgpr4_sgpr5
276 ; CHECK-NEXT: $vgpr40 = SI_SPILL_S32_TO_VGPR $sgpr30, 0, $vgpr40
277 ; CHECK-NEXT: $vgpr40 = SI_SPILL_S32_TO_VGPR $sgpr31, 1, $vgpr40
278 ; CHECK-NEXT: $vgpr40 = SI_SPILL_S32_TO_VGPR $sgpr34, 2, $vgpr40
279 ; CHECK-NEXT: $vgpr40 = SI_SPILL_S32_TO_VGPR $sgpr35, 3, $vgpr40
280 ; CHECK-NEXT: $vgpr40 = SI_SPILL_S32_TO_VGPR $sgpr36, 4, $vgpr40
281 ; CHECK-NEXT: $vgpr40 = SI_SPILL_S32_TO_VGPR $sgpr37, 5, $vgpr40
282 ; CHECK-NEXT: renamable $sgpr34_sgpr35 = S_MOV_B64 $exec
285 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
286 ; CHECK-NEXT: liveins: $sgpr34_sgpr35, $vgpr0_vgpr1:0x000000000000000F
288 ; CHECK-NEXT: renamable $sgpr4 = V_READFIRSTLANE_B32 $vgpr0, implicit $exec
289 ; CHECK-NEXT: renamable $sgpr5 = V_READFIRSTLANE_B32 $vgpr1, implicit $exec
290 ; CHECK-NEXT: renamable $vcc = V_CMP_EQ_U64_e64 $sgpr4_sgpr5, killed $vgpr0_vgpr1, implicit $exec
291 ; CHECK-NEXT: renamable $sgpr36_sgpr37 = S_AND_SAVEEXEC_B64 killed renamable $vcc, implicit-def $exec, implicit-def dead $scc, implicit $exec
292 ; CHECK-NEXT: dead $sgpr30_sgpr31 = noconvergent SI_CALL killed renamable $sgpr4_sgpr5, 0, csr_amdgpu, implicit $sgpr0_sgpr1_sgpr2_sgpr3, implicit-def $vgpr0
293 ; CHECK-NEXT: renamable $vgpr1 = COPY $vgpr0, implicit $exec
294 ; CHECK-NEXT: renamable $vgpr0 = V_MOV_B32_e32 123, implicit $exec
295 ; CHECK-NEXT: $exec = S_XOR_B64 $exec, renamable $sgpr36_sgpr37, implicit-def dead $scc
296 ; CHECK-NEXT: S_CBRANCH_EXECNZ %bb.1, implicit $exec
299 ; CHECK-NEXT: liveins: $vgpr1, $sgpr34_sgpr35
301 ; CHECK-NEXT: $exec = COPY renamable $sgpr34_sgpr35
302 ; CHECK-NEXT: renamable $vgpr0 = V_ADD_U32_e32 1, killed $vgpr1, implicit $exec
303 ; CHECK-NEXT: $sgpr37 = SI_RESTORE_S32_FROM_VGPR $vgpr40, 5
304 ; CHECK-NEXT: $sgpr36 = SI_RESTORE_S32_FROM_VGPR $vgpr40, 4
305 ; CHECK-NEXT: $sgpr35 = SI_RESTORE_S32_FROM_VGPR $vgpr40, 3
306 ; CHECK-NEXT: $sgpr34 = SI_RESTORE_S32_FROM_VGPR $vgpr40, 2
307 ; CHECK-NEXT: $sgpr31 = SI_RESTORE_S32_FROM_VGPR $vgpr40, 1
308 ; CHECK-NEXT: $sgpr30 = SI_RESTORE_S32_FROM_VGPR $vgpr40, 0
309 ; CHECK-NEXT: $sgpr4_sgpr5 = S_OR_SAVEEXEC_B64 -1, implicit-def $exec, implicit-def dead $scc, implicit $exec
310 ; CHECK-NEXT: $vgpr40 = BUFFER_LOAD_DWORD_OFFSET $sgpr0_sgpr1_sgpr2_sgpr3, $sgpr32, 0, 0, 0, implicit $exec :: (load (s32) from %stack.0, addrspace 5)
311 ; CHECK-NEXT: $exec = S_MOV_B64 killed $sgpr4_sgpr5
312 ; CHECK-NEXT: SI_RETURN implicit $vgpr0
314 liveins: $sgpr30, $sgpr31, $sgpr34, $sgpr35, $sgpr36, $sgpr37, $vgpr0, $vgpr1, $vgpr63
316 $vgpr63 = SI_SPILL_S32_TO_VGPR killed $sgpr30, 0, $vgpr63
317 $vgpr63 = SI_SPILL_S32_TO_VGPR killed $sgpr31, 1, $vgpr63
318 $vgpr63 = SI_SPILL_S32_TO_VGPR killed $sgpr34, 2, $vgpr63
319 $vgpr63 = SI_SPILL_S32_TO_VGPR killed $sgpr35, 3, $vgpr63
320 $vgpr63 = SI_SPILL_S32_TO_VGPR killed $sgpr36, 4, $vgpr63
321 $vgpr63 = SI_SPILL_S32_TO_VGPR killed $sgpr37, 5, $vgpr63
322 undef %0.sub0:vreg_64 = COPY $vgpr0
323 %0.sub1:vreg_64 = COPY $vgpr1
324 ADJCALLSTACKUP 0, 0, implicit-def dead $scc, implicit-def $sgpr32, implicit $sgpr32
325 renamable $sgpr34_sgpr35 = S_MOV_B64 $exec
328 liveins: $vgpr63, $sgpr34_sgpr35
330 renamable $sgpr4 = V_READFIRSTLANE_B32 %0.sub0, implicit $exec
331 renamable $sgpr5 = V_READFIRSTLANE_B32 %0.sub1, implicit $exec
332 renamable $vcc = V_CMP_EQ_U64_e64 $sgpr4_sgpr5, %0, implicit $exec
333 renamable $sgpr36_sgpr37 = S_AND_SAVEEXEC_B64 killed renamable $vcc, implicit-def $exec, implicit-def dead $scc, implicit $exec
336 liveins: $vgpr63, $sgpr4_sgpr5:0x000000000000000F, $sgpr34_sgpr35, $sgpr36_sgpr37
338 dead $sgpr30_sgpr31 = noconvergent SI_CALL killed renamable $sgpr4_sgpr5, 0, csr_amdgpu, implicit $sgpr0_sgpr1_sgpr2_sgpr3, implicit-def $vgpr0
339 %3:vgpr_32 = COPY $vgpr0
340 undef %0.sub0:vreg_64 = V_MOV_B32_e32 123, implicit $exec
341 $exec = S_XOR_B64_term $exec, killed renamable $sgpr36_sgpr37, implicit-def dead $scc
342 S_CBRANCH_EXECNZ %bb.1, implicit $exec
345 liveins: $vgpr63, $sgpr34_sgpr35
347 $exec = S_MOV_B64_term killed renamable $sgpr34_sgpr35
352 ADJCALLSTACKDOWN 0, 0, implicit-def dead $scc, implicit-def $sgpr32, implicit $sgpr32
353 %6:vgpr_32 = V_ADD_U32_e32 1, %3, implicit $exec
355 $sgpr37 = SI_RESTORE_S32_FROM_VGPR $vgpr63, 5
356 $sgpr36 = SI_RESTORE_S32_FROM_VGPR $vgpr63, 4
357 $sgpr35 = SI_RESTORE_S32_FROM_VGPR $vgpr63, 3
358 $sgpr34 = SI_RESTORE_S32_FROM_VGPR $vgpr63, 2
359 $sgpr31 = SI_RESTORE_S32_FROM_VGPR $vgpr63, 1
360 $sgpr30 = SI_RESTORE_S32_FROM_VGPR $vgpr63, 0
361 SI_RETURN implicit $vgpr0