[PATCH] D41605: StructurizeCFG: Fix broken backedge detection

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 27 17:57:14 PST 2017


arsenm created this revision.
arsenm added reviewers: tstellar, rampitec, jlebar.
Herald added subscribers: nhaehnle, wdng.

The work order was changed in r228186 from SCC order
to RPO with an arbitrary sorting function. The sorting
function attempted to move inner loop nodes earlier. This
was was apparently relying on an assumption that every block
in a given loop / the same loop depth would be seen before
visiting another loop. In the broken testcase, a block
outside of the loop was encountered before moving onto
another block in the same loop. The testcase would then
structurize such that one blocks unconditional successor
 could never be reached.

      

Revert to RPO for the analysis phase. This fixes
detecting edges as backedges that aren't really.

      

The processing phase does use another visited set, and
I'm unclear on whether the order there is as important.
An arbitrary order doesn't work, and triggers some infinite
loops. The reversed RPO list seems to work and is closer
to the order that was used before, minus the arbitary
custom sorting.

      

A few of the changed tests now produce smaller code,
and a few are slightly worse looking.


https://reviews.llvm.org/D41605

Files:
  lib/Transforms/Scalar/StructurizeCFG.cpp
  test/CodeGen/AMDGPU/multilevel-break.ll
  test/CodeGen/AMDGPU/nested-loop-conditions.ll
  test/Transforms/StructurizeCFG/AMDGPU/backedge-id-bug.ll
  test/Transforms/StructurizeCFG/AMDGPU/lit.local.cfg
  test/Transforms/StructurizeCFG/nested-loop-order.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41605.128253.patch
Type: text/x-patch
Size: 32169 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171228/7741adb9/attachment.bin>


More information about the llvm-commits mailing list