[PATCH] D111630: [LoopVectorize][CostModel] Update cost model for fmuladd intrinsic
Paul Walker via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 18 09:23:29 PDT 2021
paulwalker-arm added inline comments.
================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7261-7278
// If we're using ordered reductions then we can just return the base cost
// here, since getArithmeticReductionCost calculates the full ordered
// reduction cost when FP reassociation is not allowed.
- if (useOrderedReductions(RdxDesc))
- return BaseCost;
+ if (useOrderedReductions(RdxDesc)) {
+ if (RdxDesc.getRecurrenceKind() != RecurKind::FMulAdd)
+ return BaseCost;
+ // For a call to the llvm.fmuladd intrinsic we need to add the cost of a
----------------
Perhaps I've misunderstood something? because this code looks more complicated (or perhaps just more verbose) than the previous patch. I guess I'm struggling why different versions of `getArithmeticInstrCost` are being called between the two. I just assumed you'd add something like:
```
InstructionCost BaseCost = TTI.getArithmeticReductionCost(
RdxDesc.getOpcode(), VectorTy, RdxDesc.getFastMathFlags(), CostKind);
+ // For llvm.fmuladd based reductions we must include the cost of the normal
+ // vector fmul that will occur prior to the fadd reduction.
+ if (RdxDesc.getRecurrenceKind() == RecurKind::FMulAdd)
+ BaseCost += TTI.getArithmeticInstrCost(Instruction::FMul, VectorTy, CostKind);
// If we're using ordered reductions then we can just return the base cost
// here, since getArithmeticReductionCost calculates the full ordered
// reduction cost when FP reassociation is not allowed.
if (useOrderedReductions(RdxDesc))
return BaseCost;
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111630/new/
https://reviews.llvm.org/D111630
More information about the llvm-commits
mailing list