[llvm] [VPlan] Introduce scalar loop header in plan, remove VPLiveOut. (PR #109975)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 29 12:27:29 PDT 2024
================
@@ -8978,15 +8962,25 @@ static void addLiveOutsForFirstOrderRecurrences(
// lo = lcssa.phi [s1, scalar.body],
// [vector.recur.extract.for.phi, middle.block]
//
- // Extract the resume value and create a new VPLiveOut for it.
+ // Extract the resume value and update the VPIRInstrunction wrapping the
+ // phi in the scalar header block.
auto *Resume = MiddleBuilder.createNaryOp(VPInstruction::ExtractFromEnd,
{FOR->getBackedgeValue(), OneVPV},
{}, "vector.recur.extract");
auto *ResumePhiRecipe = ScalarPHBuilder.createNaryOp(
VPInstruction::ResumePhi, {Resume, FOR->getStartValue()}, {},
"scalar.recur.init");
auto *FORPhi = cast<PHINode>(FOR->getUnderlyingInstr());
- Plan.addLiveOut(FORPhi, ResumePhiRecipe);
+ VPIRInstruction *IRI = nullptr;
+ for (VPRecipeBase &R : *Plan.getScalarHeader()) {
----------------
fhahn wrote:
Changed the approach now that ResumePHI are needed for both FORs and reductions:
added `addScalarResumePhis` which creates the ResumePhi recipes for both cases (and eventually inductions as well). They are added as users of the backedge value, and later will be updated by replacing users of the backedge value (it works for reductions without any changes, for recurrences we replace uses in the scalar preheader)
WDYT?
https://github.com/llvm/llvm-project/pull/109975
More information about the llvm-commits
mailing list