[llvm] [SLP][REVEC] Expand getelementptr into vector form. (PR #103704)
Han-Kuan Chen via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 21 02:08:38 PDT 2024
================
@@ -13760,6 +13760,26 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
LLVM_DEBUG(dbgs() << "SLP: Diamond merged for " << *VL0 << ".\n");
return E->VectorizedValue;
}
+ if (isa<FixedVectorType>(ScalarTy)) {
+ assert(SLPReVec && "FixedVectorType is not expected.");
+ // CreateMaskedGather expects VecTy and VecPtr have same size. We need
+ // to expand VecPtr if ScalarTy is a vector type.
+ unsigned ScalarTyNumElements =
+ cast<FixedVectorType>(ScalarTy)->getNumElements();
+ unsigned VecTyNumElements =
+ cast<FixedVectorType>(VecTy)->getNumElements();
+ SmallVector<Constant *> Indices(VecTyNumElements);
+ transform(seq(VecTyNumElements), Indices.begin(), [=](unsigned I) {
+ return Builder.getInt64(I % ScalarTyNumElements);
+ });
----------------
HanKuanChen wrote:
> Also, do you have the cost model for this change?
GEPs are calculated by `TTI.getGEPCost` in `getGEPCosts`.
`TTI->getGatherScatterOpCost` correctly calculates the cost if ScalarTy is FixedVectorType.
https://github.com/llvm/llvm-project/pull/103704
More information about the llvm-commits
mailing list