[llvm] [LoopPeel] LCSSA form is destroyed by LoopPeel, preserve it (PR #78696)

Vedant Paranjape via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 1 02:47:06 PST 2024


vedantparanjape-amd wrote:

> > > Can you please explain in what way LCSSA form gets broken? How does the IR look like after peeling but before simplification?
> > > Just calling formLCSSARecursively() is of course correct, but it's better to understand why LCSSA gets broken and whether we can fix it incrementally instead.
> > 
> > 
> > Actually the issue seems something else imo, the Peeled Loop seems bogus, it just adds blocks with unconditional branch instructions, the loop it seems to evaluate is `Loop at depth 2 containing: %bb12<header><latch><exiting>` which is a loop with no blocks and also infinite. Maybe we need to stop loop peeling in such cases.
> 
> I think this is just because the loop bb12 contains only a branch, however the issue still persists if the loop was a meaning full one as in this example: https://godbolt.org/z/a6cYb4Ta6

If you add one more block to the loop, it doesn't crash: https://godbolt.org/z/h3hM7MMnq. It seems to be a issue with LoopUnrolling. 

Ignoring my comment above about isBlockInLCSSAForm, I think there's nothing wrong with the function because bb7.loopexit and bb7 are not part of any loops, hence adding the the lcssa block seems correct to me. 

https://github.com/llvm/llvm-project/pull/78696


More information about the llvm-commits mailing list