[llvm] [SLP][REVEC] Make tryToReduce and related functions support vector instructions. (PR #102327)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 8 05:16:25 PDT 2024
================
@@ -17939,9 +17968,24 @@ class HorizontalReduction {
case RecurKind::FAdd:
case RecurKind::FMul: {
unsigned RdxOpcode = RecurrenceDescriptor::getOpcode(RdxKind);
- if (!AllConsts)
- VectorCost =
- TTI->getArithmeticReductionCost(RdxOpcode, VectorTy, FMF, CostKind);
+ if (!AllConsts) {
+ if (auto *VecTy = dyn_cast<FixedVectorType>(ScalarTy)) {
+ assert(SLPReVec && "FixedVectorType is not expected.");
+ unsigned ScalarTyNumElements = VecTy->getNumElements();
+ for (unsigned I : seq<unsigned>(ReducedVals.size())) {
+ VectorCost += TTI->getShuffleCost(
+ TTI::SK_PermuteSingleSrc, VectorTy,
+ createStrideMask(I, ScalarTyNumElements, ReducedVals.size()));
+ VectorCost += TTI->getArithmeticReductionCost(RdxOpcode, VecTy, FMF,
+ CostKind);
+ VectorCost += TTI->getVectorInstrCost(
+ Instruction::InsertElement, VecTy, TTI::TCK_RecipThroughput, I);
----------------
alexey-bataev wrote:
Better to gather all the required indices and then use getScalarizationOverhead
https://github.com/llvm/llvm-project/pull/102327
More information about the llvm-commits
mailing list