[llvm] [SLPVectorizer][NFC] Refactor `canVectorizeLoads`. (PR #157911)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 11 09:00:08 PDT 2025
================
@@ -6830,23 +6861,44 @@ static bool isStridedLoad(ArrayRef<Value *> VL, ArrayRef<Value *> PointerOps,
if (Ptr == PtrN)
Dist = Diff;
else if (Ptr != Ptr0)
- Dist = *getPointersDiff(ScalarTy, Ptr0, ScalarTy, Ptr, DL, SE);
+ Dist = *getPointersDiff(ElemTy, Ptr0, ElemTy, Ptr, *DL, *SE);
// If the strides are not the same or repeated, we can't
// vectorize.
if (((Dist / Stride) * Stride) != Dist || !Dists.insert(Dist).second)
break;
}
- if (Dists.size() == Sz)
+ if (Dists.size() == Sz) {
+ Type *StrideTy = DL->getIndexType(Ptr0->getType());
+ SPtrInfo.StrideVal = ConstantInt::get(StrideTy, Stride);
+ SPtrInfo.Ty = StridedLoadTy;
return true;
+ }
}
return false;
}
-BoUpSLP::LoadsState
-BoUpSLP::canVectorizeLoads(ArrayRef<Value *> VL, const Value *VL0,
- SmallVectorImpl<unsigned> &Order,
- SmallVectorImpl<Value *> &PointerOps,
- unsigned *BestVF, bool TryRecursiveCheck) const {
+bool BoUpSLP::analyzeRtStrideCandidate(ArrayRef<Value *> PointerOps,
+ Type *ElemTy, Align CommonAlignment,
+ SmallVectorImpl<unsigned> &SortedIndices,
+ StridedPtrInfo &SPtrInfo) const {
+ const size_t Sz = PointerOps.size();
+ FixedVectorType *VecTy = getWidenedType(ElemTy, Sz);
----------------
alexey-bataev wrote:
```suggestion
auto *VecTy = getWidenedType(ElemTy, Sz);
```
https://github.com/llvm/llvm-project/pull/157911
More information about the llvm-commits
mailing list