[llvm] [LoopVectorize] Enable vectorisation of early exit loops with live-outs (PR #120567)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 13 05:47:15 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)
----------------
david-arm wrote:
We can do it that way I think, but I guess that requires walking through the list returned by `getExitBlocks()` every time this function is called. I imagine that's quite a bit of compile time cost, but I suppose I can limit this to when `State->CFG.UncountableEarlyExitB` is non-null if that's ok?
https://github.com/llvm/llvm-project/pull/120567
More information about the llvm-commits
mailing list