1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=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)
32 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY]], implicit-def $scc
34 ; GCN-NEXT: S_ENDPGM 0
36 successors: %bb.1, %bb.4
38 %0:sreg_64 = SI_IF undef %1:sreg_64, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
41 successors: %bb.2, %bb.3
43 %2:sreg_64 = SI_IF undef %3:sreg_64, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
48 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
53 SI_END_CF %0:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
58 # Empty block separates the collapsable s_or_b64
60 name: simple_nested_if_empty_block_between
61 tracksRegLiveness: true
65 ; GCN-LABEL: name: simple_nested_if_empty_block_between
67 ; GCN-NEXT: successors: %bb.5(0x40000000), %bb.1(0x40000000)
69 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
70 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
71 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
72 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.5, implicit $exec
75 ; GCN-NEXT: successors: %bb.2(0x40000000), %bb.4(0x40000000)
77 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
78 ; GCN-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY1]], undef %3:sreg_64, implicit-def dead $scc
79 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
80 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
83 ; GCN-NEXT: successors: %bb.4(0x80000000)
86 ; GCN-NEXT: successors: %bb.5(0x80000000)
89 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY]], implicit-def $scc
90 ; GCN-NEXT: S_ENDPGM 0
92 %0:sreg_64 = SI_IF undef %1:sreg_64, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
95 successors: %bb.2, %bb.3
97 %2:sreg_64 = SI_IF undef %3:sreg_64, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
102 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
107 SI_END_CF %0:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
112 # Effectively empty block separates the collapsable s_or_b64
114 name: simple_nested_if_empty_block_dbg_between
115 tracksRegLiveness: true
117 isEntryFunction: true
119 ; GCN-LABEL: name: simple_nested_if_empty_block_dbg_between
121 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.5(0x40000000)
123 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
124 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
125 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
126 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.5, implicit $exec
129 ; GCN-NEXT: successors: %bb.2(0x40000000), %bb.4(0x40000000)
131 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
132 ; GCN-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY1]], undef %3:sreg_64, implicit-def dead $scc
133 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
134 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
137 ; GCN-NEXT: successors: %bb.4(0x80000000)
140 ; GCN-NEXT: successors: %bb.5(0x80000000)
142 ; GCN-NEXT: DBG_VALUE
145 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY]], implicit-def $scc
146 ; GCN-NEXT: S_ENDPGM 0
148 successors: %bb.1, %bb.4
150 %0:sreg_64 = SI_IF undef %1:sreg_64, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
153 successors: %bb.2, %bb.3
155 %2:sreg_64 = SI_IF undef %3:sreg_64, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
160 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
166 SI_END_CF %0:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
172 name: skip_salu_and_meta_insts_find_first
173 tracksRegLiveness: true
175 isEntryFunction: true
177 ; GCN-LABEL: name: skip_salu_and_meta_insts_find_first
179 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.4(0x40000000)
180 ; GCN-NEXT: liveins: $vgpr0, $sgpr0_sgpr1
182 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
183 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
184 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
185 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
188 ; GCN-NEXT: successors: %bb.2(0x40000000), %bb.3(0x40000000)
190 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
191 ; GCN-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY1]], undef %3:sreg_64, implicit-def dead $scc
192 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
193 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.3, implicit $exec
196 ; GCN-NEXT: successors: %bb.3(0x80000000)
199 ; GCN-NEXT: successors: %bb.4(0x80000000)
201 ; GCN-NEXT: [[DEF:%[0-9]+]]:sgpr_32 = IMPLICIT_DEF
202 ; GCN-NEXT: [[S_BREV_B32_:%[0-9]+]]:sgpr_32 = S_BREV_B32 [[DEF]]
203 ; GCN-NEXT: KILL [[DEF]]
206 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY]], implicit-def $scc
207 ; GCN-NEXT: S_ENDPGM 0
209 successors: %bb.1, %bb.4
210 liveins: $vgpr0, $sgpr0_sgpr1
212 %0:sreg_64 = SI_IF undef %1:sreg_64, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
215 successors: %bb.2, %bb.3
217 %2:sreg_64 = SI_IF undef %3:sreg_64, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
222 %4:sgpr_32 = IMPLICIT_DEF
223 %5:sgpr_32 = S_BREV_B32 %4
225 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
228 SI_END_CF %0:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
233 # Make sure SALU instructions, meta instructions, and SGPR->SGPR
234 # copies are skipped.
236 name: skip_salu_and_meta_insts_after
237 tracksRegLiveness: true
239 isEntryFunction: true
241 ; GCN-LABEL: name: skip_salu_and_meta_insts_after
243 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.4(0x40000000)
245 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
246 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
247 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
248 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
251 ; GCN-NEXT: successors: %bb.2(0x40000000), %bb.3(0x40000000)
253 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
254 ; GCN-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY1]], undef %3:sreg_64, implicit-def dead $scc
255 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
256 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.3, implicit $exec
259 ; GCN-NEXT: successors: %bb.3(0x80000000)
262 ; GCN-NEXT: successors: %bb.4(0x80000000)
264 ; GCN-NEXT: [[DEF:%[0-9]+]]:sgpr_32 = IMPLICIT_DEF
265 ; GCN-NEXT: [[S_BREV_B32_:%[0-9]+]]:sgpr_32 = S_BREV_B32 [[DEF]]
266 ; GCN-NEXT: KILL [[DEF]]
267 ; GCN-NEXT: [[COPY2:%[0-9]+]]:sgpr_32 = COPY [[S_BREV_B32_]]
270 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY]], implicit-def $scc
271 ; GCN-NEXT: S_ENDPGM 0
273 successors: %bb.1, %bb.4
275 %0:sreg_64 = SI_IF undef %1:sreg_64, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
278 successors: %bb.2, %bb.3
280 %2:sreg_64 = SI_IF undef %3:sreg_64, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
285 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
286 %4:sgpr_32 = IMPLICIT_DEF
287 %5:sgpr_32 = S_BREV_B32 %4
292 SI_END_CF %0:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
297 # SALU instruction depends on exec through a normal operand.
299 name: salu_exec_dependency
300 tracksRegLiveness: true
302 isEntryFunction: true
304 ; GCN-LABEL: name: salu_exec_dependency
306 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.4(0x40000000)
308 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
309 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
310 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
311 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
314 ; GCN-NEXT: successors: %bb.2(0x40000000), %bb.3(0x40000000)
316 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
317 ; GCN-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY1]], undef %3:sreg_64, implicit-def dead $scc
318 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
319 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.3, implicit $exec
322 ; GCN-NEXT: successors: %bb.3(0x80000000)
325 ; GCN-NEXT: successors: %bb.4(0x80000000)
327 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY1]], implicit-def $scc
328 ; GCN-NEXT: [[S_BREV_B64_:%[0-9]+]]:sreg_64 = S_BREV_B64 $exec
331 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY]], implicit-def $scc
332 ; GCN-NEXT: S_ENDPGM 0
334 successors: %bb.1, %bb.4
336 %0:sreg_64 = SI_IF undef %1:sreg_64, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
339 successors: %bb.2, %bb.3
341 %2:sreg_64 = SI_IF undef %3:sreg_64, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
346 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
347 %4:sreg_64 = S_BREV_B64 $exec
350 SI_END_CF %0:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
355 # Copy to / from VGPR should be assumed to read exec
357 name: copy_no_explicit_exec_dependency
358 tracksRegLiveness: true
360 isEntryFunction: true
362 ; GCN-LABEL: name: copy_no_explicit_exec_dependency
364 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.4(0x40000000)
366 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
367 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
368 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
369 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
372 ; GCN-NEXT: successors: %bb.2(0x40000000), %bb.3(0x40000000)
374 ; GCN-NEXT: [[DEF:%[0-9]+]]:vreg_128 = IMPLICIT_DEF
375 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
376 ; GCN-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY1]], undef %4:sreg_64, implicit-def dead $scc
377 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
378 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.3, implicit $exec
381 ; GCN-NEXT: successors: %bb.3(0x80000000)
384 ; GCN-NEXT: successors: %bb.4(0x80000000)
386 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY1]], implicit-def $scc
387 ; GCN-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY [[DEF]].sub2
390 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY]], implicit-def $scc
391 ; GCN-NEXT: S_ENDPGM 0
393 successors: %bb.1, %bb.4
395 %0:sreg_64 = SI_IF undef %1:sreg_64, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
398 successors: %bb.2, %bb.3
400 %2:vreg_128 = IMPLICIT_DEF
401 %3:sreg_64 = SI_IF undef %4:sreg_64, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
406 SI_END_CF %3:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
407 %5:vgpr_32 = COPY %2.sub2
410 SI_END_CF %0:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
416 name: simple_nested_if_not_layout_successor
417 tracksRegLiveness: true
419 isEntryFunction: true
421 ; GCN-LABEL: name: simple_nested_if_not_layout_successor
423 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.4(0x40000000)
425 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
426 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
427 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
428 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
431 ; GCN-NEXT: successors: %bb.2(0x40000000), %bb.5(0x40000000)
433 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
434 ; GCN-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY1]], undef %3:sreg_64, implicit-def dead $scc
435 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
436 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.5, implicit $exec
439 ; GCN-NEXT: successors: %bb.5(0x80000000)
441 ; GCN-NEXT: S_BRANCH %bb.5
444 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY]], implicit-def $scc
445 ; GCN-NEXT: S_ENDPGM 0
448 ; GCN-NEXT: successors: %bb.4(0x80000000)
450 ; GCN-NEXT: S_BRANCH %bb.4
452 successors: %bb.1, %bb.4
454 %0:sreg_64 = SI_IF undef %1:sreg_64, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
457 successors: %bb.2, %bb.3
459 %2:sreg_64 = SI_IF undef %3:sreg_64, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
464 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
468 SI_END_CF %0:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
476 # This should never happen, but check that we do not hang anyway
479 name: resursive_endcf
480 tracksRegLiveness: true
482 - { reg: '$vgpr0', virtual-reg: '%0' }
484 isEntryFunction: true
486 ; GCN-LABEL: name: resursive_endcf
488 ; GCN-NEXT: successors: %bb.1(0x80000000)
489 ; GCN-NEXT: liveins: $vgpr0
491 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
492 ; GCN-NEXT: [[V_CMP_LT_U32_e64_:%[0-9]+]]:sreg_64 = V_CMP_LT_U32_e64 1, [[COPY]], implicit $exec
495 ; GCN-NEXT: successors: %bb.1(0x80000000)
497 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[V_CMP_LT_U32_e64_]], implicit-def $scc
498 ; GCN-NEXT: S_BRANCH %bb.1
503 %0:vgpr_32 = COPY $vgpr0
504 %2:sreg_64 = V_CMP_LT_U32_e64 1, %0, implicit $exec
509 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
514 # Both s_or_b64 shall be preserved since the outer SI_END_CF belongs to SI_ELSE.
517 name: simple_outer_if_else
518 tracksRegLiveness: true
520 isEntryFunction: true
522 ; GCN-LABEL: name: simple_outer_if_else
524 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
526 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
527 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
528 ; GCN-NEXT: [[S_XOR_B64_:%[0-9]+]]:sreg_64 = S_XOR_B64 [[S_AND_B64_]], [[COPY]], implicit-def dead $scc
529 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
530 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.2, implicit $exec
533 ; GCN-NEXT: successors: %bb.2(0x80000000)
535 ; GCN-NEXT: S_BRANCH %bb.2
538 ; GCN-NEXT: successors: %bb.3(0x40000000), %bb.6(0x40000000)
540 ; 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
541 ; GCN-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 $exec, [[S_OR_SAVEEXEC_B64_]], implicit-def $scc
542 ; GCN-NEXT: $exec = S_XOR_B64_term $exec, [[S_AND_B64_1]], implicit-def $scc
543 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.6, implicit $exec
546 ; GCN-NEXT: successors: %bb.3(0x40000000), %bb.4(0x40000000)
548 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
549 ; GCN-NEXT: [[S_AND_B64_2:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY1]], undef %4:sreg_64, implicit-def dead $scc
550 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_2]]
551 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.3, implicit $exec
554 ; GCN-NEXT: successors: %bb.5(0x80000000)
557 ; GCN-NEXT: successors: %bb.6(0x80000000)
559 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY1]], implicit-def $scc
562 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[S_AND_B64_1]], implicit-def $scc
563 ; GCN-NEXT: S_ENDPGM 0
565 successors: %bb.1, %bb.2
567 %0:sreg_64 = SI_IF undef %1:sreg_64, %bb.2, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
574 successors: %bb.3, %bb.6
575 %2:sreg_64 = SI_ELSE %0:sreg_64, %bb.6, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
578 successors: %bb.3, %bb.4
580 %3:sreg_64 = SI_IF undef %4:sreg_64, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
588 SI_END_CF %3:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
591 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
598 tracksRegLiveness: true
600 isEntryFunction: true
602 ; GCN-LABEL: name: if_inside_loop
604 ; GCN-NEXT: successors: %bb.6(0x80000000)
606 ; GCN-NEXT: S_BRANCH %bb.6
609 ; GCN-NEXT: successors: %bb.3(0x40000000), %bb.2(0x40000000)
611 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
612 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
613 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
614 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.3, implicit $exec
617 ; GCN-NEXT: successors: %bb.6(0x80000000)
619 ; GCN-NEXT: S_BRANCH %bb.6
622 ; GCN-NEXT: successors: %bb.4(0x80000000)
624 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY]], implicit-def $scc
627 ; GCN-NEXT: successors: %bb.5(0x80000000)
629 ; GCN-NEXT: $exec = S_OR_B64 $exec, %2, implicit-def $scc
632 ; GCN-NEXT: successors: %bb.6(0x80000000)
635 ; GCN-NEXT: successors: %bb.4(0x40000000), %bb.0(0x40000000)
637 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
638 ; GCN-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY1]], undef %3:sreg_64, implicit-def dead $scc
639 ; GCN-NEXT: [[S_XOR_B64_:%[0-9]+]]:sreg_64 = S_XOR_B64 [[S_AND_B64_1]], [[COPY1]], implicit-def dead $scc
640 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
641 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
642 ; GCN-NEXT: S_BRANCH %bb.0
643 ; GCN-NEXT: S_ENDPGM 0
648 %0:sreg_64 = SI_IF undef %1:sreg_64, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
654 SI_END_CF %0:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
657 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
662 %2:sreg_64 = SI_IF undef %3:sreg_64, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
669 # redundant MBB removal correctness test:
670 # we can keep bb.2 fallthrough to the new succ because after bb.3 gets removed
671 # new succ (bb.4) becomes bb.2's layout successor
672 name: removed_succ_fallthrough_but_layout_successor
673 tracksRegLiveness: true
675 isEntryFunction: true
677 ; GCN-LABEL: name: removed_succ_fallthrough_but_layout_successor
679 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.4(0x40000000)
681 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
682 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
683 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
684 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
687 ; GCN-NEXT: successors: %bb.2(0x40000000), %bb.4(0x40000000)
689 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
690 ; GCN-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY1]], undef %3:sreg_64, implicit-def dead $scc
691 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
692 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
695 ; GCN-NEXT: successors: %bb.4(0x80000000)
698 ; GCN-NEXT: successors: %bb.5(0x80000000)
700 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY]], implicit-def $scc
703 ; GCN-NEXT: S_ENDPGM 0
705 successors: %bb.1, %bb.4
707 %0:sreg_64 = SI_IF undef %1:sreg_64, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
710 successors: %bb.2, %bb.3
712 %2:sreg_64 = SI_IF undef %3:sreg_64, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
717 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
721 SI_END_CF %0:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
729 # redundant MBB removal correctness test:
730 # If one of the remdundant block preds has a fallthrough path, but the only redundant block succ is not
731 # going to be a layout successor to that pred after redundant block removal, we should not rearrange
732 # blocks to keep pred's fallthrough path, if the succ has fallthrough path to one of it's succ too.
734 name: deleted_succ_fallthrough_not_layout_successor
735 tracksRegLiveness: true
737 isEntryFunction: true
739 ; GCN-LABEL: name: deleted_succ_fallthrough_not_layout_successor
741 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.4(0x40000000)
743 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
744 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], undef %1:sreg_64, implicit-def dead $scc
745 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
746 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.4, implicit $exec
749 ; GCN-NEXT: successors: %bb.2(0x40000000), %bb.5(0x40000000)
751 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
752 ; GCN-NEXT: [[S_AND_B64_1:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY1]], undef %3:sreg_64, implicit-def dead $scc
753 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
754 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.5, implicit $exec
757 ; GCN-NEXT: successors: %bb.5(0x80000000)
759 ; GCN-NEXT: S_BRANCH %bb.5
762 ; GCN-NEXT: S_ENDPGM 0
765 ; GCN-NEXT: successors: %bb.6(0x80000000)
767 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY]], implicit-def $scc
770 ; GCN-NEXT: successors: %bb.4(0x80000000)
772 ; GCN-NEXT: S_BRANCH %bb.4
774 successors: %bb.1, %bb.4
776 %0:sreg_64 = SI_IF undef %1:sreg_64, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
779 successors: %bb.2, %bb.3
781 %2:sreg_64 = SI_IF undef %3:sreg_64, %bb.3, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
786 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
794 SI_END_CF %0:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
801 # While collapsing inner endcf, certain blocks ended up getting two S_BRANCH instructions.
802 # It happens in the absence of BranchFolding (mostly at -O0) when the irregularly placed BBs are traversed
803 # in the forward direction and the intervening block between a predecessor and its successor gets optimized
804 # away in subsequent iterations, leaving 2 S_BRANCH instructions in the predecessor block.
805 # The issue was fixed by iterating the blocks from bottom-up to ensure all endcf pseudos at the bottom of the
806 # function are processed first.
807 # This test ensures there are no multiple S_BRANCH instructions inserted in any block.
809 name: no_multiple_unconditional_branches
810 tracksRegLiveness: true
812 ; GCN-LABEL: name: no_multiple_unconditional_branches
814 ; GCN-NEXT: successors: %bb.1(0x40000000), %bb.14(0x40000000)
816 ; GCN-NEXT: [[DEF:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
817 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_:%[0-9]+]]:sreg_64 = V_CMP_EQ_U32_e64 0, killed [[DEF]], implicit $exec
818 ; GCN-NEXT: [[COPY:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
819 ; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[COPY]], [[V_CMP_EQ_U32_e64_]], implicit-def dead $scc
820 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_]]
821 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.14, implicit $exec
822 ; GCN-NEXT: S_BRANCH %bb.1
825 ; GCN-NEXT: successors: %bb.2(0x40000000), %bb.14(0x40000000)
827 ; GCN-NEXT: [[DEF1:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
828 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_1:%[0-9]+]]:sreg_64 = V_CMP_EQ_U32_e64 0, killed [[DEF1]], implicit $exec
829 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
830 ; 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
831 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_1]]
832 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.14, implicit $exec
833 ; GCN-NEXT: S_BRANCH %bb.2
836 ; GCN-NEXT: successors: %bb.3(0x40000000), %bb.7(0x40000000)
838 ; GCN-NEXT: [[DEF2:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
839 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_2:%[0-9]+]]:sreg_64 = V_CMP_EQ_U32_e64 0, killed [[DEF2]], implicit $exec
840 ; GCN-NEXT: [[COPY2:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
841 ; 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
842 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_2]]
843 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.7, implicit $exec
844 ; GCN-NEXT: S_BRANCH %bb.3
847 ; GCN-NEXT: successors: %bb.4(0x40000000), %bb.7(0x40000000)
849 ; GCN-NEXT: [[DEF3:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
850 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_3:%[0-9]+]]:sreg_64 = V_CMP_EQ_U32_e64 0, killed [[DEF3]], implicit $exec
851 ; GCN-NEXT: [[COPY3:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
852 ; 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
853 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_3]]
854 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.7, implicit $exec
855 ; GCN-NEXT: S_BRANCH %bb.4
858 ; GCN-NEXT: successors: %bb.7(0x80000000)
860 ; GCN-NEXT: S_BRANCH %bb.7
863 ; GCN-NEXT: successors: %bb.8(0x80000000)
865 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY2]], implicit-def $scc
866 ; GCN-NEXT: S_BRANCH %bb.8
869 ; GCN-NEXT: successors: %bb.9(0x80000000)
871 ; GCN-NEXT: S_BRANCH %bb.9
874 ; GCN-NEXT: successors: %bb.11(0x40000000), %bb.12(0x40000000)
876 ; GCN-NEXT: [[DEF4:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
877 ; GCN-NEXT: [[V_CMP_EQ_U32_e64_4:%[0-9]+]]:sreg_64 = V_CMP_EQ_U32_e64 0, killed [[DEF4]], implicit $exec
878 ; GCN-NEXT: [[COPY4:%[0-9]+]]:sreg_64 = COPY $exec, implicit-def $exec
879 ; 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
880 ; GCN-NEXT: [[S_XOR_B64_:%[0-9]+]]:sreg_64 = S_XOR_B64 [[S_AND_B64_4]], [[COPY4]], implicit-def dead $scc
881 ; GCN-NEXT: $exec = S_MOV_B64_term killed [[S_AND_B64_4]]
882 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.12, implicit $exec
883 ; GCN-NEXT: S_BRANCH %bb.11
886 ; GCN-NEXT: successors: %bb.14(0x80000000)
888 ; GCN-NEXT: S_BRANCH %bb.14
891 ; GCN-NEXT: successors: %bb.12(0x80000000)
893 ; GCN-NEXT: S_BRANCH %bb.12
896 ; GCN-NEXT: successors: %bb.10(0x40000000), %bb.14(0x40000000)
898 ; 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
899 ; GCN-NEXT: [[S_AND_B64_5:%[0-9]+]]:sreg_64 = S_AND_B64 $exec, [[S_OR_SAVEEXEC_B64_]], implicit-def $scc
900 ; GCN-NEXT: $exec = S_XOR_B64_term $exec, [[S_AND_B64_5]], implicit-def $scc
901 ; GCN-NEXT: S_CBRANCH_EXECZ %bb.14, implicit $exec
902 ; GCN-NEXT: S_BRANCH %bb.10
905 ; GCN-NEXT: $exec = S_OR_B64 $exec, [[COPY]], implicit-def $scc
906 ; GCN-NEXT: S_ENDPGM 0
908 successors: %bb.1, %bb.14
910 %0:vgpr_32 = IMPLICIT_DEF
911 %1:sreg_64 = V_CMP_EQ_U32_e64 0, killed %0:vgpr_32, implicit $exec
912 %2:sreg_64 = SI_IF %1:sreg_64, %bb.14, implicit-def $exec, implicit-def dead $scc, implicit $exec
916 successors: %bb.2, %bb.6
918 %3:vgpr_32 = IMPLICIT_DEF
919 %4:sreg_64 = V_CMP_EQ_U32_e64 0, killed %3:vgpr_32, implicit $exec
920 %5:sreg_64 = SI_IF killed %4:sreg_64, %bb.6, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
924 successors: %bb.3, %bb.7
926 %6:vgpr_32 = IMPLICIT_DEF
927 %7:sreg_64 = V_CMP_EQ_U32_e64 0, killed %6:vgpr_32, implicit $exec
928 %8:sreg_64 = SI_IF killed %7:sreg_64, %bb.7, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
932 successors: %bb.4, %bb.5
934 %9:vgpr_32 = IMPLICIT_DEF
935 %10:sreg_64 = V_CMP_EQ_U32_e64 0, killed %9:vgpr_32, implicit $exec
936 %11:sreg_64 = SI_IF killed %10:sreg_64, %bb.5, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
947 SI_END_CF %11:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
953 SI_END_CF %5:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
959 SI_END_CF %8:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
968 successors: %bb.11, %bb.12
970 %12:vgpr_32 = IMPLICIT_DEF
971 %13:sreg_64 = V_CMP_EQ_U32_e64 0, killed %12:vgpr_32, implicit $exec
972 %14:sreg_64 = SI_IF killed %13:sreg_64, %bb.12, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
986 successors: %bb.10, %bb.13
988 %15:sreg_64 = SI_ELSE %14:sreg_64, %bb.13, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
994 SI_END_CF %15:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
999 SI_END_CF %2:sreg_64, implicit-def dead $exec, implicit-def dead $scc, implicit $exec