[llvm] [SLP][REVEC] Make tryToReduce and related functions support vector instructions. (PR #102327)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 7 09:29:36 PDT 2024
================
@@ -17939,9 +17956,23 @@ 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 = 0, End = ReducedVals.size(); I != End; ++I) {
+ VectorCost += TTI->getShuffleCost(
+ TTI::SK_PermuteSingleSrc, VectorTy,
+ createStrideMask(I, ScalarTyNumElements, End));
+ VectorCost += TTI->getArithmeticReductionCost(RdxOpcode, VecTy, FMF,
+ CostKind);
+ VectorCost += TTI->getVectorInstrCost(
+ Instruction::InsertElement, VecTy, TTI::TCK_RecipThroughput, I);
+ }
+ } else
+ VectorCost = TTI->getArithmeticReductionCost(RdxOpcode, VectorTy, FMF,
+ CostKind);
----------------
alexey-bataev wrote:
Enclose in braces
https://github.com/llvm/llvm-project/pull/102327
More information about the llvm-commits
mailing list