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)
33 ; CHECK-NEXT: successors: %bb.4(0x40000000), %bb.1(0x40000000)
35 ; 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
36 ; CHECK-NEXT: [[S_AND_B32_1:%[0-9]+]]:sreg_32 = S_AND_B32 $exec_lo, [[S_OR_SAVEEXEC_B32_]], implicit-def $scc
37 ; CHECK-NEXT: $exec_lo = S_XOR_B32_term $exec_lo, [[S_AND_B32_1]], implicit-def $scc
38 ; CHECK-NEXT: S_CBRANCH_EXECZ %bb.1, implicit $exec
39 ; CHECK-NEXT: S_BRANCH %bb.4
42 ; CHECK-NEXT: successors: %bb.1(0x80000000)
44 ; CHECK-NEXT: S_BRANCH %bb.1
46 successors: %bb.2(0x40000000), %bb.3(0x40000000)
49 %2:vgpr_32 = COPY killed $vgpr0
50 %6:sreg_32 = V_CMP_NE_U32_e64 0, killed %2, implicit $exec
51 %0:sreg_32 = SI_IF killed %6, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
55 SI_END_CF killed %1, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
59 successors: %bb.3(0x80000000)
63 successors: %bb.4(0x40000000), %bb.1(0x40000000)
65 %1:sreg_32 = SI_ELSE killed %0, %bb.1, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
69 successors: %bb.1(0x80000000)
75 # Caused: Assertion `itr != mi2iMap.end() && "Instruction not in maps."' failed.
77 name: _amdgpu_cs_main2
78 tracksRegLiveness: true
80 ; CHECK-LABEL: name: _amdgpu_cs_main2
82 ; CHECK-NEXT: successors: %bb.1(0x80000000)
83 ; CHECK-NEXT: liveins: $vgpr0
85 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
86 ; CHECK-NEXT: [[V_CMP_GT_I32_e64_:%[0-9]+]]:sreg_32 = V_CMP_GT_I32_e64 1, [[COPY]], implicit $exec
87 ; CHECK-NEXT: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 0
88 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY [[S_MOV_B32_]]
91 ; CHECK-NEXT: successors: %bb.2(0x04000000), %bb.1(0x7c000000)
93 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:sreg_32 = COPY [[COPY1]]
94 ; CHECK-NEXT: [[S_AND_B32_:%[0-9]+]]:sreg_32 = S_AND_B32 $exec_lo, [[V_CMP_GT_I32_e64_]], implicit-def $scc
95 ; CHECK-NEXT: [[S_OR_B32_:%[0-9]+]]:sreg_32 = S_OR_B32 [[S_AND_B32_]], [[COPY2]], implicit-def $scc
96 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY [[S_OR_B32_]]
97 ; CHECK-NEXT: $exec_lo = S_ANDN2_B32_term $exec_lo, [[S_OR_B32_]], implicit-def $scc
98 ; CHECK-NEXT: S_CBRANCH_EXECNZ %bb.1, implicit $exec
99 ; CHECK-NEXT: S_BRANCH %bb.2
102 ; CHECK-NEXT: $exec_lo = S_OR_B32 $exec_lo, [[S_OR_B32_]], implicit-def $scc
103 ; CHECK-NEXT: S_ENDPGM 0
105 successors: %bb.1(0x80000000)
108 %4:vgpr_32 = COPY killed $vgpr0
109 %8:sreg_32 = V_CMP_GT_I32_e64 1, killed %4, implicit $exec
110 %6:sreg_32 = S_MOV_B32 0
111 %10:sreg_32 = COPY killed %6
114 successors: %bb.2(0x04000000), %bb.1(0x7c000000)
116 %1:sreg_32 = COPY killed %10
117 %2:sreg_32 = SI_IF_BREAK %8, killed %1, implicit-def dead $scc
118 %10:sreg_32 = COPY %2
119 SI_LOOP %2, %bb.1, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
123 SI_END_CF killed %2, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
128 # Caused: Live range continues after kill flag
130 name: _amdgpu_cs_main3
131 tracksRegLiveness: true
133 ; CHECK-LABEL: name: _amdgpu_cs_main3
135 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.4(0x40000000)
136 ; CHECK-NEXT: liveins: $vgpr0
138 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
139 ; 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
140 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $exec_lo, implicit-def $exec_lo
141 ; CHECK-NEXT: [[S_AND_B32_:%[0-9]+]]:sreg_32 = S_AND_B32 [[COPY1]], [[V_CMP_NGT_F32_e64_]], implicit-def dead $scc
142 ; CHECK-NEXT: $exec_lo = S_MOV_B32_term [[S_AND_B32_]]
143 ; CHECK-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
144 ; CHECK-NEXT: S_BRANCH %bb.1
147 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.4(0x40000000)
149 ; 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
150 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:sreg_32 = COPY $exec_lo, implicit-def $exec_lo
151 ; CHECK-NEXT: [[S_AND_B32_1:%[0-9]+]]:sreg_32 = S_AND_B32 [[COPY2]], [[V_CMP_NLT_F32_e64_]], implicit-def dead $scc
152 ; CHECK-NEXT: $exec_lo = S_MOV_B32_term [[S_AND_B32_1]]
153 ; CHECK-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
154 ; CHECK-NEXT: S_BRANCH %bb.2
157 ; CHECK-NEXT: successors: %bb.4(0x80000000)
160 ; CHECK-NEXT: $exec_lo = S_OR_B32 $exec_lo, [[COPY1]], implicit-def $scc
161 ; CHECK-NEXT: S_ENDPGM 0
163 successors: %bb.1(0x40000000), %bb.4(0x40000000)
166 %2:vgpr_32 = COPY killed $vgpr0
167 %5:sreg_32 = nofpexcept V_CMP_NGT_F32_e64 0, 0, 0, %2, 0, implicit $mode, implicit $exec
168 %0:sreg_32 = SI_IF killed %5, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
172 successors: %bb.2(0x40000000), %bb.3(0x40000000)
174 %7:sreg_32 = nofpexcept V_CMP_NLT_F32_e64 0, 0, 0, killed %2, 0, implicit $mode, implicit $exec
175 %1:sreg_32 = SI_IF killed %7, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
179 successors: %bb.3(0x80000000)
183 successors: %bb.4(0x80000000)
185 SI_END_CF killed %1, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
188 SI_END_CF killed %0, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
193 # Caused: Live range continues after dead def flag
195 name: _amdgpu_cs_main4
196 tracksRegLiveness: true
198 ; CHECK-LABEL: name: _amdgpu_cs_main4
200 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.5(0x40000000)
201 ; CHECK-NEXT: liveins: $vgpr0
203 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
204 ; CHECK-NEXT: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 0
205 ; CHECK-NEXT: [[V_CMP_NE_U32_e64_:%[0-9]+]]:sreg_32 = V_CMP_NE_U32_e64 0, [[COPY]], implicit $exec
206 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $exec_lo, implicit-def $exec_lo
207 ; CHECK-NEXT: [[S_AND_B32_:%[0-9]+]]:sreg_32 = S_AND_B32 [[COPY1]], [[V_CMP_NE_U32_e64_]], implicit-def dead $scc
208 ; CHECK-NEXT: $exec_lo = S_MOV_B32_term [[S_AND_B32_]]
209 ; CHECK-NEXT: S_CBRANCH_EXECZ %bb.5, implicit $exec
210 ; CHECK-NEXT: S_BRANCH %bb.1
213 ; CHECK-NEXT: successors: %bb.6(0x80000000)
215 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:sreg_32 = COPY $exec_lo
216 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:sreg_32 = COPY [[COPY2]]
217 ; CHECK-NEXT: [[COPY4:%[0-9]+]]:sreg_32 = COPY [[S_MOV_B32_]]
218 ; CHECK-NEXT: [[COPY5:%[0-9]+]]:sreg_32 = COPY [[COPY3]]
219 ; CHECK-NEXT: S_BRANCH %bb.6
222 ; CHECK-NEXT: successors: %bb.5(0x80000000)
224 ; CHECK-NEXT: [[REG_SEQUENCE:%[0-9]+]]:sgpr_128 = REG_SEQUENCE %9, %subreg.sub0, %9, %subreg.sub1, %9, %subreg.sub2, %9, %subreg.sub3
225 ; CHECK-NEXT: [[COPY6:%[0-9]+]]:vgpr_32 = COPY %11
226 ; CHECK-NEXT: BUFFER_ATOMIC_ADD_OFFSET [[COPY6]], [[REG_SEQUENCE]], 0, 0, 0, implicit $exec :: (volatile dereferenceable load store (s32), align 1, addrspace 8)
227 ; CHECK-NEXT: S_BRANCH %bb.5
230 ; CHECK-NEXT: S_ENDPGM 0
233 ; CHECK-NEXT: successors: %bb.4(0x80000000)
235 ; CHECK-NEXT: $exec_lo = S_OR_B32 $exec_lo, [[COPY1]], implicit-def $scc
236 ; CHECK-NEXT: S_BRANCH %bb.4
239 ; CHECK-NEXT: successors: %bb.7(0x04000000), %bb.6(0x7c000000)
241 ; CHECK-NEXT: [[COPY7:%[0-9]+]]:sreg_32 = COPY [[COPY4]]
242 ; CHECK-NEXT: [[COPY8:%[0-9]+]]:sreg_32 = COPY [[COPY5]]
243 ; CHECK-NEXT: [[S_FF1_I32_B32_:%[0-9]+]]:sreg_32 = S_FF1_I32_B32 [[COPY8]]
244 ; CHECK-NEXT: [[V_READLANE_B32_:%[0-9]+]]:sreg_32 = V_READLANE_B32 [[COPY]], [[S_FF1_I32_B32_]]
245 ; CHECK-NEXT: [[S_ADD_I32_:%[0-9]+]]:sreg_32 = S_ADD_I32 [[COPY7]], [[V_READLANE_B32_]], implicit-def dead $scc
246 ; CHECK-NEXT: [[S_LSHL_B32_:%[0-9]+]]:sreg_32 = S_LSHL_B32 1, [[S_FF1_I32_B32_]], implicit-def dead $scc
247 ; CHECK-NEXT: [[S_ANDN2_B32_:%[0-9]+]]:sreg_32 = S_ANDN2_B32 [[COPY8]], [[S_LSHL_B32_]], implicit-def dead $scc
248 ; CHECK-NEXT: S_CMP_LG_U32 [[S_ANDN2_B32_]], 0, implicit-def $scc
249 ; CHECK-NEXT: [[COPY4:%[0-9]+]]:sreg_32 = COPY [[S_ADD_I32_]]
250 ; CHECK-NEXT: [[COPY5:%[0-9]+]]:sreg_32 = COPY [[S_ANDN2_B32_]]
251 ; CHECK-NEXT: S_CBRANCH_SCC1 %bb.6, implicit killed $scc
252 ; CHECK-NEXT: S_BRANCH %bb.7
255 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.5(0x40000000)
257 ; CHECK-NEXT: [[S_MOV_B32_1:%[0-9]+]]:sreg_32 = S_MOV_B32 0
258 ; CHECK-NEXT: [[V_MBCNT_LO_U32_B32_e64_:%[0-9]+]]:vgpr_32 = V_MBCNT_LO_U32_B32_e64 [[COPY2]], 0, implicit $exec
259 ; 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
260 ; CHECK-NEXT: [[COPY9:%[0-9]+]]:sreg_32 = COPY $exec_lo, implicit-def $exec_lo
261 ; CHECK-NEXT: [[S_AND_B32_1:%[0-9]+]]:sreg_32 = S_AND_B32 [[COPY9]], [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
262 ; CHECK-NEXT: dead [[S_XOR_B32_:%[0-9]+]]:sreg_32 = S_XOR_B32 [[S_AND_B32_1]], [[COPY9]], implicit-def dead $scc
263 ; CHECK-NEXT: $exec_lo = S_MOV_B32_term [[S_AND_B32_1]]
264 ; CHECK-NEXT: S_CBRANCH_EXECZ %bb.5, implicit $exec
265 ; CHECK-NEXT: S_BRANCH %bb.2
267 successors: %bb.1(0x40000000), %bb.5(0x40000000)
270 %8:vgpr_32 = COPY killed $vgpr0
271 %10:sreg_32 = S_MOV_B32 0
272 %11:sreg_32 = V_CMP_NE_U32_e64 0, %8, implicit $exec
273 %0:sreg_32 = SI_IF killed %11, %bb.5, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
277 successors: %bb.6(0x80000000)
279 %13:sreg_32 = COPY $exec_lo
280 %1:sreg_32 = COPY %13
281 %25:sreg_32 = COPY killed %10
282 %26:sreg_32 = COPY killed %1
286 successors: %bb.3(0x80000000)
288 %23:sgpr_128 = REG_SEQUENCE killed %19, %subreg.sub0, %19, %subreg.sub1, %19, %subreg.sub2, %19, %subreg.sub3
289 %24:vgpr_32 = COPY killed %4
290 BUFFER_ATOMIC_ADD_OFFSET killed %24, killed %23, 0, 0, 0, implicit $exec :: (volatile dereferenceable load store (s32), align 1, addrspace 8)
293 successors: %bb.5(0x80000000)
295 SI_END_CF killed %7, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
302 successors: %bb.4(0x80000000)
304 SI_END_CF killed %0, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
308 successors: %bb.7(0x04000000), %bb.6(0x7c000000)
310 %2:sreg_32 = COPY killed %25
311 %3:sreg_32 = COPY killed %26
312 %14:sreg_32 = S_FF1_I32_B32 %3
313 %15:sreg_32 = V_READLANE_B32 %8, %14
314 %4:sreg_32 = S_ADD_I32 killed %2, killed %15, implicit-def dead $scc
315 %17:sreg_32 = S_LSHL_B32 1, killed %14, implicit-def dead $scc
316 %5:sreg_32 = S_ANDN2_B32 killed %3, killed %17, implicit-def dead $scc
317 S_CMP_LG_U32 %5, 0, implicit-def $scc
318 %25:sreg_32 = COPY %4
319 %26:sreg_32 = COPY killed %5
320 S_CBRANCH_SCC1 %bb.6, implicit killed $scc
324 successors: %bb.2(0x40000000), %bb.3(0x40000000)
326 %19:sreg_32 = S_MOV_B32 0
327 %20:vgpr_32 = V_MBCNT_LO_U32_B32_e64 killed %13, 0, implicit $exec
328 %21:sreg_32 = V_CMP_EQ_U32_e64 0, killed %20, implicit $exec
329 %7:sreg_32 = SI_IF killed %21, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec