1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 3
2 # RUN: llc -run-pass=liveintervals -run-pass=si-lower-control-flow -mtriple=amdgcn--amdpal -mcpu=gfx1030 -verify-machineinstrs -o - %s | FileCheck %s
4 # Check that verifier passes for the following.
6 # Caused: Live segment doesn't end at a valid instruction
9 tracksRegLiveness: true
11 ; CHECK-LABEL: name: _amdgpu_cs_main1
13 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.3(0x40000000)
14 ; CHECK-NEXT: liveins: $vgpr0
16 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
17 ; CHECK-NEXT: [[V_CMP_NE_U32_e64_:%[0-9]+]]:sreg_32 = V_CMP_NE_U32_e64 0, [[COPY]], implicit $exec
18 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $exec_lo, implicit-def $exec_lo
19 ; CHECK-NEXT: [[S_AND_B32_:%[0-9]+]]:sreg_32 = S_AND_B32 [[COPY1]], [[V_CMP_NE_U32_e64_]], implicit-def dead $scc
20 ; CHECK-NEXT: [[S_XOR_B32_:%[0-9]+]]:sreg_32 = S_XOR_B32 [[S_AND_B32_]], [[COPY1]], implicit-def dead $scc
21 ; CHECK-NEXT: $exec_lo = S_MOV_B32_term [[S_AND_B32_]]
22 ; CHECK-NEXT: S_CBRANCH_EXECZ %bb.3, implicit $exec
23 ; CHECK-NEXT: S_BRANCH %bb.2
26 ; CHECK-NEXT: $exec_lo = S_OR_B32 $exec_lo, %3, implicit-def $scc
27 ; CHECK-NEXT: S_ENDPGM 0
30 ; CHECK-NEXT: successors: %bb.3(0x80000000)
34 ; CHECK-NEXT: successors: %bb.4(0x40000000), %bb.1(0x40000000)
36 ; CHECK-NEXT: [[S_OR_SAVEEXEC_B32_:%[0-9]+]]:sreg_32 = S_OR_SAVEEXEC_B32 [[S_XOR_B32_]], implicit-def $exec, implicit-def $scc, implicit $exec
37 ; CHECK-NEXT: [[S_AND_B32_1:%[0-9]+]]:sreg_32 = S_AND_B32 $exec_lo, [[S_OR_SAVEEXEC_B32_]], implicit-def $scc
38 ; CHECK-NEXT: $exec_lo = S_XOR_B32_term $exec_lo, [[S_AND_B32_1]], implicit-def $scc
39 ; CHECK-NEXT: S_CBRANCH_EXECZ %bb.1, implicit $exec
40 ; CHECK-NEXT: S_BRANCH %bb.4
43 ; CHECK-NEXT: successors: %bb.1(0x80000000)
45 ; CHECK-NEXT: S_BRANCH %bb.1
47 successors: %bb.2(0x40000000), %bb.3(0x40000000)
50 %2:vgpr_32 = COPY killed $vgpr0
51 %6:sreg_32 = V_CMP_NE_U32_e64 0, killed %2, implicit $exec
52 %0:sreg_32 = SI_IF killed %6, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
56 SI_END_CF killed %1, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
60 successors: %bb.3(0x80000000)
64 successors: %bb.4(0x40000000), %bb.1(0x40000000)
66 %1:sreg_32 = SI_ELSE killed %0, %bb.1, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
70 successors: %bb.1(0x80000000)
76 # Caused: Assertion `itr != mi2iMap.end() && "Instruction not in maps."' failed.
78 name: _amdgpu_cs_main2
79 tracksRegLiveness: true
81 ; CHECK-LABEL: name: _amdgpu_cs_main2
83 ; CHECK-NEXT: successors: %bb.1(0x80000000)
84 ; CHECK-NEXT: liveins: $vgpr0
86 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
87 ; CHECK-NEXT: [[V_CMP_GT_I32_e64_:%[0-9]+]]:sreg_32 = V_CMP_GT_I32_e64 1, [[COPY]], implicit $exec
88 ; CHECK-NEXT: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 0
89 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY [[S_MOV_B32_]]
92 ; CHECK-NEXT: successors: %bb.2(0x04000000), %bb.1(0x7c000000)
94 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:sreg_32 = COPY [[COPY1]]
95 ; CHECK-NEXT: [[S_AND_B32_:%[0-9]+]]:sreg_32 = S_AND_B32 $exec_lo, [[V_CMP_GT_I32_e64_]], implicit-def $scc
96 ; CHECK-NEXT: [[S_OR_B32_:%[0-9]+]]:sreg_32 = S_OR_B32 [[S_AND_B32_]], [[COPY2]], implicit-def $scc
97 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:sreg_32 = COPY [[S_OR_B32_]]
98 ; CHECK-NEXT: $exec_lo = S_ANDN2_B32_term $exec_lo, [[S_OR_B32_]], implicit-def $scc
99 ; CHECK-NEXT: S_CBRANCH_EXECNZ %bb.1, implicit $exec
100 ; CHECK-NEXT: S_BRANCH %bb.2
103 ; CHECK-NEXT: $exec_lo = S_OR_B32 $exec_lo, [[S_OR_B32_]], implicit-def $scc
104 ; CHECK-NEXT: S_ENDPGM 0
106 successors: %bb.1(0x80000000)
109 %4:vgpr_32 = COPY killed $vgpr0
110 %8:sreg_32 = V_CMP_GT_I32_e64 1, killed %4, implicit $exec
111 %6:sreg_32 = S_MOV_B32 0
112 %10:sreg_32 = COPY killed %6
115 successors: %bb.2(0x04000000), %bb.1(0x7c000000)
117 %1:sreg_32 = COPY killed %10
118 %2:sreg_32 = SI_IF_BREAK %8, killed %1, implicit-def dead $scc
119 %10:sreg_32 = COPY %2
120 SI_LOOP %2, %bb.1, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
124 SI_END_CF killed %2, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
129 # Caused: Live range continues after kill flag
131 name: _amdgpu_cs_main3
132 tracksRegLiveness: true
134 ; CHECK-LABEL: name: _amdgpu_cs_main3
136 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.4(0x40000000)
137 ; CHECK-NEXT: liveins: $vgpr0
139 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
140 ; CHECK-NEXT: [[V_CMP_NGT_F32_e64_:%[0-9]+]]:sreg_32 = nofpexcept V_CMP_NGT_F32_e64 0, 0, 0, [[COPY]], 0, implicit $mode, implicit $exec
141 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $exec_lo, implicit-def $exec_lo
142 ; CHECK-NEXT: [[S_AND_B32_:%[0-9]+]]:sreg_32 = S_AND_B32 [[COPY1]], [[V_CMP_NGT_F32_e64_]], implicit-def dead $scc
143 ; CHECK-NEXT: $exec_lo = S_MOV_B32_term [[S_AND_B32_]]
144 ; CHECK-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
145 ; CHECK-NEXT: S_BRANCH %bb.1
148 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.4(0x40000000)
150 ; CHECK-NEXT: [[V_CMP_NLT_F32_e64_:%[0-9]+]]:sreg_32 = nofpexcept V_CMP_NLT_F32_e64 0, 0, 0, [[COPY]], 0, implicit $mode, implicit $exec
151 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:sreg_32 = COPY $exec_lo, implicit-def $exec_lo
152 ; CHECK-NEXT: [[S_AND_B32_1:%[0-9]+]]:sreg_32 = S_AND_B32 [[COPY2]], [[V_CMP_NLT_F32_e64_]], implicit-def dead $scc
153 ; CHECK-NEXT: $exec_lo = S_MOV_B32_term [[S_AND_B32_1]]
154 ; CHECK-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
155 ; CHECK-NEXT: S_BRANCH %bb.2
158 ; CHECK-NEXT: successors: %bb.4(0x80000000)
162 ; CHECK-NEXT: $exec_lo = S_OR_B32 $exec_lo, [[COPY1]], implicit-def $scc
163 ; CHECK-NEXT: S_ENDPGM 0
165 successors: %bb.1(0x40000000), %bb.4(0x40000000)
168 %2:vgpr_32 = COPY killed $vgpr0
169 %5:sreg_32 = nofpexcept V_CMP_NGT_F32_e64 0, 0, 0, %2, 0, implicit $mode, implicit $exec
170 %0:sreg_32 = SI_IF killed %5, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
174 successors: %bb.2(0x40000000), %bb.3(0x40000000)
176 %7:sreg_32 = nofpexcept V_CMP_NLT_F32_e64 0, 0, 0, killed %2, 0, implicit $mode, implicit $exec
177 %1:sreg_32 = SI_IF killed %7, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
181 successors: %bb.3(0x80000000)
185 successors: %bb.4(0x80000000)
187 SI_END_CF killed %1, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
190 SI_END_CF killed %0, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
195 # Caused: Live range continues after dead def flag
197 name: _amdgpu_cs_main4
198 tracksRegLiveness: true
200 ; CHECK-LABEL: name: _amdgpu_cs_main4
202 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.5(0x40000000)
203 ; CHECK-NEXT: liveins: $vgpr0
205 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
206 ; CHECK-NEXT: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 0
207 ; CHECK-NEXT: [[V_CMP_NE_U32_e64_:%[0-9]+]]:sreg_32 = V_CMP_NE_U32_e64 0, [[COPY]], implicit $exec
208 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $exec_lo, implicit-def $exec_lo
209 ; CHECK-NEXT: [[S_AND_B32_:%[0-9]+]]:sreg_32 = S_AND_B32 [[COPY1]], [[V_CMP_NE_U32_e64_]], implicit-def dead $scc
210 ; CHECK-NEXT: $exec_lo = S_MOV_B32_term [[S_AND_B32_]]
211 ; CHECK-NEXT: S_CBRANCH_EXECZ %bb.5, implicit $exec
212 ; CHECK-NEXT: S_BRANCH %bb.1
215 ; CHECK-NEXT: successors: %bb.6(0x80000000)
217 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:sreg_32 = COPY $exec_lo
218 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:sreg_32 = COPY [[COPY2]]
219 ; CHECK-NEXT: [[COPY4:%[0-9]+]]:sreg_32 = COPY [[S_MOV_B32_]]
220 ; CHECK-NEXT: [[COPY5:%[0-9]+]]:sreg_32 = COPY [[COPY3]]
221 ; CHECK-NEXT: S_BRANCH %bb.6
224 ; CHECK-NEXT: successors: %bb.5(0x80000000)
226 ; CHECK-NEXT: [[REG_SEQUENCE:%[0-9]+]]:sgpr_128 = REG_SEQUENCE %9, %subreg.sub0, %9, %subreg.sub1, %9, %subreg.sub2, %9, %subreg.sub3
227 ; CHECK-NEXT: [[COPY6:%[0-9]+]]:vgpr_32 = COPY %11
228 ; CHECK-NEXT: BUFFER_ATOMIC_ADD_OFFSET [[COPY6]], [[REG_SEQUENCE]], 0, 0, 0, implicit $exec :: (volatile dereferenceable load store (s32), align 1, addrspace 8)
229 ; CHECK-NEXT: S_BRANCH %bb.5
232 ; CHECK-NEXT: S_ENDPGM 0
235 ; CHECK-NEXT: successors: %bb.4(0x80000000)
237 ; CHECK-NEXT: $exec_lo = S_OR_B32 $exec_lo, [[COPY1]], implicit-def $scc
238 ; CHECK-NEXT: S_BRANCH %bb.4
241 ; CHECK-NEXT: successors: %bb.7(0x04000000), %bb.6(0x7c000000)
243 ; CHECK-NEXT: [[COPY7:%[0-9]+]]:sreg_32 = COPY [[COPY4]]
244 ; CHECK-NEXT: [[COPY8:%[0-9]+]]:sreg_32 = COPY [[COPY5]]
245 ; CHECK-NEXT: [[S_FF1_I32_B32_:%[0-9]+]]:sreg_32 = S_FF1_I32_B32 [[COPY8]]
246 ; CHECK-NEXT: [[V_READLANE_B32_:%[0-9]+]]:sreg_32 = V_READLANE_B32 [[COPY]], [[S_FF1_I32_B32_]]
247 ; CHECK-NEXT: [[S_ADD_I32_:%[0-9]+]]:sreg_32 = S_ADD_I32 [[COPY7]], [[V_READLANE_B32_]], implicit-def dead $scc
248 ; CHECK-NEXT: [[S_LSHL_B32_:%[0-9]+]]:sreg_32 = S_LSHL_B32 1, [[S_FF1_I32_B32_]], implicit-def dead $scc
249 ; CHECK-NEXT: [[S_ANDN2_B32_:%[0-9]+]]:sreg_32 = S_ANDN2_B32 [[COPY8]], [[S_LSHL_B32_]], implicit-def dead $scc
250 ; CHECK-NEXT: S_CMP_LG_U32 [[S_ANDN2_B32_]], 0, implicit-def $scc
251 ; CHECK-NEXT: [[COPY9:%[0-9]+]]:sreg_32 = COPY [[S_ADD_I32_]]
252 ; CHECK-NEXT: [[COPY9:%[0-9]+]]:sreg_32 = COPY [[S_ANDN2_B32_]]
253 ; CHECK-NEXT: S_CBRANCH_SCC1 %bb.6, implicit killed $scc
254 ; CHECK-NEXT: S_BRANCH %bb.7
257 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.5(0x40000000)
259 ; CHECK-NEXT: [[S_MOV_B32_1:%[0-9]+]]:sreg_32 = S_MOV_B32 0
260 ; CHECK-NEXT: [[V_MBCNT_LO_U32_B32_e64_:%[0-9]+]]:vgpr_32 = V_MBCNT_LO_U32_B32_e64 [[COPY2]], 0, implicit $exec
261 ; CHECK-NEXT: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_32 = V_CMP_EQ_U32_e64 0, [[V_MBCNT_LO_U32_B32_e64_]], implicit $exec
262 ; CHECK-NEXT: [[COPY9:%[0-9]+]]:sreg_32 = COPY $exec_lo, implicit-def $exec_lo
263 ; CHECK-NEXT: [[S_AND_B32_1:%[0-9]+]]:sreg_32 = S_AND_B32 [[COPY9]], [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
264 ; CHECK-NEXT: dead [[S_XOR_B32_:%[0-9]+]]:sreg_32 = S_XOR_B32 [[S_AND_B32_1]], [[COPY9]], implicit-def dead $scc
265 ; CHECK-NEXT: $exec_lo = S_MOV_B32_term [[S_AND_B32_1]]
266 ; CHECK-NEXT: S_CBRANCH_EXECZ %bb.5, implicit $exec
267 ; CHECK-NEXT: S_BRANCH %bb.2
269 successors: %bb.1(0x40000000), %bb.5(0x40000000)
272 %8:vgpr_32 = COPY killed $vgpr0
273 %10:sreg_32 = S_MOV_B32 0
274 %11:sreg_32 = V_CMP_NE_U32_e64 0, %8, implicit $exec
275 %0:sreg_32 = SI_IF killed %11, %bb.5, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
279 successors: %bb.6(0x80000000)
281 %13:sreg_32 = COPY $exec_lo
282 %1:sreg_32 = COPY %13
283 %25:sreg_32 = COPY killed %10
284 %26:sreg_32 = COPY killed %1
288 successors: %bb.3(0x80000000)
290 %23:sgpr_128 = REG_SEQUENCE killed %19, %subreg.sub0, %19, %subreg.sub1, %19, %subreg.sub2, %19, %subreg.sub3
291 %24:vgpr_32 = COPY killed %4
292 BUFFER_ATOMIC_ADD_OFFSET killed %24, killed %23, 0, 0, 0, implicit $exec :: (volatile dereferenceable load store (s32), align 1, addrspace 8)
295 successors: %bb.5(0x80000000)
297 SI_END_CF killed %7, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
304 successors: %bb.4(0x80000000)
306 SI_END_CF killed %0, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
310 successors: %bb.7(0x04000000), %bb.6(0x7c000000)
312 %2:sreg_32 = COPY killed %25
313 %3:sreg_32 = COPY killed %26
314 %14:sreg_32 = S_FF1_I32_B32 %3
315 %15:sreg_32 = V_READLANE_B32 %8, %14
316 %4:sreg_32 = S_ADD_I32 killed %2, killed %15, implicit-def dead $scc
317 %17:sreg_32 = S_LSHL_B32 1, killed %14, implicit-def dead $scc
318 %5:sreg_32 = S_ANDN2_B32 killed %3, killed %17, implicit-def dead $scc
319 S_CMP_LG_U32 %5, 0, implicit-def $scc
320 %25:sreg_32 = COPY %4
321 %26:sreg_32 = COPY killed %5
322 S_CBRANCH_SCC1 %bb.6, implicit killed $scc
326 successors: %bb.2(0x40000000), %bb.3(0x40000000)
328 %19:sreg_32 = S_MOV_B32 0
329 %20:vgpr_32 = V_MBCNT_LO_U32_B32_e64 killed %13, 0, implicit $exec
330 %21:sreg_32 = V_CMP_EQ_U32_e64 0, killed %20, implicit $exec
331 %7:sreg_32 = SI_IF killed %21, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec