[llvm] [VPlan] Impl VPlan-based pattern match for ExtendedRed and MulAccRed (NFCI) (PR #113903)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 20 04:12:57 PST 2024
================
@@ -9518,9 +9626,21 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
if (CM.blockNeedsPredicationForAnyReason(BB))
CondOp = RecipeBuilder.getBlockInMask(BB);
- VPReductionRecipe *RedRecipe =
- new VPReductionRecipe(RdxDesc, CurrentLinkI, PreviousLink, VecOp,
- CondOp, CM.useOrderedReductions(RdxDesc));
+ VPReductionRecipe *RedRecipe;
+ VPCostContext CostCtx(CM.TTI, *CM.TLI, Legal->getWidestInductionType(),
+ CM);
+ if (auto *MulAcc =
+ tryToMatchAndCreateMulAcc(RdxDesc, CurrentLinkI, PreviousLink,
+ VecOp, CondOp, CM, CostCtx, Range))
+ RedRecipe = MulAcc;
+ else if (auto *ExtRed = tryToMatchAndCreateExtendedReduction(
+ RdxDesc, CurrentLinkI, PreviousLink, VecOp, CondOp, CM,
+ CostCtx, Range))
+ RedRecipe = ExtRed;
+ else
+ RedRecipe =
+ new VPReductionRecipe(RdxDesc, CurrentLinkI, PreviousLink, VecOp,
+ CondOp, CM.useOrderedReductions(RdxDesc));
----------------
fhahn wrote:
Could we move the complexity to create the new, optimized recipes to a separate VPlan transform instead of adding it here?
https://github.com/llvm/llvm-project/pull/113903
More information about the llvm-commits
mailing list