[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 01:18:44 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:
> Why not represent it as 2 loads + insert?
This test has `-slp-threshold=-100`. Basically, scalar version (loads + insert) cost is smaller than vector version (masked gather) cost.
https://github.com/llvm/llvm-project/pull/103704
More information about the llvm-commits
mailing list