Patch D20017 aggressively choosing the best loop top in a loop, this introduces 2 issues for AMDGPU backend:
- Crash issue: it breaks assumption of basic block order in shouldSkip(), e.g.
bb2<--+ bb2 (From) Block Flow (To) / \ | bb6 => Placement => bb2 (From) bb6 -> Flow Flow (To) bb6
In original code, To MBB is assumed after From MBB, so it gets crash when this is not true.
- Unnecessary branch in fall through path, e.g.
bb2<--+ Flow (Latch) / \ | bb2 (Header) bb6 -> Flow bb6 Flow: s_cbranch_execnz bb2 s_branch end bb2: s_cbranch_execz Flow bb6: s_branch Flow end:
Flow can fall through bb2, so we can replace two branches into one conditional branch.