[PATCH] D55357: [LoopSimplifyCFG] Do not deal with loops with irreducible CFG inside

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 6 01:51:12 PST 2018


mkazantsev created this revision.
mkazantsev added reviewers: uabelho, anna, fedor.sergeev.

The current algorithm that collects live/dead/inloop blocks relies on some invariants
related to RPO and PO traversals. In particular, the important fact it requires is that
the only loop's latch is the first block in PO traversal. It also relies on fact that during
RPO we visit all prececessors of a block before we visit this block (backedges ignored).

If a loop has irreducible non-loop cycle inside, both these assumptions may break.
This patch adds detection for this situation and prohibits the terminator folding
for loops with irreducible CFG.

We can in theory support this later, for this some algorithmic changes are needed.
Besides, irreducible CFG is not a frequent situation and we can just don't bother.

Thanks @uabelho for finding this!


https://reviews.llvm.org/D55357

Files:
  lib/Transforms/Scalar/LoopSimplifyCFG.cpp
  test/Transforms/LoopSimplifyCFG/irreducible_cfg.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55357.176939.patch
Type: text/x-patch
Size: 5481 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181206/1e959d5f/attachment.bin>


More information about the llvm-commits mailing list