[llvm] e4543af - [VPlan] Track current vector loop in VPTransformState (NFC).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 30 14:16:50 PDT 2022
Author: Florian Hahn
Date: 2022-03-30T22:16:40+01:00
New Revision: e4543af4e639efcf084f0cfb8448eeea674e87bc
URL: https://github.com/llvm/llvm-project/commit/e4543af4e639efcf084f0cfb8448eeea674e87bc
DIFF: https://github.com/llvm/llvm-project/commit/e4543af4e639efcf084f0cfb8448eeea674e87bc.diff
LOG: [VPlan] Track current vector loop in VPTransformState (NFC).
Instead of looking up the vector loop using the header, keep track of
the current vector loop in VPTransformState. This removes the
requirement for the vector header block being part of the loop up front.
A follow-up patch will move the code to generate the Loop object for the
vector loop to VPRegionBlock.
Depends on D121619.
Reviewed By: Ayal
Differential Revision: https://reviews.llvm.org/D121621
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlan.cpp
llvm/lib/Transforms/Vectorize/VPlan.h
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index 58b214577012c..a2233babe7a34 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -319,8 +319,7 @@ void VPBasicBlock::execute(VPTransformState *State) {
UnreachableInst *Terminator = State->Builder.CreateUnreachable();
State->Builder.SetInsertPoint(Terminator);
// Register NewBB in its loop. In innermost loops its the same for all BB's.
- Loop *L = State->LI->getLoopFor(State->CFG.PrevBB);
- L->addBasicBlockToLoop(NewBB, *State->LI);
+ State->CurrentVectorLoop->addBasicBlockToLoop(NewBB, *State->LI);
State->CFG.PrevBB = NewBB;
}
@@ -909,6 +908,7 @@ void VPlan::execute(VPTransformState *State) {
assert(VectorHeaderBB && "Loop preheader does not have a single successor.");
Loop *L = State->LI->getLoopFor(VectorHeaderBB);
+ State->CurrentVectorLoop = L;
State->CFG.ExitBB = L->getExitBlock();
// Remove the edge between Header and Latch to allow other connections.
@@ -1543,7 +1543,7 @@ void VPReductionPHIRecipe::execute(VPTransformState &State) {
ScalarPHI ? PN->getType() : VectorType::get(PN->getType(), State.VF);
BasicBlock *HeaderBB = State.CFG.PrevBB;
- assert(State.LI->getLoopFor(HeaderBB)->getHeader() == HeaderBB &&
+ assert(State.CurrentVectorLoop->getHeader() == HeaderBB &&
"recipe must be in the vector loop header");
unsigned LastPartForNewPhi = isOrdered() ? 1 : State.UF;
for (unsigned Part = 0; Part < LastPartForNewPhi; ++Part) {
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 02b0d09bfe91a..3fe981e4c0954 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -352,6 +352,9 @@ struct VPTransformState {
/// Holds recipes that may generate a poison value that is used after
/// vectorization, even when their operands are not poison.
SmallPtrSet<VPRecipeBase *, 16> MayGeneratePoisonRecipes;
+
+ /// The loop object for the current parent region, or nullptr.
+ Loop *CurrentVectorLoop = nullptr;
};
/// VPUsers instance used by VPBlockBase to manage CondBit and the block
More information about the llvm-commits
mailing list