1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx906 -verify-coalescing -verify-machineinstrs -amdgpu-enable-rewrite-partial-reg-uses=false -start-before=register-coalescer -stop-after=machine-scheduler -o - %s | FileCheck %s
4 # Tests that break due to the handling of partially undef registers
5 # when whole register identity copies are erased.
7 # Make sure there is no verifier error after
8 # RenameIndepependentSubregs processes this. The coalescer would
9 # remove the identity copy in %bb.1, and leave behind a dummy interval
10 # across bb.1 with no corresponding value anywhere in the function.
13 name: identity_copy_undef_subrange
14 tracksRegLiveness: true
16 ; CHECK-LABEL: name: identity_copy_undef_subrange
18 ; CHECK-NEXT: successors: %bb.1(0x80000000)
19 ; CHECK-NEXT: liveins: $vgpr0
21 ; CHECK-NEXT: undef [[COPY:%[0-9]+]].sub1:vreg_64 = COPY $vgpr0
24 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
26 ; CHECK-NEXT: S_CBRANCH_EXECNZ %bb.1, implicit $exec
27 ; CHECK-NEXT: S_BRANCH %bb.2
30 ; CHECK-NEXT: successors: %bb.1(0x80000000)
32 ; CHECK-NEXT: undef [[COPY:%[0-9]+]].sub1:vreg_64 = nofpexcept V_CEIL_F32_e32 [[COPY]].sub1, implicit $mode, implicit $exec
33 ; CHECK-NEXT: S_BRANCH %bb.1
37 undef %0.sub1:vreg_64 = COPY killed $vgpr0
40 successors: %bb.2, %bb.1
43 S_CBRANCH_EXECNZ %bb.1, implicit $exec
47 undef %0.sub1:vreg_64 = nofpexcept V_CEIL_F32_e32 killed %0.sub1, implicit $mode, implicit $exec
52 # Test another use of the register inside the block.
54 name: identity_copy_undef_subrange_other_uses0
55 tracksRegLiveness: true
57 ; CHECK-LABEL: name: identity_copy_undef_subrange_other_uses0
59 ; CHECK-NEXT: successors: %bb.1(0x80000000)
60 ; CHECK-NEXT: liveins: $vgpr0
62 ; CHECK-NEXT: undef [[COPY:%[0-9]+]].sub1:vreg_64 = COPY $vgpr0
65 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
67 ; CHECK-NEXT: S_NOP 0, implicit undef [[COPY]].sub0
68 ; CHECK-NEXT: S_NOP 0, implicit undef [[COPY]].sub0
69 ; CHECK-NEXT: S_CBRANCH_EXECNZ %bb.1, implicit $exec
70 ; CHECK-NEXT: S_BRANCH %bb.2
73 ; CHECK-NEXT: successors: %bb.1(0x80000000)
75 ; CHECK-NEXT: undef [[COPY:%[0-9]+]].sub1:vreg_64 = nofpexcept V_CEIL_F32_e32 [[COPY]].sub1, implicit $mode, implicit $exec
76 ; CHECK-NEXT: S_BRANCH %bb.1
79 undef %0.sub1:vreg_64 = COPY killed $vgpr0
82 successors: %bb.2, %bb.1
85 S_NOP 0, implicit %0.sub0
86 S_NOP 0, implicit %0.sub0
87 S_CBRANCH_EXECNZ %bb.1, implicit $exec
91 undef %0.sub1:vreg_64 = nofpexcept V_CEIL_F32_e32 killed %0.sub1, implicit $mode, implicit $exec
97 name: second_identity_copy
98 tracksRegLiveness: true
100 ; CHECK-LABEL: name: second_identity_copy
102 ; CHECK-NEXT: successors: %bb.1(0x80000000)
103 ; CHECK-NEXT: liveins: $vgpr0
105 ; CHECK-NEXT: undef [[COPY:%[0-9]+]].sub1:vreg_64 = COPY $vgpr0
108 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
110 ; CHECK-NEXT: S_CBRANCH_EXECNZ %bb.1, implicit $exec
111 ; CHECK-NEXT: S_BRANCH %bb.2
114 ; CHECK-NEXT: successors: %bb.1(0x80000000)
116 ; CHECK-NEXT: undef [[COPY:%[0-9]+]].sub1:vreg_64 = nofpexcept V_MUL_F32_e32 0, [[COPY]].sub1, implicit $mode, implicit $exec
117 ; CHECK-NEXT: S_BRANCH %bb.1
121 undef %0.sub1:vreg_64 = COPY killed $vgpr0
124 successors: %bb.2, %bb.1
126 %0:vreg_64 = COPY killed %0
128 S_CBRANCH_EXECNZ %bb.1, implicit $exec
132 undef %0.sub1:vreg_64 = nofpexcept V_MUL_F32_e32 0, killed %0.sub1, implicit $mode, implicit $exec
138 name: second_identity_copy_undef_lane_outblock
139 tracksRegLiveness: true
141 ; CHECK-LABEL: name: second_identity_copy_undef_lane_outblock
143 ; CHECK-NEXT: successors: %bb.1(0x80000000)
144 ; CHECK-NEXT: liveins: $vgpr0
146 ; CHECK-NEXT: undef [[COPY:%[0-9]+]].sub1:vreg_64 = COPY $vgpr0
149 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
151 ; CHECK-NEXT: S_CBRANCH_EXECNZ %bb.1, implicit $exec
152 ; CHECK-NEXT: S_BRANCH %bb.2
155 ; CHECK-NEXT: successors: %bb.1(0x80000000)
157 ; CHECK-NEXT: [[COPY:%[0-9]+]].sub1:vreg_64 = nofpexcept V_MUL_F32_e32 0, [[COPY]].sub1, implicit $mode, implicit $exec
158 ; CHECK-NEXT: S_BRANCH %bb.1
162 undef %0.sub1:vreg_64 = COPY killed $vgpr0
165 successors: %bb.2, %bb.1
167 %0:vreg_64 = COPY killed %0
169 S_CBRANCH_EXECNZ %bb.1, implicit $exec
173 %0.sub1:vreg_64 = nofpexcept V_MUL_F32_e32 0, killed %0.sub1, implicit $mode, implicit $exec
178 # The same value number appears in multiple blocks
180 name: identity_copy_undef_subrange_null_vninfo_to_remove
181 tracksRegLiveness: true
183 ; CHECK-LABEL: name: identity_copy_undef_subrange_null_vninfo_to_remove
185 ; CHECK-NEXT: successors: %bb.1(0x80000000)
186 ; CHECK-NEXT: liveins: $vgpr0
188 ; CHECK-NEXT: undef [[COPY:%[0-9]+]].sub1:vreg_64 = COPY $vgpr0
191 ; CHECK-NEXT: successors: %bb.3(0x40000000), %bb.2(0x40000000)
193 ; CHECK-NEXT: S_CBRANCH_EXECNZ %bb.3, implicit $exec
196 ; CHECK-NEXT: successors: %bb.1(0x80000000)
198 ; CHECK-NEXT: S_NOP 0, implicit undef [[COPY]].sub0
199 ; CHECK-NEXT: undef [[COPY:%[0-9]+]].sub1:vreg_64 = nofpexcept V_CEIL_F32_e32 [[COPY]].sub1, implicit $mode, implicit $exec
200 ; CHECK-NEXT: S_BRANCH %bb.1
203 ; CHECK-NEXT: S_NOP 0, implicit undef [[COPY]].sub0
207 undef %0.sub1:vreg_64 = COPY killed $vgpr0
211 S_CBRANCH_EXECNZ %bb.3, implicit $exec
214 S_NOP 0, implicit %0.sub0
215 undef %0.sub1:vreg_64 = nofpexcept V_CEIL_F32_e32 killed %0.sub1, implicit $mode, implicit $exec
219 S_NOP 0, implicit %0.sub0
224 name: undef_copy_self_loop0
225 tracksRegLiveness: true
227 ; CHECK-LABEL: name: undef_copy_self_loop0
229 ; CHECK-NEXT: successors: %bb.1(0x80000000)
230 ; CHECK-NEXT: liveins: $vgpr0
232 ; CHECK-NEXT: undef [[COPY:%[0-9]+]].sub1:vreg_64 = COPY $vgpr0
235 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
237 ; CHECK-NEXT: S_CBRANCH_EXECNZ %bb.1, implicit $exec
240 ; CHECK-NEXT: S_NOP 0, implicit undef [[COPY]].sub0
244 undef %0.sub1:vreg_64 = COPY killed $vgpr0
248 S_CBRANCH_EXECNZ %bb.1, implicit $exec
251 S_NOP 0, implicit %0.sub0
256 name: undef_copy_self_loop1
257 tracksRegLiveness: true
259 ; CHECK-LABEL: name: undef_copy_self_loop1
261 ; CHECK-NEXT: successors: %bb.1(0x80000000)
262 ; CHECK-NEXT: liveins: $vgpr0
264 ; CHECK-NEXT: undef [[COPY:%[0-9]+]].sub1:vreg_64 = COPY $vgpr0
267 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
269 ; CHECK-NEXT: S_CBRANCH_EXECNZ %bb.1, implicit $exec
272 ; CHECK-NEXT: S_NOP 0, implicit [[COPY]].sub1
276 undef %0.sub1:vreg_64 = COPY killed $vgpr0
280 S_CBRANCH_EXECNZ %bb.1, implicit $exec
283 S_NOP 0, implicit %0.sub1
287 # The coalescing of the %0 = %2 COPY in %bb.2 needs to prune the dead
288 # phi range across %bb.1 after it is erased.
290 name: prune_subrange_phi_value_0
291 tracksRegLiveness: true
293 ; CHECK-LABEL: name: prune_subrange_phi_value_0
295 ; CHECK-NEXT: successors: %bb.1(0x80000000)
296 ; CHECK-NEXT: liveins: $vgpr0
298 ; CHECK-NEXT: dead undef [[COPY:%[0-9]+]].sub1:vreg_64 = COPY $vgpr0
301 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
303 ; CHECK-NEXT: S_CBRANCH_EXECNZ %bb.1, implicit $exec
304 ; CHECK-NEXT: S_BRANCH %bb.2
307 ; CHECK-NEXT: successors: %bb.1(0x80000000)
309 ; CHECK-NEXT: S_BRANCH %bb.1
313 undef %0.sub1:vreg_64 = COPY killed $vgpr0
316 successors: %bb.2, %bb.1
318 %1:vreg_64 = COPY killed %0
320 S_CBRANCH_EXECNZ %bb.1, implicit $exec
324 undef %2.sub1:vreg_64 = COPY %0.sub1
325 %0:vreg_64 = COPY killed %2
331 name: prune_subrange_phi_value_0_0
332 tracksRegLiveness: true
334 ; CHECK-LABEL: name: prune_subrange_phi_value_0_0
336 ; CHECK-NEXT: successors: %bb.1(0x80000000)
337 ; CHECK-NEXT: liveins: $vgpr0
339 ; CHECK-NEXT: dead undef [[COPY:%[0-9]+]].sub1:vreg_64 = COPY $vgpr0
342 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
344 ; CHECK-NEXT: S_CBRANCH_EXECNZ %bb.1, implicit $exec
345 ; CHECK-NEXT: S_BRANCH %bb.2
348 ; CHECK-NEXT: successors: %bb.1(0x80000000)
350 ; CHECK-NEXT: S_BRANCH %bb.1
354 undef %0.sub1:vreg_64 = COPY killed $vgpr0
357 successors: %bb.2, %bb.1
359 %1:vreg_64 = COPY killed %0
361 S_CBRANCH_EXECNZ %bb.1, implicit $exec
365 undef %0.sub1:vreg_64 = COPY %0.sub1
371 name: prune_subrange_phi_value_0_1
372 tracksRegLiveness: true
374 ; CHECK-LABEL: name: prune_subrange_phi_value_0_1
376 ; CHECK-NEXT: successors: %bb.1(0x80000000)
377 ; CHECK-NEXT: liveins: $vgpr0
379 ; CHECK-NEXT: dead undef [[COPY:%[0-9]+]].sub1:vreg_64 = COPY $vgpr0
382 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
384 ; CHECK-NEXT: S_CBRANCH_EXECNZ %bb.1, implicit $exec
385 ; CHECK-NEXT: S_BRANCH %bb.2
388 ; CHECK-NEXT: successors: %bb.1(0x80000000)
390 ; CHECK-NEXT: S_BRANCH %bb.1
394 undef %0.sub1:vreg_64 = COPY killed $vgpr0
397 successors: %bb.2, %bb.1
399 %1:vreg_64 = COPY killed %0
401 S_CBRANCH_EXECNZ %bb.1, implicit $exec
409 # Variant of testcase that asserts since there wasn't already an
410 # incoming segment at the erased copy, and no valid end point.
412 name: prune_subrange_phi_value_1
413 tracksRegLiveness: true
415 ; CHECK-LABEL: name: prune_subrange_phi_value_1
417 ; CHECK-NEXT: successors: %bb.1(0x80000000)
418 ; CHECK-NEXT: liveins: $vgpr0
420 ; CHECK-NEXT: undef [[COPY:%[0-9]+]].sub1:vreg_64 = COPY $vgpr0
423 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
425 ; CHECK-NEXT: S_CBRANCH_EXECNZ %bb.1, implicit $exec
426 ; CHECK-NEXT: S_BRANCH %bb.2
429 ; CHECK-NEXT: successors: %bb.1(0x80000000)
431 ; CHECK-NEXT: undef [[COPY:%[0-9]+]].sub1:vreg_64 = nofpexcept V_CEIL_F32_e32 [[COPY]].sub1, implicit $mode, implicit $exec
432 ; CHECK-NEXT: S_BRANCH %bb.1
436 undef %0.sub1:vreg_64 = COPY killed $vgpr0
439 successors: %bb.2, %bb.1
441 %0:vreg_64 = COPY killed %0
442 S_CBRANCH_EXECNZ %bb.1, implicit $exec
446 undef %1.sub1:vreg_64 = nofpexcept V_CEIL_F32_e32 killed %0.sub1, implicit $mode, implicit $exec
447 %0:vreg_64 = COPY killed %1
453 name: prune_subrange_phi_value_2
454 tracksRegLiveness: true
456 ; CHECK-LABEL: name: prune_subrange_phi_value_2
458 ; CHECK-NEXT: successors: %bb.1(0x80000000)
459 ; CHECK-NEXT: liveins: $vgpr0
461 ; CHECK-NEXT: undef [[COPY:%[0-9]+]].sub1:vreg_64 = COPY $vgpr0
464 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
466 ; CHECK-NEXT: S_CBRANCH_EXECNZ %bb.1, implicit $exec
467 ; CHECK-NEXT: S_BRANCH %bb.2
470 ; CHECK-NEXT: successors: %bb.1(0x80000000)
472 ; CHECK-NEXT: [[COPY:%[0-9]+]].sub1:vreg_64 = nofpexcept V_CEIL_F32_e32 [[COPY]].sub1, implicit $mode, implicit $exec
473 ; CHECK-NEXT: S_BRANCH %bb.1
477 undef %0.sub1:vreg_64 = COPY killed $vgpr0
480 successors: %bb.2, %bb.1
482 %0:vreg_64 = COPY killed %0
483 S_CBRANCH_EXECNZ %bb.1, implicit $exec
487 %0.sub1:vreg_64 = nofpexcept V_CEIL_F32_e32 %0.sub1, implicit $mode, implicit $exec