[llvm] [VPlan] Introduce ExitPhi VPInstruction, use to create phi for FOR. (PR #94760)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 10 08:15:04 PDT 2024
================
@@ -193,11 +193,18 @@ void VPLiveOut::fixPhi(VPlan &Plan, VPTransformState &State) {
auto Lane = vputils::isUniformAfterVectorization(ExitValue)
? VPLane::getFirstLane()
: VPLane::getLastLaneForVF(State.VF);
- VPBasicBlock *MiddleVPBB =
+ VPBasicBlock *PredVPBB =
cast<VPBasicBlock>(Plan.getVectorLoopRegion()->getSingleSuccessor());
- BasicBlock *MiddleBB = State.CFG.VPBB2IRBB[MiddleVPBB];
- Phi->addIncoming(State.get(ExitValue, VPIteration(State.UF - 1, Lane)),
- MiddleBB);
+ VPRecipeBase *DefRecipe = ExitValue->getDefiningRecipe();
+ if (DefRecipe && !DefRecipe->getParent()->getParent())
+ PredVPBB = DefRecipe->getParent();
+ BasicBlock *PredBB = State.CFG.VPBB2IRBB[PredVPBB];
+ State.Builder.SetInsertPoint(PredBB, PredBB->getFirstNonPHIIt());
----------------
fhahn wrote:
Added a comment + TODO, thanks!
>Is this potential post-extract why ResumePhi is considered (maybe!) vector-to-scalar? These extracts best materialize into recipes.
Yes, we need to select the last lane, which may require creating a new extract, if the VPValue is a vector. Added a TODO to model extracts explicitly.
https://github.com/llvm/llvm-project/pull/94760
More information about the llvm-commits
mailing list