@@ -2237,8 +2237,7 @@ class BoUpSLP {
2237
2237
bool isStridedLoad(ArrayRef<Value *> VL, ArrayRef<Value *> PointerOps,
2238
2238
ArrayRef<unsigned> Order, const TargetTransformInfo &TTI,
2239
2239
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;
2242
2241
2243
2242
/// Checks if the given array of loads can be represented as a vectorized,
2244
2243
/// scatter or just simple gather.
@@ -6822,10 +6821,19 @@ bool BoUpSLP::isStridedLoad(ArrayRef<Value *> VL, ArrayRef<Value *> PointerOps,
6822
6821
ArrayRef<unsigned> Order,
6823
6822
const TargetTransformInfo &TTI,
6824
6823
const DataLayout &DL, ScalarEvolution &SE,
6825
- const bool IsAnyPointerUsedOutGraph,
6826
6824
const int64_t Diff,
6827
6825
StridedPtrInfo &SPtrInfo) const {
6828
6826
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
+
6829
6837
const uint64_t AbsoluteDiff = std::abs(Diff);
6830
6838
Type *ScalarTy = VL.front()->getType();
6831
6839
auto *VecTy = getWidenedType(ScalarTy, Sz);
@@ -6956,18 +6964,7 @@ BoUpSLP::LoadsState BoUpSLP::canVectorizeLoads(
6956
6964
cast<Instruction>(V), UserIgnoreList);
6957
6965
}))
6958
6966
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))
6971
6968
return LoadsState::StridedVectorize;
6972
6969
}
6973
6970
if (!TTI->isLegalMaskedGather(VecTy, CommonAlignment) ||
0 commit comments