File tree Expand file tree Collapse file tree 4 files changed +22
-5
lines changed
llvm/lib/Transforms/Vectorize Expand file tree Collapse file tree 4 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -9469,13 +9469,17 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
94699469 CostCtx, Range);
94709470 }
94719471
9472- // Update VF after convertToAbstractRecipes. Cannot set the VF here since
9472+ // Update VF after ` convertToAbstractRecipes` . Cannot set the VF here since
94739473 // `handleUncountableEarlyExit` will check the VF of the plan, need to set
94749474 // before it and update.
94759475 // TODO: Use a better method that only set the VF for plan once.
9476- Plan->clearVF ();
9477- for (ElementCount VF : Range)
9478- Plan->addVF (VF);
9476+ SmallVector<ElementCount, 2 > VFToRemove;
9477+ for (ElementCount VF : Plan->vectorFactors ())
9478+ if (!Range.contains (VF))
9479+ VFToRemove.push_back (VF);
9480+
9481+ for (ElementCount VF : VFToRemove)
9482+ Plan->removeVF (VF);
94799483
94809484 // Interleave memory: for each Interleave Group we marked earlier as relevant
94819485 // for this VPlan, replace the Recipes widening its memory instructions with a
Original file line number Diff line number Diff line change @@ -3797,7 +3797,7 @@ class VPlan {
37973797 VFs.insert (VF);
37983798 }
37993799
3800- void clearVF ( ) { VFs.clear ( ); }
3800+ void removeVF (ElementCount VF ) { VFs.remove (VF ); }
38013801
38023802 bool hasVF (ElementCount VF) const { return VFs.count (VF); }
38033803 bool hasScalableVF () const {
Original file line number Diff line number Diff line change @@ -273,6 +273,14 @@ Type *VPTypeAnalysis::inferScalarType(const VPValue *V) {
273273 [](const VPWidenCastRecipe *R) { return R->getResultType (); })
274274 .Case <VPScalarCastRecipe>(
275275 [](const VPScalarCastRecipe *R) { return R->getResultType (); })
276+ .Case <VPExtendedReductionRecipe>(
277+ [](const VPExtendedReductionRecipe *R) {
278+ return R->getResultType ();
279+ })
280+ .Case <VPMulAccumulateReductionRecipe>(
281+ [](const VPMulAccumulateReductionRecipe *R) {
282+ return R->getResultType ();
283+ })
276284 .Case <VPExpandSCEVRecipe>([](const VPExpandSCEVRecipe *R) {
277285 return R->getSCEV ()->getType ();
278286 })
Original file line number Diff line number Diff line change @@ -78,6 +78,11 @@ struct VFRange {
7878 return End.getKnownMinValue () <= Start.getKnownMinValue ();
7979 }
8080
81+ bool contains (const ElementCount &VF) const {
82+ return VF.getKnownMinValue () >= Start.getKnownMinValue () &&
83+ VF.getKnownMinValue () < End.getKnownMinValue ();
84+ }
85+
8186 VFRange (const ElementCount &Start, const ElementCount &End)
8287 : Start(Start), End(End) {
8388 assert (Start.isScalable () == End.isScalable () &&
You can’t perform that action at this time.
0 commit comments