[llvm] [VPlan] Create header phis once, after constructing VPlan0 (NFC). (PR #168291)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 13 23:58:08 PST 2025
================
@@ -8357,6 +8265,9 @@ VPRecipeBuilder::tryToCreatePartialReduction(VPInstruction *Reduction,
cast<VPReductionRecipe>(BinOpRecipe)->isPartialReduction()))
std::swap(BinOp, Accumulator);
+ if (auto *RedPhiR = dyn_cast<VPReductionPHIRecipe>(Accumulator))
+ RedPhiR->setVFScaleFactor(ScaleFactor);
----------------
ayalz wrote:
ReductionPHIRecipe currently gets its Style/ScaleFactor set when constructed:
```
// If the PHI is used by a partial reduction, set the scale factor.
bool UseInLoopReduction = CM.isInLoopReduction(Phi);
bool UseOrderedReductions = CM.useOrderedReductions(RdxDesc);
unsigned ScaleFactor =
getScalingForReduction(RdxDesc.getLoopExitInstr()).value_or(1);
PhiRecipe = new VPReductionPHIRecipe(
Phi, RdxDesc.getRecurrenceKind(), *StartV,
getReductionStyle(UseInLoopReduction, UseOrderedReductions,
ScaleFactor),
RdxDesc.hasUsesOutsideReductionChain());
```
Setting ScaleFactor here is needed now as noted below, but could this change be applied independently?
https://github.com/llvm/llvm-project/pull/168291
More information about the llvm-commits
mailing list