[llvm] [LV] Use VPReductionRecipe for partial reductions (PR #147513)
Sam Tebbs via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 20 08:08:48 PST 2025
================
@@ -304,134 +303,6 @@ bool VPRecipeBase::isScalarCast() const {
return VPI && Instruction::isCast(VPI->getOpcode());
}
-InstructionCost
-VPPartialReductionRecipe::computeCost(ElementCount VF,
- VPCostContext &Ctx) const {
- std::optional<unsigned> Opcode;
- VPValue *Op = getVecOp();
- uint64_t MulConst;
-
- InstructionCost CondCost = 0;
- if (isConditional()) {
- CmpInst::Predicate Pred = CmpInst::BAD_ICMP_PREDICATE;
- auto *VecTy = Ctx.Types.inferScalarType(Op);
- auto *CondTy = Ctx.Types.inferScalarType(getCondOp());
- CondCost = Ctx.TTI.getCmpSelInstrCost(Instruction::Select, VecTy, CondTy,
- Pred, Ctx.CostKind);
- }
----------------
SamTebbs33 wrote:
> Oh that’s surprising, are we forming partial reductions for those cases? If not than it would be good to check first why the behavior changed, because that would be somewhat unexpected. I think we also have the predicate cost on main, but maybe the difference would be that after moving we may already have and pass the correct vector types?
When I first tried moving it over, I applied the cost to all cases in `VPReductionRecipe::computeCost`, which is what introduced the regressions in mve-reductions.ll. If I just apply the extra cost to the partial reduction case then nothing changes so we should be good to go with that approach and fix up the cost model for other conditional reductions later.
https://github.com/llvm/llvm-project/pull/147513
More information about the llvm-commits
mailing list