[llvm] [LV] Only create partial reductions when profitable. (PR #181706)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 19 13:13:09 PST 2026
================
@@ -4300,23 +4285,19 @@ tryToMatchAndCreateExtendedReduction(VPReductionRecipe *Red, VPCostContext &Ctx,
cast<VPWidenCastRecipe>(VecOp)->computeCost(VF, Ctx);
InstructionCost RedCost = Red->computeCost(VF, Ctx);
- if (Red->isPartialReduction()) {
- TargetTransformInfo::PartialReductionExtendKind ExtKind =
- TargetTransformInfo::getPartialReductionExtendKind(ExtOpc);
- // FIXME: Move partial reduction creation, costing and clamping
- // here from LoopVectorize.cpp.
- ExtRedCost = Ctx.TTI.getPartialReductionCost(
- Opcode, SrcTy, nullptr, RedTy, VF, ExtKind,
- llvm::TargetTransformInfo::PR_None, std::nullopt, Ctx.CostKind,
- RedTy->isFloatingPointTy()
- ? std::optional{Red->getFastMathFlags()}
- : std::nullopt);
- } else if (!RedTy->isFloatingPointTy()) {
- // TTI::getExtendedReductionCost only supports integer types.
- ExtRedCost = Ctx.TTI.getExtendedReductionCost(
- Opcode, ExtOpc == Instruction::CastOps::ZExt, RedTy, SrcVecTy,
- Red->getFastMathFlags(), CostKind);
- }
+ // For partial reductions, the decision has already been
+ // made at the point of transforming reductions -> partial
+ // reductions for a given plan, based on the cost-model.
+ if (Red->isPartialReduction())
----------------
fhahn wrote:
To double check, would it be much more work to directly create VPExpressionRecipes when we create the partial reductions and remove the partial reduction handling here?
https://github.com/llvm/llvm-project/pull/181706
More information about the llvm-commits
mailing list