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 -start-before=simple-register-coalescing -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: successors: %bb.1(0x80000000)
19 ; CHECK: liveins: $vgpr0
20 ; CHECK: undef %0.sub1:vreg_64 = COPY $vgpr0
22 ; CHECK: successors: %bb.2(0x40000000), %bb.1(0x40000000)
23 ; CHECK: S_CBRANCH_EXECNZ %bb.1, implicit $exec
24 ; CHECK: S_BRANCH %bb.2
26 ; CHECK: successors: %bb.1(0x80000000)
27 ; CHECK: undef %0.sub1:vreg_64 = nofpexcept V_CEIL_F32_e32 %0.sub1, implicit $mode, implicit $exec
28 ; CHECK: S_BRANCH %bb.1
32 undef %0.sub1:vreg_64 = COPY killed $vgpr0
35 successors: %bb.2, %bb.1
38 S_CBRANCH_EXECNZ %bb.1, implicit $exec
42 undef %0.sub1:vreg_64 = nofpexcept V_CEIL_F32_e32 killed %0.sub1, implicit $mode, implicit $exec
47 # Test another use of the register inside the block.
49 name: identity_copy_undef_subrange_other_uses0
50 tracksRegLiveness: true
52 ; CHECK-LABEL: name: identity_copy_undef_subrange_other_uses0
54 ; CHECK: successors: %bb.1(0x80000000)
55 ; CHECK: liveins: $vgpr0
56 ; CHECK: undef %0.sub1:vreg_64 = COPY $vgpr0
58 ; CHECK: successors: %bb.2(0x40000000), %bb.1(0x40000000)
59 ; CHECK: S_NOP 0, implicit undef %0.sub0
60 ; CHECK: S_NOP 0, implicit undef %0.sub0
61 ; CHECK: S_CBRANCH_EXECNZ %bb.1, implicit $exec
62 ; CHECK: S_BRANCH %bb.2
64 ; CHECK: successors: %bb.1(0x80000000)
65 ; CHECK: undef %0.sub1:vreg_64 = nofpexcept V_CEIL_F32_e32 %0.sub1, implicit $mode, implicit $exec
66 ; CHECK: S_BRANCH %bb.1
69 undef %0.sub1:vreg_64 = COPY killed $vgpr0
72 successors: %bb.2, %bb.1
75 S_NOP 0, implicit %0.sub0
76 S_NOP 0, implicit %0.sub0
77 S_CBRANCH_EXECNZ %bb.1, implicit $exec
81 undef %0.sub1:vreg_64 = nofpexcept V_CEIL_F32_e32 killed %0.sub1, implicit $mode, implicit $exec
87 name: second_identity_copy
88 tracksRegLiveness: true
90 ; CHECK-LABEL: name: second_identity_copy
92 ; CHECK: successors: %bb.1(0x80000000)
93 ; CHECK: liveins: $vgpr0
94 ; CHECK: undef %0.sub1:vreg_64 = COPY $vgpr0
96 ; CHECK: successors: %bb.2(0x40000000), %bb.1(0x40000000)
97 ; CHECK: S_CBRANCH_EXECNZ %bb.1, implicit $exec
98 ; CHECK: S_BRANCH %bb.2
100 ; CHECK: successors: %bb.1(0x80000000)
101 ; CHECK: undef %0.sub1:vreg_64 = nofpexcept V_MUL_F32_e32 0, %0.sub1, implicit $mode, implicit $exec
102 ; CHECK: S_BRANCH %bb.1
106 undef %0.sub1:vreg_64 = COPY killed $vgpr0
109 successors: %bb.2, %bb.1
111 %0:vreg_64 = COPY killed %0
113 S_CBRANCH_EXECNZ %bb.1, implicit $exec
117 undef %0.sub1:vreg_64 = nofpexcept V_MUL_F32_e32 0, killed %0.sub1, implicit $mode, implicit $exec
123 name: second_identity_copy_undef_lane_outblock
124 tracksRegLiveness: true
126 ; CHECK-LABEL: name: second_identity_copy_undef_lane_outblock
128 ; CHECK: successors: %bb.1(0x80000000)
129 ; CHECK: liveins: $vgpr0
130 ; CHECK: undef %0.sub1:vreg_64 = COPY $vgpr0
132 ; CHECK: successors: %bb.2(0x40000000), %bb.1(0x40000000)
133 ; CHECK: S_CBRANCH_EXECNZ %bb.1, implicit $exec
134 ; CHECK: S_BRANCH %bb.2
136 ; CHECK: successors: %bb.1(0x80000000)
137 ; CHECK: %0.sub1:vreg_64 = nofpexcept V_MUL_F32_e32 0, %0.sub1, implicit $mode, implicit $exec
138 ; CHECK: S_BRANCH %bb.1
142 undef %0.sub1:vreg_64 = COPY killed $vgpr0
145 successors: %bb.2, %bb.1
147 %0:vreg_64 = COPY killed %0
149 S_CBRANCH_EXECNZ %bb.1, implicit $exec
153 %0.sub1:vreg_64 = nofpexcept V_MUL_F32_e32 0, killed %0.sub1, implicit $mode, implicit $exec
158 # The same value number appears in multiple blocks
160 name: identity_copy_undef_subrange_null_vninfo_to_remove
161 tracksRegLiveness: true
163 ; CHECK-LABEL: name: identity_copy_undef_subrange_null_vninfo_to_remove
165 ; CHECK: successors: %bb.1(0x80000000)
166 ; CHECK: liveins: $vgpr0
167 ; CHECK: undef %0.sub1:vreg_64 = COPY $vgpr0
169 ; CHECK: successors: %bb.3(0x40000000), %bb.2(0x40000000)
170 ; CHECK: S_CBRANCH_EXECNZ %bb.3, implicit $exec
172 ; CHECK: successors: %bb.1(0x80000000)
173 ; CHECK: S_NOP 0, implicit undef %0.sub0
174 ; CHECK: undef %0.sub1:vreg_64 = nofpexcept V_CEIL_F32_e32 %0.sub1, implicit $mode, implicit $exec
175 ; CHECK: S_BRANCH %bb.1
177 ; CHECK: S_NOP 0, implicit undef %0.sub0
181 undef %0.sub1:vreg_64 = COPY killed $vgpr0
185 S_CBRANCH_EXECNZ %bb.3, implicit $exec
188 S_NOP 0, implicit %0.sub0
189 undef %0.sub1:vreg_64 = nofpexcept V_CEIL_F32_e32 killed %0.sub1, implicit $mode, implicit $exec
193 S_NOP 0, implicit %0.sub0
198 name: undef_copy_self_loop0
199 tracksRegLiveness: true
201 ; CHECK-LABEL: name: undef_copy_self_loop0
203 ; CHECK: successors: %bb.1(0x80000000)
204 ; CHECK: liveins: $vgpr0
205 ; CHECK: undef %0.sub1:vreg_64 = COPY $vgpr0
207 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
208 ; CHECK: S_CBRANCH_EXECNZ %bb.1, implicit $exec
210 ; CHECK: S_NOP 0, implicit undef %0.sub0
214 undef %0.sub1:vreg_64 = COPY killed $vgpr0
218 S_CBRANCH_EXECNZ %bb.1, implicit $exec
221 S_NOP 0, implicit %0.sub0
226 name: undef_copy_self_loop1
227 tracksRegLiveness: true
229 ; CHECK-LABEL: name: undef_copy_self_loop1
231 ; CHECK: successors: %bb.1(0x80000000)
232 ; CHECK: liveins: $vgpr0
233 ; CHECK: undef %0.sub1:vreg_64 = COPY $vgpr0
235 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
236 ; CHECK: S_CBRANCH_EXECNZ %bb.1, implicit $exec
238 ; CHECK: S_NOP 0, implicit %0.sub1
242 undef %0.sub1:vreg_64 = COPY killed $vgpr0
246 S_CBRANCH_EXECNZ %bb.1, implicit $exec
249 S_NOP 0, implicit %0.sub1
253 # The coalescing of the %0 = %2 COPY in %bb.2 needs to prune the dead
254 # phi range across %bb.1 after it is erased.
256 name: prune_subrange_phi_value_0
257 tracksRegLiveness: true
259 ; CHECK-LABEL: name: prune_subrange_phi_value_0
261 ; CHECK: successors: %bb.1(0x80000000)
262 ; CHECK: liveins: $vgpr0
263 ; CHECK: undef %2.sub1:vreg_64 = COPY $vgpr0
265 ; CHECK: successors: %bb.2(0x40000000), %bb.1(0x40000000)
266 ; CHECK: S_CBRANCH_EXECNZ %bb.1, implicit $exec
267 ; CHECK: S_BRANCH %bb.2
269 ; CHECK: successors: %bb.1(0x80000000)
270 ; CHECK: S_BRANCH %bb.1
274 undef %0.sub1:vreg_64 = COPY killed $vgpr0
277 successors: %bb.2, %bb.1
279 %1:vreg_64 = COPY killed %0
281 S_CBRANCH_EXECNZ %bb.1, implicit $exec
285 undef %2.sub1:vreg_64 = COPY %0.sub1
286 %0:vreg_64 = COPY killed %2
292 name: prune_subrange_phi_value_0_0
293 tracksRegLiveness: true
295 ; CHECK-LABEL: name: prune_subrange_phi_value_0_0
297 ; CHECK: successors: %bb.1(0x80000000)
298 ; CHECK: liveins: $vgpr0
299 ; CHECK: undef %0.sub1:vreg_64 = COPY $vgpr0
301 ; CHECK: successors: %bb.2(0x40000000), %bb.1(0x40000000)
302 ; CHECK: S_CBRANCH_EXECNZ %bb.1, implicit $exec
303 ; CHECK: S_BRANCH %bb.2
305 ; CHECK: successors: %bb.1(0x80000000)
306 ; CHECK: S_BRANCH %bb.1
310 undef %0.sub1:vreg_64 = COPY killed $vgpr0
313 successors: %bb.2, %bb.1
315 %1:vreg_64 = COPY killed %0
317 S_CBRANCH_EXECNZ %bb.1, implicit $exec
321 undef %0.sub1:vreg_64 = COPY %0.sub1
327 name: prune_subrange_phi_value_0_1
328 tracksRegLiveness: true
330 ; CHECK-LABEL: name: prune_subrange_phi_value_0_1
332 ; CHECK: successors: %bb.1(0x80000000)
333 ; CHECK: liveins: $vgpr0
334 ; CHECK: undef %0.sub1:vreg_64 = COPY $vgpr0
336 ; CHECK: successors: %bb.2(0x40000000), %bb.1(0x40000000)
337 ; CHECK: S_CBRANCH_EXECNZ %bb.1, implicit $exec
338 ; CHECK: S_BRANCH %bb.2
340 ; CHECK: successors: %bb.1(0x80000000)
341 ; CHECK: S_BRANCH %bb.1
345 undef %0.sub1:vreg_64 = COPY killed $vgpr0
348 successors: %bb.2, %bb.1
350 %1:vreg_64 = COPY killed %0
352 S_CBRANCH_EXECNZ %bb.1, implicit $exec
360 # Variant of testcase that asserts since there wasn't already an
361 # incoming segment at the erased copy, and no valid end point.
363 name: prune_subrange_phi_value_1
364 tracksRegLiveness: true
366 ; CHECK-LABEL: name: prune_subrange_phi_value_1
368 ; CHECK: successors: %bb.1(0x80000000)
369 ; CHECK: liveins: $vgpr0
370 ; CHECK: undef %0.sub1:vreg_64 = COPY $vgpr0
372 ; CHECK: successors: %bb.2(0x40000000), %bb.1(0x40000000)
373 ; CHECK: S_CBRANCH_EXECNZ %bb.1, implicit $exec
374 ; CHECK: S_BRANCH %bb.2
376 ; CHECK: successors: %bb.1(0x80000000)
377 ; CHECK: undef %0.sub1:vreg_64 = nofpexcept V_CEIL_F32_e32 %0.sub1, implicit $mode, implicit $exec
378 ; CHECK: S_BRANCH %bb.1
382 undef %0.sub1:vreg_64 = COPY killed $vgpr0
385 successors: %bb.2, %bb.1
387 %0:vreg_64 = COPY killed %0
388 S_CBRANCH_EXECNZ %bb.1, implicit $exec
392 undef %1.sub1:vreg_64 = nofpexcept V_CEIL_F32_e32 killed %0.sub1, implicit $mode, implicit $exec
393 %0:vreg_64 = COPY killed %1
399 name: prune_subrange_phi_value_2
400 tracksRegLiveness: true
402 ; CHECK-LABEL: name: prune_subrange_phi_value_2
404 ; CHECK: successors: %bb.1(0x80000000)
405 ; CHECK: liveins: $vgpr0
406 ; CHECK: undef %0.sub1:vreg_64 = COPY $vgpr0
408 ; CHECK: successors: %bb.2(0x40000000), %bb.1(0x40000000)
409 ; CHECK: S_CBRANCH_EXECNZ %bb.1, implicit $exec
410 ; CHECK: S_BRANCH %bb.2
412 ; CHECK: successors: %bb.1(0x80000000)
413 ; CHECK: %0.sub1:vreg_64 = nofpexcept V_CEIL_F32_e32 %0.sub1, implicit $mode, implicit $exec
414 ; CHECK: S_BRANCH %bb.1
418 undef %0.sub1:vreg_64 = COPY killed $vgpr0
421 successors: %bb.2, %bb.1
423 %0:vreg_64 = COPY killed %0
424 S_CBRANCH_EXECNZ %bb.1, implicit $exec
428 %0.sub1:vreg_64 = nofpexcept V_CEIL_F32_e32 %0.sub1, implicit $mode, implicit $exec