[llvm] [LoopVectorize] Enable vectorisation of early exit loops with live-outs (PR #120567)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 13 02:46:24 PST 2025
================
@@ -501,7 +501,15 @@ void VPBasicBlock::execute(VPTransformState *State) {
UnreachableInst *Terminator = State->Builder.CreateUnreachable();
// Register NewBB in its loop. In innermost loops its the same for all
// BB's.
- if (State->CurrentParentLoop)
+ if (this == State->Plan->getEarlyExit()) {
+ // If this is the vector early exit block then it has a single successor,
+ // which is the uncountable early exit block of the original loop. The
+ // parent loop for the exit block may not be the same as the parent loop
+ // of the vectorised loop, so we have to treat this differently.
+ Loop *EEL = State->LI->getLoopFor(State->CFG.UncountableEarlyExitBB);
+ if (EEL)
+ EEL->addBasicBlockToLoop(NewBB, *State->LI);
+ } else if (State->CurrentParentLoop)
----------------
fhahn wrote:
It might be good to frame this more generally if possible.
IIUC the problem here is that now we introduce a VPBB which may be outside the enclosing loop (and in the same loop as the destination VPIRBB.
This is the case when we have a VPBB that only branches to a single exit block and then it must be in the same loop as this VPIRBB. Can we check for that instead?
https://github.com/llvm/llvm-project/pull/120567
More information about the llvm-commits
mailing list