[llvm] [SLPVectorizer] Widen constant strided loads. (PR #162324)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 27 06:26:56 PDT 2025
================
@@ -6921,36 +6920,105 @@ bool BoUpSLP::isStridedLoad(ArrayRef<Value *> PointerOps, Type *ScalarTy,
}
bool BoUpSLP::analyzeConstantStrideCandidate(
- const ArrayRef<Value *> PointerOps, Type *ScalarTy, Align Alignment,
+ ArrayRef<Value *> PointerOps, Type *ElemTy, Align Alignment,
const SmallVectorImpl<unsigned> &SortedIndices, const int64_t Diff,
Value *Ptr0, Value *PtrN, StridedPtrInfo &SPtrInfo) const {
- const size_t Sz = PointerOps.size();
- if (!isStridedLoad(PointerOps, ScalarTy, Alignment, Diff, Sz))
- return false;
+ const unsigned Sz = PointerOps.size();
+ SmallVector<int64_t> SortedOffsetsFromBase(Sz);
+ // Go through `PointerOps` in sorted order and record offsets from `Ptr0`.
+ for (unsigned I : seq<unsigned>(Sz)) {
+ Value *Ptr =
+ SortedIndices.empty() ? PointerOps[I] : PointerOps[SortedIndices[I]];
+ SortedOffsetsFromBase[I] =
+ *getPointersDiff(ElemTy, Ptr0, ElemTy, Ptr, *DL, *SE);
+ }
+ assert(SortedOffsetsFromBase.size() > 1 &&
+ "Trying to generate strided load for less than 2 loads");
----------------
alexey-bataev wrote:
Why do you need this assertion? `SortedOffsetsFromBase` is always of size `Sz`
https://github.com/llvm/llvm-project/pull/162324
More information about the llvm-commits
mailing list