1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=amdgcn-amd-amdhsa -run-pass=liveintervals,si-lower-control-flow,si-lower-control-flow -verify-machineinstrs %s -o - | FileCheck -check-prefixes=GCN %s
4 # Check that assert is not triggered
7 name: si-lower-control-flow
10 ; GCN-LABEL: name: si-lower-control-flow
11 ; GCN: [[COPY:%[0-9]+]]:sgpr_64 = COPY $sgpr4_sgpr5
12 ; GCN-NEXT: [[S_LOAD_DWORD_IMM:%[0-9]+]]:sreg_32_xm0_xexec = S_LOAD_DWORD_IMM [[COPY]], 16, 0
13 ; GCN-NEXT: [[S_AND_B32_:%[0-9]+]]:sreg_32_xm0 = S_AND_B32 [[S_LOAD_DWORD_IMM]], 255, implicit-def $scc
14 ; GCN-NEXT: dead [[S_AND_B32_1:%[0-9]+]]:sreg_32_xm0 = S_AND_B32 65535, [[S_AND_B32_]], implicit-def $scc
15 ; GCN-NEXT: S_ENDPGM 0
16 %0:sgpr_64 = COPY $sgpr4_sgpr5
17 %1:sreg_32_xm0_xexec = S_LOAD_DWORD_IMM %0, 16, 0
18 %2:sreg_32_xm0 = S_AND_B32 %1, 255, implicit-def $scc
19 %3:sreg_32_xm0 = S_AND_B32 65535, %2, implicit-def $scc
24 name: preserve_undef_flag_si_if_src
25 tracksRegLiveness: true
27 ; GCN-LABEL: name: preserve_undef_flag_si_if_src
29 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
31 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
32 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
33 ; GCN-NEXT: dead [[S_XOR_B64_:%[0-9]+]]:sreg_64 = S_XOR_B64 [[S_AND_B64_]], [[COPY]], implicit-def dead $scc
34 ; GCN-NEXT: $exec = S_MOV_B64_term [[S_AND_B64_]]
35 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.2, implicit $exec
36 ; GCN-NEXT: S_BRANCH %bb.1
39 ; GCN-NEXT: successors: %bb.2(0x80000000)
42 ; GCN-NEXT: S_ENDPGM 0
44 successors: %bb.1, %bb.2
46 %1:sreg_64 = SI_IF undef %0:sreg_64, %bb.2, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
57 # We need to split the block for SI_END_CF, but
59 name: end_cf_split_block_end
60 tracksRegLiveness: true
62 ; GCN-LABEL: name: end_cf_split_block_end
64 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
65 ; GCN-NEXT: liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31
67 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
68 ; GCN-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
69 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
70 ; GCN-NEXT: [[COPY2:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
71 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY2]], [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
72 ; GCN-NEXT: [[S_XOR_B64_:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[S_AND_B64_]], [[COPY2]], implicit-def dead $scc
73 ; GCN-NEXT: $exec = S_MOV_B64_term [[S_AND_B64_]]
74 ; GCN-NEXT: [[S_MOV_B64_term:%[0-9]+]]:sreg_64_xexec = S_MOV_B64_term [[S_XOR_B64_]], implicit $exec
75 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.1, implicit $exec
76 ; GCN-NEXT: S_BRANCH %bb.2
79 ; GCN-NEXT: successors: %bb.2(0x80000000)
81 ; GCN-NEXT: [[COPY3:%[0-9]+]]:sreg_64_xexec = COPY [[S_MOV_B64_term]]
82 ; GCN-NEXT: $exec = S_OR_B64_term $exec, [[COPY3]], implicit-def $scc
85 ; GCN-NEXT: S_ENDPGM 0
87 liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31
89 %0:vgpr_32 = COPY killed $vgpr0
90 %1:vgpr_32 = COPY killed $vgpr1
91 %3:sreg_64_xexec = V_CMP_EQ_U32_e64 killed %0, killed %1, implicit $exec
92 %4:sreg_64_xexec = SI_IF %3, %bb.1, implicit-def $exec, implicit-def dead $scc, implicit $exec
93 %5:sreg_64_xexec = S_MOV_B64_term %4, implicit $exec
99 %6:sreg_64_xexec = COPY %5
100 SI_END_CF killed %6, implicit-def $exec, implicit-def dead $scc, implicit $exec
108 name: end_cf_split_block_physreg_livein
109 tracksRegLiveness: true
111 ; GCN-LABEL: name: end_cf_split_block_physreg_livein
113 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
114 ; GCN-NEXT: liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31, $sgpr4_sgpr5
116 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
117 ; GCN-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
118 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
119 ; GCN-NEXT: [[COPY2:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
120 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY2]], [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
121 ; GCN-NEXT: [[S_XOR_B64_:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[S_AND_B64_]], [[COPY2]], implicit-def dead $scc
122 ; GCN-NEXT: $exec = S_MOV_B64_term [[S_AND_B64_]]
123 ; GCN-NEXT: [[S_MOV_B64_term:%[0-9]+]]:sreg_64_xexec = S_MOV_B64_term [[S_XOR_B64_]], implicit $exec
124 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.1, implicit $exec
125 ; GCN-NEXT: S_BRANCH %bb.2
128 ; GCN-NEXT: successors: %bb.3(0x80000000)
129 ; GCN-NEXT: liveins: $vgpr0, $sgpr4_sgpr5
131 ; GCN-NEXT: [[COPY3:%[0-9]+]]:sreg_64_xexec = COPY [[S_MOV_B64_term]]
133 ; GCN-NEXT: $exec = S_OR_B64_term $exec, [[COPY3]], implicit-def $scc
136 ; GCN-NEXT: successors: %bb.2(0x80000000)
137 ; GCN-NEXT: liveins: $vgpr0, $sgpr4_sgpr5
139 ; GCN-NEXT: S_SLEEP 3
140 ; GCN-NEXT: S_NOP 0, implicit $vgpr0, implicit $sgpr4_sgpr5
143 ; GCN-NEXT: S_ENDPGM 0
145 liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31, $sgpr4_sgpr5
147 %0:vgpr_32 = COPY killed $vgpr0
148 %1:vgpr_32 = COPY killed $vgpr1
149 %3:sreg_64_xexec = V_CMP_EQ_U32_e64 killed %0, killed %1, implicit $exec
150 %4:sreg_64_xexec = SI_IF %3, %bb.1, implicit-def $exec, implicit-def dead $scc, implicit $exec
151 %5:sreg_64_xexec = S_MOV_B64_term %4, implicit $exec
156 liveins: $vgpr0, $sgpr4_sgpr5
158 %6:sreg_64_xexec = COPY %5
160 SI_END_CF killed %6, implicit-def $exec, implicit-def dead $scc, implicit $exec
162 S_NOP 0, implicit $vgpr0, implicit $sgpr4_sgpr5
170 name: end_cf_split_block_physreg_livein_liveout
171 tracksRegLiveness: true
173 ; GCN-LABEL: name: end_cf_split_block_physreg_livein_liveout
175 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
176 ; GCN-NEXT: liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31, $sgpr4_sgpr5, $sgpr8_sgpr9_sgpr10_sgpr11:0x0000000000000003
178 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
179 ; GCN-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
180 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
181 ; GCN-NEXT: [[COPY2:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
182 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY2]], [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
183 ; GCN-NEXT: [[S_XOR_B64_:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[S_AND_B64_]], [[COPY2]], implicit-def dead $scc
184 ; GCN-NEXT: $exec = S_MOV_B64_term [[S_AND_B64_]]
185 ; GCN-NEXT: [[S_MOV_B64_term:%[0-9]+]]:sreg_64_xexec = S_MOV_B64_term [[S_XOR_B64_]], implicit $exec
186 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.1, implicit $exec
187 ; GCN-NEXT: S_BRANCH %bb.2
190 ; GCN-NEXT: successors: %bb.3(0x80000000)
191 ; GCN-NEXT: liveins: $vgpr0, $sgpr4_sgpr5, $sgpr8_sgpr9_sgpr10_sgpr11:0x0000000000000003
193 ; GCN-NEXT: [[COPY3:%[0-9]+]]:sreg_64_xexec = COPY [[S_MOV_B64_term]]
194 ; GCN-NEXT: $exec = S_OR_B64_term $exec, [[COPY3]], implicit-def $scc
197 ; GCN-NEXT: successors: %bb.2(0x80000000)
198 ; GCN-NEXT: liveins: $vgpr0, $sgpr4_sgpr5, $sgpr8_sgpr9_sgpr10
200 ; GCN-NEXT: S_SLEEP 3
204 ; GCN-NEXT: liveins: $vgpr0, $sgpr4_sgpr5, $sgpr8_sgpr9_sgpr10_sgpr11:0x0000000000000003
206 ; GCN-NEXT: S_ENDPGM 0, implicit $vgpr0, implicit $sgpr4_sgpr5, implicit $sgpr8_sgpr9_sgpr10_sgpr11
208 liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31, $sgpr4_sgpr5, $sgpr8_sgpr9_sgpr10_sgpr11:0x00000003
210 %0:vgpr_32 = COPY killed $vgpr0
211 %1:vgpr_32 = COPY killed $vgpr1
212 %3:sreg_64_xexec = V_CMP_EQ_U32_e64 killed %0, killed %1, implicit $exec
213 %4:sreg_64_xexec = SI_IF %3, %bb.1, implicit-def $exec, implicit-def dead $scc, implicit $exec
214 %5:sreg_64_xexec = S_MOV_B64_term %4, implicit $exec
219 liveins: $vgpr0, $sgpr4_sgpr5, $sgpr8_sgpr9_sgpr10_sgpr11:0x00000003
221 %6:sreg_64_xexec = COPY %5
222 SI_END_CF killed %6, implicit-def $exec, implicit-def dead $scc, implicit $exec
227 liveins: $vgpr0, $sgpr4_sgpr5, $sgpr8_sgpr9_sgpr10_sgpr11:0x00000003
228 S_ENDPGM 0, implicit $vgpr0, implicit $sgpr4_sgpr5, implicit $sgpr8_sgpr9_sgpr10_sgpr11
233 name: end_cf_split_block_physreg_liveout
234 tracksRegLiveness: true
236 ; GCN-LABEL: name: end_cf_split_block_physreg_liveout
238 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
239 ; GCN-NEXT: liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31
241 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
242 ; GCN-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
243 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
244 ; GCN-NEXT: [[COPY2:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
245 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY2]], [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
246 ; GCN-NEXT: [[S_XOR_B64_:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[S_AND_B64_]], [[COPY2]], implicit-def dead $scc
247 ; GCN-NEXT: $exec = S_MOV_B64_term [[S_AND_B64_]]
248 ; GCN-NEXT: [[S_MOV_B64_term:%[0-9]+]]:sreg_64_xexec = S_MOV_B64_term [[S_XOR_B64_]], implicit $exec
249 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.1, implicit $exec
250 ; GCN-NEXT: S_BRANCH %bb.2
253 ; GCN-NEXT: successors: %bb.3(0x80000000)
255 ; GCN-NEXT: [[COPY3:%[0-9]+]]:sreg_64_xexec = COPY [[S_MOV_B64_term]]
256 ; GCN-NEXT: $exec = S_OR_B64_term $exec, [[COPY3]], implicit-def $scc
259 ; GCN-NEXT: successors: %bb.2(0x80000000)
261 ; GCN-NEXT: $vgpr3 = V_MOV_B32_e32 0, implicit $exec
262 ; GCN-NEXT: $sgpr4_sgpr5 = S_MOV_B64 32
265 ; GCN-NEXT: liveins: $vgpr3, $sgpr4_sgpr5
267 ; GCN-NEXT: S_ENDPGM 0, implicit $vgpr3, implicit $sgpr4_sgpr5
269 liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31
271 %0:vgpr_32 = COPY killed $vgpr0
272 %1:vgpr_32 = COPY killed $vgpr1
273 %3:sreg_64_xexec = V_CMP_EQ_U32_e64 killed %0, killed %1, implicit $exec
274 %4:sreg_64_xexec = SI_IF %3, %bb.1, implicit-def $exec, implicit-def dead $scc, implicit $exec
275 %5:sreg_64_xexec = S_MOV_B64_term %4, implicit $exec
281 %6:sreg_64_xexec = COPY %5
282 SI_END_CF killed %6, implicit-def $exec, implicit-def dead $scc, implicit $exec
283 $vgpr3 = V_MOV_B32_e32 0, implicit $exec
284 $sgpr4_sgpr5 = S_MOV_B64 32
287 liveins: $vgpr3, $sgpr4_sgpr5
288 S_ENDPGM 0, implicit $vgpr3, implicit $sgpr4_sgpr5
293 name: end_cf_split_block_physreg_live_across_split
294 tracksRegLiveness: true
296 ; GCN-LABEL: name: end_cf_split_block_physreg_live_across_split
298 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
299 ; GCN-NEXT: liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31, $sgpr4_sgpr5
301 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
302 ; GCN-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
303 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
304 ; GCN-NEXT: [[COPY2:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
305 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY2]], [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
306 ; GCN-NEXT: [[S_XOR_B64_:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[S_AND_B64_]], [[COPY2]], implicit-def dead $scc
307 ; GCN-NEXT: $exec = S_MOV_B64_term [[S_AND_B64_]]
308 ; GCN-NEXT: [[S_MOV_B64_term:%[0-9]+]]:sreg_64_xexec = S_MOV_B64_term [[S_XOR_B64_]], implicit $exec
309 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.1, implicit $exec
310 ; GCN-NEXT: S_BRANCH %bb.2
313 ; GCN-NEXT: successors: %bb.3(0x80000000)
314 ; GCN-NEXT: liveins: $vgpr0, $sgpr4_sgpr5
316 ; GCN-NEXT: [[COPY3:%[0-9]+]]:sreg_64_xexec = COPY [[S_MOV_B64_term]]
317 ; GCN-NEXT: $sgpr4_sgpr5 = S_MOV_B64 32
318 ; GCN-NEXT: $exec = S_OR_B64_term $exec, [[COPY3]], implicit-def $scc
321 ; GCN-NEXT: successors: %bb.2(0x80000000)
322 ; GCN-NEXT: liveins: $vgpr0, $sgpr4_sgpr5
324 ; GCN-NEXT: S_SLEEP 3, implicit $sgpr4_sgpr5
328 ; GCN-NEXT: liveins: $vgpr0, $sgpr4_sgpr5
330 ; GCN-NEXT: S_ENDPGM 0, implicit $vgpr0, implicit $sgpr4_sgpr5
332 liveins: $vgpr0, $vgpr1, $sgpr30_sgpr31, $sgpr4_sgpr5
334 %0:vgpr_32 = COPY killed $vgpr0
335 %1:vgpr_32 = COPY killed $vgpr1
336 %3:sreg_64_xexec = V_CMP_EQ_U32_e64 killed %0, killed %1, implicit $exec
337 %4:sreg_64_xexec = SI_IF %3, %bb.1, implicit-def $exec, implicit-def dead $scc, implicit $exec
338 %5:sreg_64_xexec = S_MOV_B64_term %4, implicit $exec
343 liveins: $vgpr0, $sgpr4_sgpr5
345 %6:sreg_64_xexec = COPY %5
346 $sgpr4_sgpr5 = S_MOV_B64 32
347 SI_END_CF killed %6, implicit-def $exec, implicit-def dead $scc, implicit $exec
348 S_SLEEP 3, implicit $sgpr4_sgpr5
352 liveins: $vgpr0, $sgpr4_sgpr5
353 S_ENDPGM 0, implicit $vgpr0, implicit $sgpr4_sgpr5
358 name: end_cf_split_block_process_next_inst
359 tracksRegLiveness: true
361 ; GCN-LABEL: name: end_cf_split_block_process_next_inst
363 ; GCN-NEXT: successors: %bb.1(0x80000000)
364 ; GCN-NEXT: liveins: $vgpr0, $vgpr1, $vgpr2
366 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
367 ; GCN-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
368 ; GCN-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
369 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY1]], implicit $exec
370 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_1:%[0-9]+]]:sreg_64_xexec = V_CMP_EQ_U32_e64 [[COPY]], [[COPY2]], implicit $exec
371 ; GCN-NEXT: dead [[S_MOV_B64_:%[0-9]+]]:sreg_64_xexec = S_MOV_B64 0
374 ; GCN-NEXT: successors: %bb.3(0x80000000)
376 ; GCN-NEXT: [[COPY3:%[0-9]+]]:sreg_64_xexec = COPY [[V_CMP_EQ_U32_e64_]]
377 ; GCN-NEXT: $exec = S_OR_B64_term $exec, [[COPY3]], implicit-def $scc
380 ; GCN-NEXT: successors: %bb.2(0x80000000)
382 ; GCN-NEXT: [[COPY4:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
383 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY4]], [[V_CMP_EQ_U32_e64_1]], implicit-def dead $scc
384 ; GCN-NEXT: [[S_XOR_B64_:%[0-9]+]]:sreg_64_xexec = S_XOR_B64 [[S_AND_B64_]], [[COPY4]], implicit-def dead $scc
385 ; GCN-NEXT: $exec = S_MOV_B64_term [[S_AND_B64_]]
386 ; GCN-NEXT: dead [[S_MOV_B64_term:%[0-9]+]]:sreg_64_xexec = S_MOV_B64_term [[S_XOR_B64_]], implicit $exec
387 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.2, implicit $exec
390 ; GCN-NEXT: S_ENDPGM 0
392 liveins: $vgpr0, $vgpr1, $vgpr2
394 %0:vgpr_32 = COPY killed $vgpr0
395 %1:vgpr_32 = COPY killed $vgpr1
396 %2:vgpr_32 = COPY killed $vgpr2
397 %3:sreg_64_xexec = V_CMP_EQ_U32_e64 %0, killed %1, implicit $exec
398 %4:sreg_64_xexec = V_CMP_EQ_U32_e64 killed %0, killed %2, implicit $exec
399 %5:sreg_64_xexec = S_MOV_B64 0
404 %6:sreg_64_xexec = COPY %3
405 SI_END_CF killed %6, implicit-def $exec, implicit-def dead $scc, implicit $exec
406 %7:sreg_64_xexec = SI_IF %4, %bb.2, implicit-def $exec, implicit-def dead $scc, implicit $exec
407 %8:sreg_64_xexec = S_MOV_B64_term %7, implicit $exec