Skip to content

Commit 509d5f5

Browse files
author
Mikhail Gudim
committed
addressed review comments.
1 parent ba976de commit 509d5f5

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2245,6 +2245,21 @@ class BoUpSLP {
22452245
Align Alignment, const int64_t Diff, Value *Ptr0,
22462246
Value *PtrN, StridedPtrInfo &SPtrInfo) const;
22472247

2248+
/// Return true if an array of scalar loads can be replaced with a strided
2249+
/// load (with run-time stride).
2250+
/// \param PointerOps list of pointer arguments of loads.
2251+
/// \param ScalarTy type of loads.
2252+
/// \param CommonAlignment common alignement of loads as computed by
2253+
/// `computeCommonAlignment<LoadInst>`.
2254+
/// \param SortedIndicies is a list of indicies computed by this function such
2255+
/// that the sequence `PointerOps[SortedIndices[0]],
2256+
/// PointerOps[SortedIndicies[1]], ..., PointerOps[SortedIndices[n]]` is
2257+
/// ordered by the coefficient of the stride. For example, if PointerOps is
2258+
/// `%base + %stride, %base, %base + 2 * stride` the `SortedIndices` will be
2259+
/// `[1, 0, 2]`. We follow the convention that if `SortedIndices` has to be
2260+
/// `0, 1, 2, 3, ...` we return empty vector for `SortedIndicies`.
2261+
/// \param SPtrInfo If the function return `true`, it also sets all the fields
2262+
/// of `SPtrInfo` necessary to generate the strided load later.
22482263
bool analyzeRtStrideCandidate(ArrayRef<Value *> PointerOps, Type *ScalarTy,
22492264
Align CommonAlignment,
22502265
SmallVectorImpl<unsigned> &SortedIndices,
@@ -6888,8 +6903,8 @@ bool BoUpSLP::analyzeRtStrideCandidate(ArrayRef<Value *> PointerOps,
68886903
// TODO: VecSz may change if we widen the strided load.
68896904
unsigned VecSz = Sz;
68906905
FixedVectorType *StridedLoadTy = getWidenedType(ScalarTy, VecSz);
6891-
if (!(Sz > MinProfitableStridedLoads && TTI->isTypeLegal(StridedLoadTy) &&
6892-
TTI->isLegalStridedLoadStore(StridedLoadTy, CommonAlignment)))
6906+
if (Sz <= MinProfitableStridedLoads || !TTI->isTypeLegal(StridedLoadTy) ||
6907+
!TTI->isLegalStridedLoadStore(StridedLoadTy, CommonAlignment))
68936908
return false;
68946909
if (const SCEV *Stride =
68956910
calculateRtStride(PointerOps, ScalarTy, *DL, *SE, SortedIndices)) {

0 commit comments

Comments
 (0)