diff options
| author | Florian Hahn <flo@fhahn.com> | 2025-05-16 21:11:41 +0100 |
|---|---|---|
| committer | Florian Hahn <flo@fhahn.com> | 2025-05-16 21:12:39 +0100 |
| commit | ba93685ea228523c1f717f569e08185098b7defb (patch) | |
| tree | 312c81997ad322e1b77116066aaa39e019c954b5 /llvm/lib/Transforms/Vectorize/VPlan.cpp | |
| parent | ad6bb707730247abc07810c0598434a86361e049 (diff) | |
[VPlan] Also use original parent loop for exit VPBBs.
When vectorizing loops with early exits that is nested within another
one, one of the loop exits may be outside both loops, so setting adding
it to the parent loop is incorrect. Also use the original parent loop
for exit blocks.
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/VPlan.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Vectorize/VPlan.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp index c36feb0e2fde..06b738afbd22 100644 --- a/llvm/lib/Transforms/Vectorize/VPlan.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp @@ -411,12 +411,16 @@ void VPBasicBlock::connectToPredecessors(VPTransformState &State) { // Register NewBB in its loop. In innermost loops its the same for all // BB's. Loop *ParentLoop = State.CurrentParentLoop; - // If this block has a sole successor that is an exit block then it needs - // adding to the same parent loop as the exit block. - VPBlockBase *SuccVPBB = getSingleSuccessor(); - if (SuccVPBB && State.Plan->isExitBlock(SuccVPBB)) - ParentLoop = - State.LI->getLoopFor(cast<VPIRBasicBlock>(SuccVPBB)->getIRBasicBlock()); + // If this block has a sole successor that is an exit block or is an exit + // block itself then it needs adding to the same parent loop as the exit + // block. + VPBlockBase *SuccOrExitVPB = getSingleSuccessor(); + SuccOrExitVPB = SuccOrExitVPB ? SuccOrExitVPB : this; + if (State.Plan->isExitBlock(SuccOrExitVPB)) { + ParentLoop = State.LI->getLoopFor( + cast<VPIRBasicBlock>(SuccOrExitVPB)->getIRBasicBlock()); + } + if (ParentLoop && !State.LI->getLoopFor(NewBB)) ParentLoop->addBasicBlockToLoop(NewBB, *State.LI); |
