1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=amdgcn-amd-amdhsa -start-before=livevars -stop-after=twoaddressinstruction -verify-machineinstrs -o - %s | FileCheck %s
4 # FIXME: update_mir_test_checks tries to incorrectly re-use a variable
5 # name used for a copy, so some of the check variable names were
8 # Check for LiveVariables verifier error after lowering SI_END_CF
11 name: live_variables_update_block_split
12 tracksRegLiveness: true
14 ; CHECK-LABEL: name: live_variables_update_block_split
16 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
17 ; CHECK-NEXT: liveins: $vgpr0
19 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY killed $vgpr0
20 ; CHECK-NEXT: [[V_MOV_B32_e32_:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
21 ; CHECK-NEXT: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 0, killed [[COPY]], implicit $exec
22 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY [[V_MOV_B32_e32_]]
23 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY killed [[V_MOV_B32_e32_]]
24 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
25 ; CHECK-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY3]], [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
26 ; CHECK-NEXT: [[S_XOR_B64_:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[S_AND_B64_]], [[COPY3]], implicit-def dead $scc
27 ; CHECK-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
28 ; CHECK-NEXT: [[S_MOV_B64_term:%[0-9]+]]:sreg_64_xexec = S_MOV_B64_term killed [[S_XOR_B64_]], implicit $exec
29 ; CHECK-NEXT: S_CBRANCH_EXECZ %bb.1, implicit $exec
30 ; CHECK-NEXT: S_BRANCH %bb.2
33 ; CHECK-NEXT: successors: %bb.3(0x80000000)
35 ; CHECK-NEXT: [[COPY4:%[0-9]+]]:sreg_64_xexec = COPY killed [[S_MOV_B64_term]]
36 ; CHECK-NEXT: $exec = S_OR_B64_term $exec, killed [[COPY4]], implicit-def $scc
39 ; CHECK-NEXT: successors: %bb.2(0x80000000)
41 ; CHECK-NEXT: [[COPY5:%[0-9]+]]:vgpr_32 = COPY killed [[COPY1]]
42 ; CHECK-NEXT: [[V_ADD_U32_e32_:%[0-9]+]]:vgpr_32 = nsw V_ADD_U32_e32 1, killed [[COPY5]], implicit $exec
43 ; CHECK-NEXT: [[COPY6:%[0-9]+]]:vgpr_32 = COPY killed [[V_ADD_U32_e32_]]
46 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
48 ; CHECK-NEXT: [[COPY66:%[0-9]+]]:vgpr_32 = COPY killed [[COPY6]]
49 ; CHECK-NEXT: GLOBAL_STORE_DWORD undef %10:vreg_64, [[COPY66]], 0, 0, implicit $exec :: (volatile store (s32), addrspace 1)
50 ; CHECK-NEXT: [[COPY7:%[0-9]+]]:vgpr_32 = COPY killed [[COPY66]]
51 ; CHECK-NEXT: [[COPY8:%[0-9]+]]:vgpr_32 = COPY [[COPY7]]
52 ; CHECK-NEXT: [[COPY8:%[0-9]+]]:vgpr_32 = COPY killed [[COPY7]]
53 ; CHECK-NEXT: [[COPY8:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
54 ; CHECK-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY8]], [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
55 ; CHECK-NEXT: [[S_XOR_B64_1:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[S_AND_B64_1]], [[COPY8]], implicit-def dead $scc
56 ; CHECK-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
57 ; CHECK-NEXT: [[S_MOV_B64_term1:%[0-9]+]]:sreg_64_xexec = S_MOV_B64_term killed [[S_XOR_B64_1]], implicit $exec
58 ; CHECK-NEXT: S_CBRANCH_EXECZ %bb.1, implicit $exec
59 ; CHECK-NEXT: S_BRANCH %bb.2
61 successors: %bb.2(0x40000000), %bb.1(0x40000000)
64 %0:vgpr_32 = COPY killed $vgpr0
65 %1:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
66 %2:sreg_64_xexec = V_CMP_EQ_U32_e64 0, killed %0, implicit $exec
67 %3:sreg_64_xexec = SI_IF %2, %bb.1, implicit-def $exec, implicit-def dead $scc, implicit $exec
71 successors: %bb.2(0x80000000)
73 %4:sreg_64_xexec = PHI %5, %bb.2, %3, %bb.0
74 %6:vgpr_32 = PHI %7, %bb.2, %1, %bb.0
75 SI_END_CF killed %4, implicit-def $exec, implicit-def dead $scc, implicit $exec
76 %8:vgpr_32 = nsw V_ADD_U32_e32 1, killed %6, implicit $exec
79 successors: %bb.2(0x40000000), %bb.1(0x40000000)
81 %9:vgpr_32 = PHI %8, %bb.1, %7, %bb.2, %1, %bb.0
82 GLOBAL_STORE_DWORD undef %10:vreg_64, %9, 0, 0, implicit $exec :: (volatile store (s32), addrspace 1)
83 %7:vgpr_32 = COPY killed %9
84 %5:sreg_64_xexec = SI_IF %2, %bb.1, implicit-def $exec, implicit-def dead $scc, implicit $exec
89 # Here %4 which is not a phi join reg has its last use in bb.2. When
90 # bb.2 is split into MBB/SplitBB, %4 will be live through MBB.
92 name: live_variables_update_block_split_non_phi_live_across
93 tracksRegLiveness: true
95 ; CHECK-LABEL: name: live_variables_update_block_split_non_phi_live_across
97 ; CHECK-NEXT: successors: %bb.3(0x40000000), %bb.1(0x40000000)
98 ; CHECK-NEXT: liveins: $vgpr0
100 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY killed $vgpr0
101 ; CHECK-NEXT: [[V_MOV_B32_e32_:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
102 ; CHECK-NEXT: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 0, killed [[COPY]], implicit $exec
103 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY [[V_MOV_B32_e32_]]
104 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY killed [[V_MOV_B32_e32_]]
105 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
106 ; CHECK-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY3]], [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
107 ; CHECK-NEXT: [[S_XOR_B64_:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[S_AND_B64_]], [[COPY3]], implicit-def dead $scc
108 ; CHECK-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
109 ; CHECK-NEXT: [[S_MOV_B64_term:%[0-9]+]]:sreg_64_xexec = S_MOV_B64_term killed [[S_XOR_B64_]], implicit $exec
110 ; CHECK-NEXT: S_CBRANCH_EXECZ %bb.1, implicit $exec
111 ; CHECK-NEXT: S_BRANCH %bb.3
114 ; CHECK-NEXT: successors: %bb.2(0x80000000)
116 ; CHECK-NEXT: [[COPY4:%[0-9]+]]:vgpr_32 = COPY killed [[COPY1]]
117 ; CHECK-NEXT: [[COPY5:%[0-9]+]]:sreg_64_xexec = COPY killed [[S_MOV_B64_term]]
118 ; CHECK-NEXT: S_BRANCH %bb.2
121 ; CHECK-NEXT: successors: %bb.4(0x80000000)
123 ; CHECK-NEXT: [[COPY6:%[0-9]+]]:sreg_64_xexec = COPY killed [[COPY5]]
124 ; CHECK-NEXT: $exec = S_OR_B64_term $exec, killed [[COPY6]], implicit-def $scc
127 ; CHECK-NEXT: successors: %bb.3(0x80000000)
129 ; CHECK-NEXT: [[V_ADD_U32_e32_:%[0-9]+]]:vgpr_32 = nsw V_ADD_U32_e32 1, killed [[COPY4]], implicit $exec
130 ; CHECK-NEXT: [[COPY7:%[0-9]+]]:vgpr_32 = COPY killed [[V_ADD_U32_e32_]]
133 ; CHECK-NEXT: successors: %bb.3(0x40000000), %bb.1(0x40000000)
135 ; CHECK-NEXT: [[COPY77:%[0-9]+]]:vgpr_32 = COPY killed [[COPY7]]
136 ; CHECK-NEXT: GLOBAL_STORE_DWORD undef %11:vreg_64, [[COPY77]], 0, 0, implicit $exec :: (volatile store (s32), addrspace 1)
137 ; CHECK-NEXT: [[COPY8:%[0-9]+]]:vgpr_32 = COPY killed [[COPY77]]
138 ; CHECK-NEXT: [[COPY9:%[0-9]+]]:vgpr_32 = COPY [[COPY8]]
139 ; CHECK-NEXT: [[COPY9:%[0-9]+]]:vgpr_32 = COPY killed [[COPY8]]
140 ; CHECK-NEXT: [[COPY9:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
141 ; CHECK-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY9]], [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
142 ; CHECK-NEXT: [[S_XOR_B64_1:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[S_AND_B64_1]], [[COPY9]], implicit-def dead $scc
143 ; CHECK-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
144 ; CHECK-NEXT: [[S_MOV_B64_term1:%[0-9]+]]:sreg_64_xexec = S_MOV_B64_term killed [[S_XOR_B64_1]], implicit $exec
145 ; CHECK-NEXT: S_CBRANCH_EXECZ %bb.1, implicit $exec
146 ; CHECK-NEXT: S_BRANCH %bb.3
148 successors: %bb.3(0x40000000), %bb.1(0x40000000)
151 %0:vgpr_32 = COPY killed $vgpr0
152 %1:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
153 %2:sreg_64_xexec = V_CMP_EQ_U32_e64 0, killed %0, implicit $exec
154 %3:sreg_64_xexec = SI_IF %2, %bb.1, implicit-def $exec, implicit-def dead $scc, implicit $exec
158 successors: %bb.2(0x80000000)
160 %4:sreg_64_xexec = PHI %5, %bb.3, %3, %bb.0
161 %6:vgpr_32 = PHI %7, %bb.3, %1, %bb.0
165 successors: %bb.3(0x80000000)
167 %8:sreg_64_xexec = COPY %4
168 SI_END_CF killed %8, implicit-def $exec, implicit-def dead $scc, implicit $exec
169 %9:vgpr_32 = nsw V_ADD_U32_e32 1, killed %6, implicit $exec
172 successors: %bb.3(0x40000000), %bb.1(0x40000000)
174 %10:vgpr_32 = PHI %9, %bb.2, %7, %bb.3, %1, %bb.0
175 GLOBAL_STORE_DWORD undef %11:vreg_64, %10, 0, 0, implicit $exec :: (volatile store (s32), addrspace 1)
176 %7:vgpr_32 = COPY killed %10
177 %5:sreg_64_xexec = SI_IF %2, %bb.1, implicit-def $exec, implicit-def dead $scc, implicit $exec
182 # Check we don't get "Block should not be in AliveBlocks" for
183 # registers defined before si_end_cf
185 name: live_variables_update_block_split_split_killed_def_before_si_end_cf
186 tracksRegLiveness: true
188 ; CHECK-LABEL: name: live_variables_update_block_split_split_killed_def_before_si_end_cf
190 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
191 ; CHECK-NEXT: liveins: $vgpr0
193 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY killed $vgpr0
194 ; CHECK-NEXT: [[V_MOV_B32_e32_:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
195 ; CHECK-NEXT: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 0, killed [[COPY]], implicit $exec
196 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY [[V_MOV_B32_e32_]]
197 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY killed [[V_MOV_B32_e32_]]
198 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
199 ; CHECK-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY3]], [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
200 ; CHECK-NEXT: [[S_XOR_B64_:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[S_AND_B64_]], [[COPY3]], implicit-def dead $scc
201 ; CHECK-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
202 ; CHECK-NEXT: [[S_MOV_B64_term:%[0-9]+]]:sreg_64_xexec = S_MOV_B64_term killed [[S_XOR_B64_]], implicit $exec
203 ; CHECK-NEXT: S_CBRANCH_EXECZ %bb.1, implicit $exec
204 ; CHECK-NEXT: S_BRANCH %bb.2
207 ; CHECK-NEXT: successors: %bb.3(0x80000000)
209 ; CHECK-NEXT: [[COPY4:%[0-9]+]]:sreg_64_xexec = COPY killed [[S_MOV_B64_term]]
210 ; CHECK-NEXT: [[S_MOV_B64_:%[0-9]+]]:sreg_64 = S_MOV_B64 1
211 ; CHECK-NEXT: $exec = S_OR_B64_term $exec, killed [[COPY4]], implicit-def $scc
214 ; CHECK-NEXT: successors: %bb.2(0x80000000)
216 ; CHECK-NEXT: S_NOP 0, implicit killed [[S_MOV_B64_]]
217 ; CHECK-NEXT: [[COPY5:%[0-9]+]]:vgpr_32 = COPY killed [[COPY1]]
218 ; CHECK-NEXT: [[V_ADD_U32_e32_:%[0-9]+]]:vgpr_32 = nsw V_ADD_U32_e32 1, killed [[COPY5]], implicit $exec
219 ; CHECK-NEXT: [[COPY6:%[0-9]+]]:vgpr_32 = COPY killed [[V_ADD_U32_e32_]]
222 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
224 ; CHECK-NEXT: [[COPY66:%[0-9]+]]:vgpr_32 = COPY killed [[COPY6]]
225 ; CHECK-NEXT: GLOBAL_STORE_DWORD undef %11:vreg_64, [[COPY66]], 0, 0, implicit $exec :: (volatile store (s32), addrspace 1)
226 ; CHECK-NEXT: [[COPY7:%[0-9]+]]:vgpr_32 = COPY killed [[COPY66]]
227 ; CHECK-NEXT: [[COPY8:%[0-9]+]]:vgpr_32 = COPY [[COPY7]]
228 ; CHECK-NEXT: [[COPY8:%[0-9]+]]:vgpr_32 = COPY killed [[COPY7]]
229 ; CHECK-NEXT: [[COPY8:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
230 ; CHECK-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY8]], [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
231 ; CHECK-NEXT: [[S_XOR_B64_1:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[S_AND_B64_1]], [[COPY8]], implicit-def dead $scc
232 ; CHECK-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
233 ; CHECK-NEXT: [[S_MOV_B64_term1:%[0-9]+]]:sreg_64_xexec = S_MOV_B64_term killed [[S_XOR_B64_1]], implicit $exec
234 ; CHECK-NEXT: S_CBRANCH_EXECZ %bb.1, implicit $exec
235 ; CHECK-NEXT: S_BRANCH %bb.2
239 %0:vgpr_32 = COPY killed $vgpr0
240 %1:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
241 %2:sreg_64_xexec = V_CMP_EQ_U32_e64 0, killed %0, implicit $exec
242 %3:sreg_64_xexec = SI_IF %2, %bb.1, implicit-def $exec, implicit-def dead $scc, implicit $exec
246 %4:sreg_64_xexec = PHI %5, %bb.2, %3, %bb.0
247 %6:vgpr_32 = PHI %7, %bb.2, %1, %bb.0
248 %8:sreg_64 = S_MOV_B64 1
249 SI_END_CF killed %4, implicit-def $exec, implicit-def dead $scc, implicit $exec
250 S_NOP 0, implicit killed %8
251 %9:vgpr_32 = nsw V_ADD_U32_e32 1, killed %6, implicit $exec
254 successors: %bb.2(0x40000000), %bb.1(0x40000000)
256 %10:vgpr_32 = PHI %9, %bb.1, %7, %bb.2, %1, %bb.0
257 GLOBAL_STORE_DWORD undef %11:vreg_64, %10, 0, 0, implicit $exec :: (volatile store (s32), addrspace 1)
258 %7:vgpr_32 = COPY killed %10
259 %5:sreg_64_xexec = SI_IF %2, %bb.1, implicit-def $exec, implicit-def dead $scc, implicit $exec