[llvm] [VPlan] Impl VPlan-based pattern match for ExtendedRed and MulAccRed (PR #113903)
Elvis Wang via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 10 19:11:02 PDT 2025
================
@@ -9515,6 +9458,29 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
// Adjust the recipes for any inloop reductions.
adjustRecipesForReductions(Plan, RecipeBuilder, Range.Start);
+ // Transform recipes to abstract recipes if it is leagal and beneficial and
+ // clamp the range for better cost estimation.
+ // TODO: Enable following transform when the EVL-version of extended-reduction
+ // and mulacc-reduction are implemented.
+ if (!CM.foldTailWithEVL()) {
+ VPCostContext CostCtx(CM.TTI, *CM.TLI, Legal->getWidestInductionType(), CM,
+ CM.CostKind);
+ VPlanTransforms::runPass(VPlanTransforms::convertToAbstractRecipes, *Plan,
+ CostCtx, Range);
+ }
+
+ // Update VF after `convertToAbstractRecipes`. Cannot set the VF here since
+ // `handleUncountableEarlyExit` will check the VF of the plan, need to set
+ // before it and update.
+ // TODO: Use a better method that only set the VF for plan once.
+ SmallVector<ElementCount, 2> VFToRemove;
+ for (ElementCount VF : Plan->vectorFactors())
+ if (!Range.contains(VF))
+ VFToRemove.push_back(VF);
+
+ for (ElementCount VF : VFToRemove)
+ Plan->removeVF(VF);
----------------
ElvisWang123 wrote:
Fix by #135294. Thanks.
https://github.com/llvm/llvm-project/pull/113903
More information about the llvm-commits
mailing list