1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -march=amdgcn -mcpu=gfx1010 -verify-machineinstrs -run-pass=postra-machine-sink -mattr=-wavefrontsize32,+wavefrontsize64 -o - %s | FileCheck -check-prefixes=GFX10 %s
4 # Ensure that PostRA Machine Sink does not sink instructions
5 # past block prologues which would overwrite their uses.
8 # Make sure COPY to $sgpr9 is not sunk after S_AND_SAVEEXEC_B64.
11 tracksRegLiveness: true
14 - { reg: '$sgpr4', virtual-reg: '' }
16 ; GFX10-LABEL: name: _amdgpu_ps_main
18 ; GFX10-NEXT: successors: %bb.1(0x80000000)
19 ; GFX10-NEXT: liveins: $sgpr4
21 ; GFX10-NEXT: renamable $sgpr9 = COPY $sgpr4
22 ; GFX10-NEXT: renamable $vgpr5 = IMPLICIT_DEF
23 ; GFX10-NEXT: renamable $sgpr0_sgpr1 = nofpexcept V_CMP_NGT_F32_e64 0, 0, 0, $vgpr5, 0, implicit $mode, implicit $exec
24 ; GFX10-NEXT: S_BRANCH %bb.1
27 ; GFX10-NEXT: successors: %bb.2(0x40000000), %bb.3(0x40000000)
28 ; GFX10-NEXT: liveins: $sgpr6, $sgpr9, $sgpr0_sgpr1
30 ; GFX10-NEXT: $sgpr4_sgpr5 = S_AND_SAVEEXEC_B64 $sgpr0_sgpr1, implicit-def $exec, implicit-def $scc, implicit $exec
31 ; GFX10-NEXT: renamable $sgpr14_sgpr15 = S_XOR_B64 $exec, killed renamable $sgpr4_sgpr5, implicit-def dead $scc
32 ; GFX10-NEXT: S_CBRANCH_EXECZ %bb.3, implicit $exec
33 ; GFX10-NEXT: S_BRANCH %bb.2
36 ; GFX10-NEXT: successors: %bb.3(0x80000000)
37 ; GFX10-NEXT: liveins: $sgpr6
39 ; GFX10-NEXT: $m0 = COPY killed renamable $sgpr6
40 ; GFX10-NEXT: S_BRANCH %bb.3
43 ; GFX10-NEXT: S_ENDPGM 0
45 successors: %bb.1(0x80000000)
48 renamable $sgpr9 = COPY $sgpr4
49 renamable $vgpr5 = IMPLICIT_DEF
50 renamable $sgpr0_sgpr1 = nofpexcept V_CMP_NGT_F32_e64 0, 0, 0, $vgpr5, 0, implicit $mode, implicit $exec
54 successors: %bb.2(0x40000000), %bb.8(0x40000000)
55 liveins: $sgpr6, $sgpr9, $sgpr0_sgpr1
57 $sgpr4_sgpr5 = S_AND_SAVEEXEC_B64 $sgpr0_sgpr1, implicit-def $exec, implicit-def $scc, implicit $exec
58 renamable $sgpr14_sgpr15 = S_XOR_B64 $exec, killed renamable $sgpr4_sgpr5, implicit-def dead $scc
59 S_CBRANCH_EXECZ %bb.8, implicit $exec
63 successors: %bb.8(0x40000000)
66 $m0 = COPY killed renamable $sgpr6
75 # Make sure COPY to $sgpr0_sgpr1 is not sunk after S_AND_SAVEEXEC_B64.
76 name: _amdgpu_ps_main2
78 tracksRegLiveness: true
81 - { reg: '$sgpr4', virtual-reg: '' }
82 - { reg: '$sgpr6_sgpr7', virtual-reg: '' }
84 ; GFX10-LABEL: name: _amdgpu_ps_main2
86 ; GFX10-NEXT: successors: %bb.1(0x80000000)
87 ; GFX10-NEXT: liveins: $sgpr4, $sgpr6_sgpr7
89 ; GFX10-NEXT: renamable $sgpr9 = COPY $sgpr4
90 ; GFX10-NEXT: renamable $vgpr5 = IMPLICIT_DEF
91 ; GFX10-NEXT: renamable $sgpr0_sgpr1 = COPY $sgpr6_sgpr7
92 ; GFX10-NEXT: S_BRANCH %bb.1
95 ; GFX10-NEXT: successors: %bb.2(0x40000000), %bb.3(0x40000000)
96 ; GFX10-NEXT: liveins: $sgpr6, $sgpr9, $sgpr0_sgpr1
98 ; GFX10-NEXT: $sgpr4_sgpr5 = S_AND_SAVEEXEC_B64 $sgpr0_sgpr1, implicit-def $exec, implicit-def $scc, implicit $exec
99 ; GFX10-NEXT: renamable $sgpr14_sgpr15 = S_XOR_B64 $exec, killed renamable $sgpr4_sgpr5, implicit-def dead $scc
100 ; GFX10-NEXT: S_CBRANCH_EXECZ %bb.3, implicit $exec
101 ; GFX10-NEXT: S_BRANCH %bb.2
104 ; GFX10-NEXT: successors: %bb.3(0x80000000)
105 ; GFX10-NEXT: liveins: $sgpr6
107 ; GFX10-NEXT: $m0 = COPY killed renamable $sgpr6
108 ; GFX10-NEXT: S_BRANCH %bb.3
111 ; GFX10-NEXT: S_ENDPGM 0
113 successors: %bb.1(0x80000000)
114 liveins: $sgpr4, $sgpr6_sgpr7
116 renamable $sgpr9 = COPY $sgpr4
117 renamable $vgpr5 = IMPLICIT_DEF
118 renamable $sgpr0_sgpr1 = COPY $sgpr6_sgpr7
122 successors: %bb.2(0x40000000), %bb.8(0x40000000)
123 liveins: $sgpr6, $sgpr9, $sgpr0_sgpr1
125 $sgpr4_sgpr5 = S_AND_SAVEEXEC_B64 $sgpr0_sgpr1, implicit-def $exec, implicit-def $scc, implicit $exec
126 renamable $sgpr14_sgpr15 = S_XOR_B64 $exec, killed renamable $sgpr4_sgpr5, implicit-def dead $scc
127 S_CBRANCH_EXECZ %bb.8, implicit $exec
131 successors: %bb.8(0x40000000)
134 $m0 = COPY killed renamable $sgpr6
143 # Make sure COPY to $sgpr2_sgpr3 is not sunk after S_AND_SAVEEXEC_B32.
144 name: _amdgpu_ps_main3
146 tracksRegLiveness: true
149 - { reg: '$sgpr6_sgpr7', virtual-reg: '' }
150 - { reg: '$sgpr8', virtual-reg: '' }
152 ; GFX10-LABEL: name: _amdgpu_ps_main3
154 ; GFX10-NEXT: successors: %bb.1(0x80000000)
155 ; GFX10-NEXT: liveins: $sgpr6_sgpr7, $sgpr8
157 ; GFX10-NEXT: renamable $vgpr5 = IMPLICIT_DEF
158 ; GFX10-NEXT: renamable $sgpr0_sgpr1 = IMPLICIT_DEF
159 ; GFX10-NEXT: renamable $sgpr2_sgpr3 = COPY $sgpr6_sgpr7
160 ; GFX10-NEXT: S_BRANCH %bb.1
163 ; GFX10-NEXT: successors: %bb.2(0x40000000), %bb.3(0x40000000)
164 ; GFX10-NEXT: liveins: $sgpr6, $sgpr8, $sgpr0_sgpr1, $sgpr2_sgpr3
166 ; GFX10-NEXT: $sgpr2 = S_AND_SAVEEXEC_B32 $sgpr8, implicit-def $exec, implicit-def $scc, implicit $exec
167 ; GFX10-NEXT: $sgpr4_sgpr5 = S_AND_SAVEEXEC_B64 $sgpr0_sgpr1, implicit-def $exec, implicit-def $scc, implicit $exec
168 ; GFX10-NEXT: renamable $sgpr14_sgpr15 = S_XOR_B64 $exec, killed renamable $sgpr4_sgpr5, implicit-def dead $scc
169 ; GFX10-NEXT: S_NOP 0, implicit $sgpr2_sgpr3
170 ; GFX10-NEXT: S_CBRANCH_EXECZ %bb.3, implicit $exec
171 ; GFX10-NEXT: S_BRANCH %bb.2
174 ; GFX10-NEXT: successors: %bb.3(0x80000000)
175 ; GFX10-NEXT: liveins: $sgpr6
177 ; GFX10-NEXT: $m0 = COPY killed renamable $sgpr6
178 ; GFX10-NEXT: S_BRANCH %bb.3
181 ; GFX10-NEXT: S_ENDPGM 0
183 successors: %bb.1(0x80000000)
184 liveins: $sgpr6_sgpr7, $sgpr8
186 renamable $vgpr5 = IMPLICIT_DEF
187 renamable $sgpr0_sgpr1 = IMPLICIT_DEF
188 renamable $sgpr2_sgpr3 = COPY $sgpr6_sgpr7
192 successors: %bb.2(0x40000000), %bb.8(0x40000000)
193 liveins: $sgpr6, $sgpr8, $sgpr0_sgpr1, $sgpr2_sgpr3
195 $sgpr2 = S_AND_SAVEEXEC_B32 $sgpr8, implicit-def $exec, implicit-def $scc, implicit $exec
196 $sgpr4_sgpr5 = S_AND_SAVEEXEC_B64 $sgpr0_sgpr1, implicit-def $exec, implicit-def $scc, implicit $exec
197 renamable $sgpr14_sgpr15 = S_XOR_B64 $exec, killed renamable $sgpr4_sgpr5, implicit-def dead $scc
198 S_NOP 0, implicit $sgpr2_sgpr3
199 S_CBRANCH_EXECZ %bb.8, implicit $exec
203 successors: %bb.8(0x40000000)
206 $m0 = COPY killed renamable $sgpr6
216 name: machinesink_loop_vgpr_out_of_divergent_loop_postra
217 tracksRegLiveness: true
219 ; GFX10-LABEL: name: machinesink_loop_vgpr_out_of_divergent_loop_postra
221 ; GFX10-NEXT: successors: %bb.1(0x80000000)
222 ; GFX10-NEXT: liveins: $sgpr8, $vgpr0, $vgpr1
226 ; GFX10-NEXT: successors: %bb.7(0x40000000), %bb.2(0x40000000)
227 ; GFX10-NEXT: liveins: $sgpr8, $vgpr0
229 ; GFX10-NEXT: $sgpr4 = S_AND_SAVEEXEC_B32 $sgpr8, implicit-def $exec, implicit-def $scc, implicit $exec
230 ; GFX10-NEXT: renamable $sgpr4 = S_XOR_B32 $exec_lo, killed renamable $sgpr4, implicit-def dead $scc
231 ; GFX10-NEXT: S_CBRANCH_EXECZ %bb.7, implicit $exec
234 ; GFX10-NEXT: successors: %bb.3(0x80000000)
235 ; GFX10-NEXT: liveins: $sgpr4, $sgpr8, $vgpr0
239 ; GFX10-NEXT: successors: %bb.5(0x40000000), %bb.4(0x40000000)
240 ; GFX10-NEXT: liveins: $sgpr4, $sgpr8, $vgpr0
242 ; GFX10-NEXT: $sgpr5 = S_AND_SAVEEXEC_B32 $sgpr8, implicit-def $exec, implicit-def $scc, implicit $exec
243 ; GFX10-NEXT: renamable $sgpr5 = S_XOR_B32 $exec_lo, killed renamable $sgpr5, implicit-def dead $scc
244 ; GFX10-NEXT: S_CBRANCH_EXECZ %bb.5, implicit $exec
245 ; GFX10-NEXT: S_BRANCH %bb.4
248 ; GFX10-NEXT: successors: %bb.5(0x80000000)
249 ; GFX10-NEXT: liveins: $sgpr4, $sgpr5, $sgpr8, $vgpr0
253 ; GFX10-NEXT: successors: %bb.3(0x40000000), %bb.6(0x40000000)
254 ; GFX10-NEXT: liveins: $sgpr4, $sgpr5, $sgpr8, $vgpr0
256 ; GFX10-NEXT: renamable $vgpr1 = V_ADD_U32_e64 $sgpr8, $vgpr0, 0, implicit $exec
257 ; GFX10-NEXT: renamable $sgpr5 = S_AND_B32 $exec_lo, killed renamable $sgpr5, implicit-def $scc
258 ; GFX10-NEXT: renamable $sgpr5 = S_OR_B32 killed renamable $sgpr5, renamable $sgpr4, implicit-def $scc
259 ; GFX10-NEXT: $exec_lo = S_ANDN2_B32 $exec_lo, renamable $sgpr5, implicit-def $scc
260 ; GFX10-NEXT: S_CBRANCH_EXECNZ %bb.3, implicit $exec
261 ; GFX10-NEXT: S_BRANCH %bb.6
264 ; GFX10-NEXT: successors: %bb.3(0x80000000)
265 ; GFX10-NEXT: liveins: $sgpr4, $sgpr5, $sgpr8, $vgpr0, $vgpr1
267 ; GFX10-NEXT: $exec_lo = S_OR_B32 $exec_lo, killed renamable $sgpr5, implicit-def $scc
268 ; GFX10-NEXT: INLINEASM &"", 1 /* sideeffect attdialect */, implicit killed renamable $vgpr1
269 ; GFX10-NEXT: S_BRANCH %bb.3
272 ; GFX10-NEXT: successors: %bb.1(0x40000000), %bb.8(0x40000000)
273 ; GFX10-NEXT: liveins: $sgpr4, $sgpr8, $vgpr0
275 ; GFX10-NEXT: $exec_lo = S_ANDN2_B32 $exec_lo, killed renamable $sgpr4, implicit-def $scc
276 ; GFX10-NEXT: S_CBRANCH_EXECNZ %bb.1, implicit $exec
279 ; GFX10-NEXT: successors: %bb.9(0x80000000)
283 ; GFX10-NEXT: successors: %bb.9(0x40000000), %bb.10(0x40000000)
285 ; GFX10-NEXT: S_CBRANCH_VCCNZ %bb.9, implicit undef $vcc
286 ; GFX10-NEXT: S_BRANCH %bb.10
289 ; GFX10-NEXT: SI_RETURN
291 liveins: $sgpr8, $vgpr0, $vgpr1
294 liveins: $sgpr8, $vgpr0
296 $sgpr4 = S_AND_SAVEEXEC_B32 $sgpr8, implicit-def $exec, implicit-def $scc, implicit $exec
297 renamable $sgpr4 = S_XOR_B32 $exec_lo, killed renamable $sgpr4, implicit-def dead $scc
298 S_CBRANCH_EXECZ %bb.6, implicit $exec
301 liveins: $sgpr4, $sgpr8, $vgpr0
305 liveins: $sgpr4, $sgpr8, $vgpr0
307 $sgpr5 = S_AND_SAVEEXEC_B32 $sgpr8, implicit-def $exec, implicit-def $scc, implicit $exec
308 renamable $sgpr5 = S_XOR_B32 $exec_lo, killed renamable $sgpr5, implicit-def dead $scc
309 S_CBRANCH_EXECZ %bb.4, implicit $exec
313 liveins: $sgpr4, $sgpr5, $sgpr8, $vgpr0
317 liveins: $sgpr4, $sgpr5, $sgpr8, $vgpr0
319 renamable $vgpr1 = V_ADD_U32_e64 $sgpr8, $vgpr0, 0, implicit $exec
320 renamable $sgpr5 = S_AND_B32 $exec_lo, killed renamable $sgpr5, implicit-def $scc
321 renamable $sgpr5 = S_OR_B32 killed renamable $sgpr5, renamable $sgpr4, implicit-def $scc
323 $exec_lo = S_ANDN2_B32 $exec_lo, renamable $sgpr5, implicit-def $scc
324 S_CBRANCH_EXECNZ %bb.2, implicit $exec
328 liveins: $sgpr4, $sgpr5, $sgpr8, $vgpr0, $vgpr1
330 $exec_lo = S_OR_B32 $exec_lo, killed renamable $sgpr5, implicit-def $scc
331 INLINEASM &"", 1 /* sideeffect attdialect */, implicit killed renamable $vgpr1
335 liveins: $sgpr4, $sgpr8, $vgpr0
337 $exec_lo = S_ANDN2_B32 $exec_lo, killed renamable $sgpr4, implicit-def $scc
338 S_CBRANCH_EXECNZ %bb.1, implicit $exec
343 S_CBRANCH_VCCNZ %bb.7, implicit undef $vcc
352 name: machinesink_loop_sgpr_out_of_divergent_loop_postra
353 tracksRegLiveness: true
355 ; GFX10-LABEL: name: machinesink_loop_sgpr_out_of_divergent_loop_postra
357 ; GFX10-NEXT: successors: %bb.1(0x80000000)
358 ; GFX10-NEXT: liveins: $sgpr8, $sgpr9, $sgpr10
362 ; GFX10-NEXT: successors: %bb.7(0x40000000), %bb.2(0x40000000)
363 ; GFX10-NEXT: liveins: $sgpr8, $sgpr9
365 ; GFX10-NEXT: $sgpr4 = S_AND_SAVEEXEC_B32 $sgpr9, implicit-def $exec, implicit-def $scc, implicit $exec
366 ; GFX10-NEXT: renamable $sgpr4 = S_XOR_B32 $exec_lo, killed renamable $sgpr4, implicit-def dead $scc
367 ; GFX10-NEXT: S_CBRANCH_EXECZ %bb.7, implicit $exec
370 ; GFX10-NEXT: successors: %bb.3(0x80000000)
371 ; GFX10-NEXT: liveins: $sgpr4, $sgpr8, $sgpr9
375 ; GFX10-NEXT: successors: %bb.5(0x40000000), %bb.4(0x40000000)
376 ; GFX10-NEXT: liveins: $sgpr4, $sgpr8, $sgpr9
378 ; GFX10-NEXT: $sgpr5 = S_AND_SAVEEXEC_B32 $sgpr9, implicit-def $exec, implicit-def $scc, implicit $exec
379 ; GFX10-NEXT: renamable $sgpr5 = S_XOR_B32 $exec_lo, killed renamable $sgpr5, implicit-def dead $scc
380 ; GFX10-NEXT: S_CBRANCH_EXECZ %bb.5, implicit $exec
381 ; GFX10-NEXT: S_BRANCH %bb.4
384 ; GFX10-NEXT: successors: %bb.5(0x80000000)
385 ; GFX10-NEXT: liveins: $sgpr4, $sgpr5, $sgpr8, $sgpr9
389 ; GFX10-NEXT: successors: %bb.3(0x40000000), %bb.6(0x40000000)
390 ; GFX10-NEXT: liveins: $sgpr4, $sgpr5, $sgpr8, $sgpr9
392 ; GFX10-NEXT: renamable $sgpr6 = S_ADD_I32 renamable $sgpr8, renamable $sgpr9, implicit-def dead $scc
393 ; GFX10-NEXT: renamable $sgpr5 = S_AND_B32 $exec_lo, killed renamable $sgpr5, implicit-def $scc
394 ; GFX10-NEXT: renamable $sgpr5 = S_OR_B32 killed renamable $sgpr5, renamable $sgpr4, implicit-def $scc
395 ; GFX10-NEXT: INLINEASM &"", 1 /* sideeffect attdialect */
396 ; GFX10-NEXT: $exec_lo = S_ANDN2_B32 $exec_lo, renamable $sgpr5, implicit-def $scc
397 ; GFX10-NEXT: S_CBRANCH_EXECNZ %bb.3, implicit $exec
398 ; GFX10-NEXT: S_BRANCH %bb.6
401 ; GFX10-NEXT: successors: %bb.3(0x80000000)
402 ; GFX10-NEXT: liveins: $sgpr4, $sgpr5, $sgpr6, $sgpr8, $sgpr9
404 ; GFX10-NEXT: $exec_lo = S_OR_B32 $exec_lo, killed renamable $sgpr5, implicit-def $scc
405 ; GFX10-NEXT: INLINEASM &"", 1 /* sideeffect attdialect */, implicit killed renamable $sgpr6
406 ; GFX10-NEXT: S_BRANCH %bb.3
409 ; GFX10-NEXT: successors: %bb.1(0x40000000), %bb.8(0x40000000)
410 ; GFX10-NEXT: liveins: $sgpr4, $sgpr8, $sgpr9
412 ; GFX10-NEXT: $exec_lo = S_ANDN2_B32 $exec_lo, killed renamable $sgpr4, implicit-def $scc
413 ; GFX10-NEXT: S_CBRANCH_EXECNZ %bb.1, implicit $exec
416 ; GFX10-NEXT: successors: %bb.9(0x80000000)
420 ; GFX10-NEXT: successors: %bb.9(0x40000000), %bb.10(0x40000000)
422 ; GFX10-NEXT: S_CBRANCH_VCCNZ %bb.9, implicit undef $vcc
423 ; GFX10-NEXT: S_BRANCH %bb.10
426 ; GFX10-NEXT: SI_RETURN
428 liveins: $sgpr8, $sgpr9, $sgpr10
432 liveins: $sgpr8, $sgpr9
434 $sgpr4 = S_AND_SAVEEXEC_B32 $sgpr9, implicit-def $exec, implicit-def $scc, implicit $exec
435 renamable $sgpr4 = S_XOR_B32 $exec_lo, killed renamable $sgpr4, implicit-def dead $scc
436 S_CBRANCH_EXECZ %bb.6, implicit $exec
439 liveins: $sgpr4, $sgpr8, $sgpr9
443 liveins: $sgpr4, $sgpr8, $sgpr9
445 $sgpr5 = S_AND_SAVEEXEC_B32 $sgpr9, implicit-def $exec, implicit-def $scc, implicit $exec
446 renamable $sgpr5 = S_XOR_B32 $exec_lo, killed renamable $sgpr5, implicit-def dead $scc
447 S_CBRANCH_EXECZ %bb.4, implicit $exec
451 liveins: $sgpr4, $sgpr5, $sgpr8, $sgpr9
455 liveins: $sgpr4, $sgpr5, $sgpr8, $sgpr9
457 renamable $sgpr6 = S_ADD_I32 renamable $sgpr8, renamable $sgpr9, implicit-def dead $scc
458 renamable $sgpr5 = S_AND_B32 $exec_lo, killed renamable $sgpr5, implicit-def $scc
459 renamable $sgpr5 = S_OR_B32 killed renamable $sgpr5, renamable $sgpr4, implicit-def $scc
460 INLINEASM &"", 1 /* sideeffect attdialect */
461 $exec_lo = S_ANDN2_B32 $exec_lo, renamable $sgpr5, implicit-def $scc
462 S_CBRANCH_EXECNZ %bb.2, implicit $exec
466 liveins: $sgpr4, $sgpr5, $sgpr6, $sgpr8, $sgpr9
468 $exec_lo = S_OR_B32 $exec_lo, killed renamable $sgpr5, implicit-def $scc
469 INLINEASM &"", 1 /* sideeffect attdialect */, implicit killed renamable $sgpr6
473 liveins: $sgpr4, $sgpr8, $sgpr9
475 $exec_lo = S_ANDN2_B32 $exec_lo, killed renamable $sgpr4, implicit-def $scc
476 S_CBRANCH_EXECNZ %bb.1, implicit $exec
481 S_CBRANCH_VCCNZ %bb.7, implicit undef $vcc