Skip to content

Commit 8bbd95a

Browse files
authored
[SLPVectorizer] Move size checks (NFC) (llvm#159361)
Move size checks inside `isStridedLoad`. In the future we plan to possibly change the size and type of strided load there.
1 parent 6a7aec1 commit 8bbd95a

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2237,8 +2237,7 @@ class BoUpSLP {
22372237
bool isStridedLoad(ArrayRef<Value *> VL, ArrayRef<Value *> PointerOps,
22382238
ArrayRef<unsigned> Order, const TargetTransformInfo &TTI,
22392239
const DataLayout &DL, ScalarEvolution &SE,
2240-
const bool IsAnyPointerUsedOutGraph, const int64_t Diff,
2241-
StridedPtrInfo &SPtrInfo) const;
2240+
const int64_t Diff, StridedPtrInfo &SPtrInfo) const;
22422241

22432242
/// Checks if the given array of loads can be represented as a vectorized,
22442243
/// scatter or just simple gather.
@@ -6822,10 +6821,19 @@ bool BoUpSLP::isStridedLoad(ArrayRef<Value *> VL, ArrayRef<Value *> PointerOps,
68226821
ArrayRef<unsigned> Order,
68236822
const TargetTransformInfo &TTI,
68246823
const DataLayout &DL, ScalarEvolution &SE,
6825-
const bool IsAnyPointerUsedOutGraph,
68266824
const int64_t Diff,
68276825
StridedPtrInfo &SPtrInfo) const {
68286826
const size_t Sz = VL.size();
6827+
if (Diff % (Sz - 1) != 0)
6828+
return false;
6829+
6830+
// Try to generate strided load node.
6831+
auto IsAnyPointerUsedOutGraph = any_of(PointerOps, [&](Value *V) {
6832+
return isa<Instruction>(V) && any_of(V->users(), [&](User *U) {
6833+
return !isVectorized(U) && !MustGather.contains(U);
6834+
});
6835+
});
6836+
68296837
const uint64_t AbsoluteDiff = std::abs(Diff);
68306838
Type *ScalarTy = VL.front()->getType();
68316839
auto *VecTy = getWidenedType(ScalarTy, Sz);
@@ -6956,18 +6964,7 @@ BoUpSLP::LoadsState BoUpSLP::canVectorizeLoads(
69566964
cast<Instruction>(V), UserIgnoreList);
69576965
}))
69586966
return LoadsState::CompressVectorize;
6959-
// Simple check if not a strided access - clear order.
6960-
bool IsPossibleStrided = *Diff % (Sz - 1) == 0;
6961-
// Try to generate strided load node.
6962-
auto IsAnyPointerUsedOutGraph =
6963-
IsPossibleStrided && any_of(PointerOps, [&](Value *V) {
6964-
return isa<Instruction>(V) && any_of(V->users(), [&](User *U) {
6965-
return !isVectorized(U) && !MustGather.contains(U);
6966-
});
6967-
});
6968-
if (IsPossibleStrided &&
6969-
isStridedLoad(VL, PointerOps, Order, *TTI, *DL, *SE,
6970-
IsAnyPointerUsedOutGraph, *Diff, SPtrInfo))
6967+
if (isStridedLoad(VL, PointerOps, Order, *TTI, *DL, *SE, *Diff, SPtrInfo))
69716968
return LoadsState::StridedVectorize;
69726969
}
69736970
if (!TTI->isLegalMaskedGather(VecTy, CommonAlignment) ||

0 commit comments

Comments
 (0)