1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -march=amdgcn -verify-machineinstrs -run-pass=si-lower-control-flow -amdgpu-remove-redundant-endcf %s -o - | FileCheck -check-prefix=GCN %s
4 # Make sure dbg_value doesn't change codeegn when collapsing end_cf
6 name: simple_nested_if_dbg_value
7 tracksRegLiveness: true
11 ; GCN-LABEL: name: simple_nested_if_dbg_value
13 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.4(0x40000000)
15 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
16 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
17 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
18 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
21 ; GCN-NEXT: successors: %bb.2(0x40000000), %bb.4(0x40000000)
23 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
24 ; GCN-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY1]], undef %3:sreg_64, implicit-def dead $scc
25 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
26 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
29 ; GCN-NEXT: successors: %bb.4(0x80000000)
33 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY]], implicit-def $scc
35 ; GCN-NEXT: S_ENDPGM 0
37 successors: %bb.1, %bb.4
39 %0:sreg_64 = SI_IF undef %1:sreg_64, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
42 successors: %bb.2, %bb.3
44 %2:sreg_64 = SI_IF undef %3:sreg_64, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
49 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
54 SI_END_CF %0:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
59 # Empty block separates the collapsable s_or_b64
61 name: simple_nested_if_empty_block_between
62 tracksRegLiveness: true
66 ; GCN-LABEL: name: simple_nested_if_empty_block_between
68 ; GCN-NEXT: successors: %bb.5(0x40000000), %bb.1(0x40000000)
70 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
71 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
72 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
73 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.5, implicit $exec
76 ; GCN-NEXT: successors: %bb.2(0x40000000), %bb.4(0x40000000)
78 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
79 ; GCN-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY1]], undef %3:sreg_64, implicit-def dead $scc
80 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
81 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
84 ; GCN-NEXT: successors: %bb.4(0x80000000)
88 ; GCN-NEXT: successors: %bb.5(0x80000000)
92 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY]], implicit-def $scc
93 ; GCN-NEXT: S_ENDPGM 0
95 %0:sreg_64 = SI_IF undef %1:sreg_64, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
98 successors: %bb.2, %bb.3
100 %2:sreg_64 = SI_IF undef %3:sreg_64, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
105 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
110 SI_END_CF %0:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
115 # Effectively empty block separates the collapsable s_or_b64
117 name: simple_nested_if_empty_block_dbg_between
118 tracksRegLiveness: true
120 isEntryFunction: true
122 ; GCN-LABEL: name: simple_nested_if_empty_block_dbg_between
124 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.5(0x40000000)
126 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
127 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
128 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
129 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.5, implicit $exec
132 ; GCN-NEXT: successors: %bb.2(0x40000000), %bb.4(0x40000000)
134 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
135 ; GCN-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY1]], undef %3:sreg_64, implicit-def dead $scc
136 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
137 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
140 ; GCN-NEXT: successors: %bb.4(0x80000000)
144 ; GCN-NEXT: successors: %bb.5(0x80000000)
146 ; GCN-NEXT: DBG_VALUE
149 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY]], implicit-def $scc
150 ; GCN-NEXT: S_ENDPGM 0
152 successors: %bb.1, %bb.4
154 %0:sreg_64 = SI_IF undef %1:sreg_64, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
157 successors: %bb.2, %bb.3
159 %2:sreg_64 = SI_IF undef %3:sreg_64, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
164 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
170 SI_END_CF %0:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
176 name: skip_salu_and_meta_insts_find_first
177 tracksRegLiveness: true
179 isEntryFunction: true
181 ; GCN-LABEL: name: skip_salu_and_meta_insts_find_first
183 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.4(0x40000000)
184 ; GCN-NEXT: liveins: $vgpr0, $sgpr0_sgpr1
186 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
187 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
188 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
189 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
192 ; GCN-NEXT: successors: %bb.2(0x40000000), %bb.3(0x40000000)
194 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
195 ; GCN-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY1]], undef %3:sreg_64, implicit-def dead $scc
196 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
197 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.3, implicit $exec
200 ; GCN-NEXT: successors: %bb.3(0x80000000)
204 ; GCN-NEXT: successors: %bb.4(0x80000000)
206 ; GCN-NEXT: [[DEF:%[0-9]+]]:sgpr_32 = IMPLICIT_DEF
207 ; GCN-NEXT: [[S_BREV_B32_:%[0-9]+]]:sgpr_32 = S_BREV_B32 [[DEF]]
208 ; GCN-NEXT: KILL [[DEF]]
211 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY]], implicit-def $scc
212 ; GCN-NEXT: S_ENDPGM 0
214 successors: %bb.1, %bb.4
215 liveins: $vgpr0, $sgpr0_sgpr1
217 %0:sreg_64 = SI_IF undef %1:sreg_64, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
220 successors: %bb.2, %bb.3
222 %2:sreg_64 = SI_IF undef %3:sreg_64, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
227 %4:sgpr_32 = IMPLICIT_DEF
228 %5:sgpr_32 = S_BREV_B32 %4
230 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
233 SI_END_CF %0:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
238 # Make sure SALU instructions, meta instructions, and SGPR->SGPR
239 # copies are skipped.
241 name: skip_salu_and_meta_insts_after
242 tracksRegLiveness: true
244 isEntryFunction: true
246 ; GCN-LABEL: name: skip_salu_and_meta_insts_after
248 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.4(0x40000000)
250 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
251 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
252 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
253 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
256 ; GCN-NEXT: successors: %bb.2(0x40000000), %bb.3(0x40000000)
258 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
259 ; GCN-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY1]], undef %3:sreg_64, implicit-def dead $scc
260 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
261 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.3, implicit $exec
264 ; GCN-NEXT: successors: %bb.3(0x80000000)
268 ; GCN-NEXT: successors: %bb.4(0x80000000)
270 ; GCN-NEXT: [[DEF:%[0-9]+]]:sgpr_32 = IMPLICIT_DEF
271 ; GCN-NEXT: [[S_BREV_B32_:%[0-9]+]]:sgpr_32 = S_BREV_B32 [[DEF]]
272 ; GCN-NEXT: KILL [[DEF]]
273 ; GCN-NEXT: [[COPY2:%[0-9]+]]:sgpr_32 = COPY [[S_BREV_B32_]]
276 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY]], implicit-def $scc
277 ; GCN-NEXT: S_ENDPGM 0
279 successors: %bb.1, %bb.4
281 %0:sreg_64 = SI_IF undef %1:sreg_64, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
284 successors: %bb.2, %bb.3
286 %2:sreg_64 = SI_IF undef %3:sreg_64, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
291 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
292 %4:sgpr_32 = IMPLICIT_DEF
293 %5:sgpr_32 = S_BREV_B32 %4
298 SI_END_CF %0:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
303 # SALU instruction depends on exec through a normal operand.
305 name: salu_exec_dependency
306 tracksRegLiveness: true
308 isEntryFunction: true
310 ; GCN-LABEL: name: salu_exec_dependency
312 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.4(0x40000000)
314 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
315 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
316 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
317 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
320 ; GCN-NEXT: successors: %bb.2(0x40000000), %bb.3(0x40000000)
322 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
323 ; GCN-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY1]], undef %3:sreg_64, implicit-def dead $scc
324 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
325 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.3, implicit $exec
328 ; GCN-NEXT: successors: %bb.3(0x80000000)
332 ; GCN-NEXT: successors: %bb.4(0x80000000)
334 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY1]], implicit-def $scc
335 ; GCN-NEXT: [[S_BREV_B64_:%[0-9]+]]:sreg_64 = S_BREV_B64 $exec
338 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY]], implicit-def $scc
339 ; GCN-NEXT: S_ENDPGM 0
341 successors: %bb.1, %bb.4
343 %0:sreg_64 = SI_IF undef %1:sreg_64, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
346 successors: %bb.2, %bb.3
348 %2:sreg_64 = SI_IF undef %3:sreg_64, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
353 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
354 %4:sreg_64 = S_BREV_B64 $exec
357 SI_END_CF %0:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
362 # Copy to / from VGPR should be assumed to read exec
364 name: copy_no_explicit_exec_dependency
365 tracksRegLiveness: true
367 isEntryFunction: true
369 ; GCN-LABEL: name: copy_no_explicit_exec_dependency
371 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.4(0x40000000)
373 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
374 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
375 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
376 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
379 ; GCN-NEXT: successors: %bb.2(0x40000000), %bb.3(0x40000000)
381 ; GCN-NEXT: [[DEF:%[0-9]+]]:vreg_128 = IMPLICIT_DEF
382 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
383 ; GCN-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY1]], undef %4:sreg_64, implicit-def dead $scc
384 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
385 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.3, implicit $exec
388 ; GCN-NEXT: successors: %bb.3(0x80000000)
392 ; GCN-NEXT: successors: %bb.4(0x80000000)
394 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY1]], implicit-def $scc
395 ; GCN-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY [[DEF]].sub2
398 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY]], implicit-def $scc
399 ; GCN-NEXT: S_ENDPGM 0
401 successors: %bb.1, %bb.4
403 %0:sreg_64 = SI_IF undef %1:sreg_64, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
406 successors: %bb.2, %bb.3
408 %2:vreg_128 = IMPLICIT_DEF
409 %3:sreg_64 = SI_IF undef %4:sreg_64, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
414 SI_END_CF %3:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
415 %5:vgpr_32 = COPY %2.sub2
418 SI_END_CF %0:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
424 name: simple_nested_if_not_layout_successor
425 tracksRegLiveness: true
427 isEntryFunction: true
429 ; GCN-LABEL: name: simple_nested_if_not_layout_successor
431 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.4(0x40000000)
433 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
434 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
435 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
436 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
439 ; GCN-NEXT: successors: %bb.2(0x40000000), %bb.5(0x40000000)
441 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
442 ; GCN-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY1]], undef %3:sreg_64, implicit-def dead $scc
443 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
444 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.5, implicit $exec
447 ; GCN-NEXT: successors: %bb.5(0x80000000)
449 ; GCN-NEXT: S_BRANCH %bb.5
452 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY]], implicit-def $scc
453 ; GCN-NEXT: S_ENDPGM 0
456 ; GCN-NEXT: successors: %bb.4(0x80000000)
458 ; GCN-NEXT: S_BRANCH %bb.4
460 successors: %bb.1, %bb.4
462 %0:sreg_64 = SI_IF undef %1:sreg_64, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
465 successors: %bb.2, %bb.3
467 %2:sreg_64 = SI_IF undef %3:sreg_64, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
472 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
476 SI_END_CF %0:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
484 # This should never happen, but check that we do not hang anyway
487 name: resursive_endcf
488 tracksRegLiveness: true
490 - { reg: '$vgpr0', virtual-reg: '%0' }
492 isEntryFunction: true
494 ; GCN-LABEL: name: resursive_endcf
496 ; GCN-NEXT: successors: %bb.1(0x80000000)
497 ; GCN-NEXT: liveins: $vgpr0
499 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
500 ; GCN-NEXT: [[V_CMP_LT_U32_e64_:%[0-9]+]]:sreg_64 = V_CMP_LT_U32_e64 1, [[COPY]], implicit $exec
503 ; GCN-NEXT: successors: %bb.1(0x80000000)
505 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[V_CMP_LT_U32_e64_]], implicit-def $scc
506 ; GCN-NEXT: S_BRANCH %bb.1
511 %0:vgpr_32 = COPY $vgpr0
512 %2:sreg_64 = V_CMP_LT_U32_e64 1, %0, implicit $exec
517 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
522 # Both s_or_b64 shall be preserved since the outer SI_END_CF belongs to SI_ELSE.
525 name: simple_outer_if_else
526 tracksRegLiveness: true
528 isEntryFunction: true
530 ; GCN-LABEL: name: simple_outer_if_else
532 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
534 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
535 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
536 ; GCN-NEXT: [[S_XOR_B64_:%[0-9]+]]:sreg_64 = S_XOR_B64 [[S_AND_B64_]], [[COPY]], implicit-def dead $scc
537 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
538 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.2, implicit $exec
541 ; GCN-NEXT: successors: %bb.2(0x80000000)
543 ; GCN-NEXT: S_BRANCH %bb.2
546 ; GCN-NEXT: successors: %bb.3(0x40000000), %bb.6(0x40000000)
548 ; GCN-NEXT: [[S_OR_SAVEEXEC_B64_:%[0-9]+]]:sreg_64 = S_OR_SAVEEXEC_B64 [[S_XOR_B64_]], implicit-def $exec, implicit-def $scc, implicit $exec
549 ; GCN-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 $exec, [[S_OR_SAVEEXEC_B64_]], implicit-def $scc
550 ; GCN-NEXT: $exec = S_XOR_B64_term $exec, [[S_AND_B64_1]], implicit-def $scc
551 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.6, implicit $exec
554 ; GCN-NEXT: successors: %bb.3(0x40000000), %bb.4(0x40000000)
556 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
557 ; GCN-NEXT: [[S_AND_B64_2:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY1]], undef %4:sreg_64, implicit-def dead $scc
558 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_2]]
559 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.3, implicit $exec
562 ; GCN-NEXT: successors: %bb.5(0x80000000)
566 ; GCN-NEXT: successors: %bb.6(0x80000000)
568 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY1]], implicit-def $scc
571 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[S_AND_B64_1]], implicit-def $scc
572 ; GCN-NEXT: S_ENDPGM 0
574 successors: %bb.1, %bb.2
576 %0:sreg_64 = SI_IF undef %1:sreg_64, %bb.2, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
583 successors: %bb.3, %bb.6
584 %2:sreg_64 = SI_ELSE %0:sreg_64, %bb.6, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
587 successors: %bb.3, %bb.4
589 %3:sreg_64 = SI_IF undef %4:sreg_64, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
597 SI_END_CF %3:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
600 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
607 tracksRegLiveness: true
609 isEntryFunction: true
611 ; GCN-LABEL: name: if_inside_loop
613 ; GCN-NEXT: successors: %bb.6(0x80000000)
615 ; GCN-NEXT: S_BRANCH %bb.6
618 ; GCN-NEXT: successors: %bb.3(0x40000000), %bb.2(0x40000000)
620 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
621 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
622 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
623 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.3, implicit $exec
626 ; GCN-NEXT: successors: %bb.6(0x80000000)
628 ; GCN-NEXT: S_BRANCH %bb.6
631 ; GCN-NEXT: successors: %bb.4(0x80000000)
633 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY]], implicit-def $scc
636 ; GCN-NEXT: successors: %bb.5(0x80000000)
638 ; GCN-NEXT: $exec = S_OR_B64 $exec, %2, implicit-def $scc
641 ; GCN-NEXT: successors: %bb.6(0x80000000)
645 ; GCN-NEXT: successors: %bb.4(0x40000000), %bb.0(0x40000000)
647 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
648 ; GCN-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY1]], undef %3:sreg_64, implicit-def dead $scc
649 ; GCN-NEXT: [[S_XOR_B64_:%[0-9]+]]:sreg_64 = S_XOR_B64 [[S_AND_B64_1]], [[COPY1]], implicit-def dead $scc
650 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
651 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
652 ; GCN-NEXT: S_BRANCH %bb.0
653 ; GCN-NEXT: S_ENDPGM 0
658 %0:sreg_64 = SI_IF undef %1:sreg_64, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
664 SI_END_CF %0:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
667 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
672 %2:sreg_64 = SI_IF undef %3:sreg_64, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
679 # redundant MBB removal correctness test:
680 # we can keep bb.2 fallthrough to the new succ because after bb.3 gets removed
681 # new succ (bb.4) becomes bb.2's layout successor
682 name: removed_succ_fallthrough_but_layout_successor
683 tracksRegLiveness: true
685 isEntryFunction: true
687 ; GCN-LABEL: name: removed_succ_fallthrough_but_layout_successor
689 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.4(0x40000000)
691 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
692 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
693 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
694 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
697 ; GCN-NEXT: successors: %bb.2(0x40000000), %bb.4(0x40000000)
699 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
700 ; GCN-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY1]], undef %3:sreg_64, implicit-def dead $scc
701 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
702 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
705 ; GCN-NEXT: successors: %bb.4(0x80000000)
709 ; GCN-NEXT: successors: %bb.5(0x80000000)
711 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY]], implicit-def $scc
714 ; GCN-NEXT: S_ENDPGM 0
716 successors: %bb.1, %bb.4
718 %0:sreg_64 = SI_IF undef %1:sreg_64, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
721 successors: %bb.2, %bb.3
723 %2:sreg_64 = SI_IF undef %3:sreg_64, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
728 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
732 SI_END_CF %0:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
740 # redundant MBB removal correctness test:
741 # If one of the remdundant block preds has a fallthrough path, but the only redundant block succ is not
742 # going to be a layout successor to that pred after redundant block removal, we should not rearrange
743 # blocks to keep pred's fallthrough path, if the succ has fallthrough path to one of it's succ too.
745 name: deleted_succ_fallthrough_not_layout_successor
746 tracksRegLiveness: true
748 isEntryFunction: true
750 ; GCN-LABEL: name: deleted_succ_fallthrough_not_layout_successor
752 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.4(0x40000000)
754 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
755 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
756 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
757 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
760 ; GCN-NEXT: successors: %bb.2(0x40000000), %bb.5(0x40000000)
762 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
763 ; GCN-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY1]], undef %3:sreg_64, implicit-def dead $scc
764 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
765 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.5, implicit $exec
768 ; GCN-NEXT: successors: %bb.5(0x80000000)
770 ; GCN-NEXT: S_BRANCH %bb.5
773 ; GCN-NEXT: S_ENDPGM 0
776 ; GCN-NEXT: successors: %bb.6(0x80000000)
778 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY]], implicit-def $scc
781 ; GCN-NEXT: successors: %bb.4(0x80000000)
783 ; GCN-NEXT: S_BRANCH %bb.4
785 successors: %bb.1, %bb.4
787 %0:sreg_64 = SI_IF undef %1:sreg_64, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
790 successors: %bb.2, %bb.3
792 %2:sreg_64 = SI_IF undef %3:sreg_64, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
797 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
805 SI_END_CF %0:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
812 # While collapsing inner endcf, certain blocks ended up getting two S_BRANCH instructions.
813 # It happens in the absence of BranchFolding (mostly at -O0) when the irregularly placed BBs are traversed
814 # in the forward direction and the intervening block between a predecessor and its successor gets optimized
815 # away in subsequent iterations, leaving 2 S_BRANCH instructions in the predecessor block.
816 # The issue was fixed by iterating the blocks from bottom-up to ensure all endcf pseudos at the bottom of the
817 # function are processed first.
818 # This test ensures there are no multiple S_BRANCH instructions inserted in any block.
820 name: no_multiple_unconditional_branches
821 tracksRegLiveness: true
823 ; GCN-LABEL: name: no_multiple_unconditional_branches
825 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.14(0x40000000)
827 ; GCN-NEXT: [[DEF:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
828 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64 = V_CMP_EQ_U32_e64 0, killed [[DEF]], implicit $exec
829 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
830 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
831 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
832 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.14, implicit $exec
833 ; GCN-NEXT: S_BRANCH %bb.1
836 ; GCN-NEXT: successors: %bb.2(0x40000000), %bb.14(0x40000000)
838 ; GCN-NEXT: [[DEF1:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
839 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_1:%[0-9]+]]:sreg_64 = V_CMP_EQ_U32_e64 0, killed [[DEF1]], implicit $exec
840 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
841 ; GCN-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY1]], killed [[V_CMP_EQ_U32_e64_1]], implicit-def dead $scc
842 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
843 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.14, implicit $exec
844 ; GCN-NEXT: S_BRANCH %bb.2
847 ; GCN-NEXT: successors: %bb.3(0x40000000), %bb.7(0x40000000)
849 ; GCN-NEXT: [[DEF2:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
850 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_2:%[0-9]+]]:sreg_64 = V_CMP_EQ_U32_e64 0, killed [[DEF2]], implicit $exec
851 ; GCN-NEXT: [[COPY2:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
852 ; GCN-NEXT: [[S_AND_B64_2:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY2]], killed [[V_CMP_EQ_U32_e64_2]], implicit-def dead $scc
853 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_2]]
854 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.7, implicit $exec
855 ; GCN-NEXT: S_BRANCH %bb.3
858 ; GCN-NEXT: successors: %bb.4(0x40000000), %bb.7(0x40000000)
860 ; GCN-NEXT: [[DEF3:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
861 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_3:%[0-9]+]]:sreg_64 = V_CMP_EQ_U32_e64 0, killed [[DEF3]], implicit $exec
862 ; GCN-NEXT: [[COPY3:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
863 ; GCN-NEXT: [[S_AND_B64_3:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY3]], killed [[V_CMP_EQ_U32_e64_3]], implicit-def dead $scc
864 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_3]]
865 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.7, implicit $exec
866 ; GCN-NEXT: S_BRANCH %bb.4
869 ; GCN-NEXT: successors: %bb.7(0x80000000)
871 ; GCN-NEXT: S_BRANCH %bb.7
874 ; GCN-NEXT: successors: %bb.8(0x80000000)
876 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY2]], implicit-def $scc
877 ; GCN-NEXT: S_BRANCH %bb.8
880 ; GCN-NEXT: successors: %bb.9(0x80000000)
882 ; GCN-NEXT: S_BRANCH %bb.9
885 ; GCN-NEXT: successors: %bb.11(0x40000000), %bb.12(0x40000000)
887 ; GCN-NEXT: [[DEF4:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
888 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_4:%[0-9]+]]:sreg_64 = V_CMP_EQ_U32_e64 0, killed [[DEF4]], implicit $exec
889 ; GCN-NEXT: [[COPY4:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
890 ; GCN-NEXT: [[S_AND_B64_4:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY4]], killed [[V_CMP_EQ_U32_e64_4]], implicit-def dead $scc
891 ; GCN-NEXT: [[S_XOR_B64_:%[0-9]+]]:sreg_64 = S_XOR_B64 [[S_AND_B64_4]], [[COPY4]], implicit-def dead $scc
892 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_4]]
893 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.12, implicit $exec
894 ; GCN-NEXT: S_BRANCH %bb.11
897 ; GCN-NEXT: successors: %bb.14(0x80000000)
899 ; GCN-NEXT: S_BRANCH %bb.14
902 ; GCN-NEXT: successors: %bb.12(0x80000000)
904 ; GCN-NEXT: S_BRANCH %bb.12
907 ; GCN-NEXT: successors: %bb.10(0x40000000), %bb.14(0x40000000)
909 ; GCN-NEXT: [[S_OR_SAVEEXEC_B64_:%[0-9]+]]:sreg_64 = S_OR_SAVEEXEC_B64 [[S_XOR_B64_]], implicit-def $exec, implicit-def $scc, implicit $exec
910 ; GCN-NEXT: [[S_AND_B64_5:%[0-9]+]]:sreg_64 = S_AND_B64 $exec, [[S_OR_SAVEEXEC_B64_]], implicit-def $scc
911 ; GCN-NEXT: $exec = S_XOR_B64_term $exec, [[S_AND_B64_5]], implicit-def $scc
912 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.14, implicit $exec
913 ; GCN-NEXT: S_BRANCH %bb.10
916 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY]], implicit-def $scc
917 ; GCN-NEXT: S_ENDPGM 0
919 successors: %bb.1, %bb.14
921 %0:vgpr_32 = IMPLICIT_DEF
922 %1:sreg_64 = V_CMP_EQ_U32_e64 0, killed %0:vgpr_32, implicit $exec
923 %2:sreg_64 = SI_IF %1:sreg_64, %bb.14, implicit-def $exec, implicit-def dead $scc, implicit $exec
927 successors: %bb.2, %bb.6
929 %3:vgpr_32 = IMPLICIT_DEF
930 %4:sreg_64 = V_CMP_EQ_U32_e64 0, killed %3:vgpr_32, implicit $exec
931 %5:sreg_64 = SI_IF killed %4:sreg_64, %bb.6, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
935 successors: %bb.3, %bb.7
937 %6:vgpr_32 = IMPLICIT_DEF
938 %7:sreg_64 = V_CMP_EQ_U32_e64 0, killed %6:vgpr_32, implicit $exec
939 %8:sreg_64 = SI_IF killed %7:sreg_64, %bb.7, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
943 successors: %bb.4, %bb.5
945 %9:vgpr_32 = IMPLICIT_DEF
946 %10:sreg_64 = V_CMP_EQ_U32_e64 0, killed %9:vgpr_32, implicit $exec
947 %11:sreg_64 = SI_IF killed %10:sreg_64, %bb.5, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
958 SI_END_CF %11:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
964 SI_END_CF %5:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
970 SI_END_CF %8:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
979 successors: %bb.11, %bb.12
981 %12:vgpr_32 = IMPLICIT_DEF
982 %13:sreg_64 = V_CMP_EQ_U32_e64 0, killed %12:vgpr_32, implicit $exec
983 %14:sreg_64 = SI_IF killed %13:sreg_64, %bb.12, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
997 successors: %bb.10, %bb.13
999 %15:sreg_64 = SI_ELSE %14:sreg_64, %bb.13, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
1005 SI_END_CF %15:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
1010 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec