[llvm] [SLP][REVEC] Fix cost model for getGatherCost with FixedVectorType ScalarTy. (PR #109369)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 20 07:23:15 PDT 2024
================
@@ -11767,14 +11765,27 @@ InstructionCost BoUpSLP::getGatherCost(ArrayRef<Value *> VL, bool ForPoisonSrc,
}
DuplicateNonConst = true;
- ShuffledElements.setBits(I * ScalarTyNumElements,
- I * ScalarTyNumElements + ScalarTyNumElements);
+ ShuffledElements.setBit(I);
ShuffleMask[I] = Res.first->second;
}
- if (ForPoisonSrc)
- Cost =
- TTI->getScalarizationOverhead(VecTy, ~ShuffledElements, /*Insert*/ true,
- /*Extract*/ false, CostKind);
+ if (ForPoisonSrc) {
+ if (isa<FixedVectorType>(ScalarTy)) {
+ assert(SLPReVec && "Only supported by REVEC.");
+ // We don't need to insert elements one by one. Instead, we can insert the
+ // entire vector into the destination.
+ Cost = 0;
+ unsigned ScalarTyNumElements = getNumElements(ScalarTy);
+ for (unsigned I = 0, E = VL.size(); I != E; ++I)
----------------
alexey-bataev wrote:
```suggestion
for (unsigned I : seq<unsigned>(VL.size()))
```
https://github.com/llvm/llvm-project/pull/109369
More information about the llvm-commits
mailing list