[llvm] [SLP] Create SLP trees starting from constant stride stores (PR #185964)
Ryan Buchner via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 8 14:04:30 PDT 2026
https://github.com/bababuck updated https://github.com/llvm/llvm-project/pull/185964
>From 35e24d9969826a1f2fbb7b8ce3082e21b7c43de6 Mon Sep 17 00:00:00 2001
From: bababuck <buchner.ryan at gmail.com>
Date: Mon, 9 Mar 2026 23:10:16 -0700
Subject: [PATCH 01/13] [SLP][NFC] MinProfitableStridedLoads ->
MinProfitableStridedMemOps and MaxProfitableLoadStride -> MaxProfitableStride
---
.../Transforms/Vectorize/SLPVectorizer.cpp | 26 +++++++++++++------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 25dbbd9939593..6d2287b67640f 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -190,7 +190,13 @@ static cl::opt<unsigned> MinProfitableStridedLoads(
cl::desc("The minimum number of loads, which should be considered strided, "
"if the stride is > 1 or is runtime value"));
-static cl::opt<unsigned> MaxProfitableLoadStride(
+static cl::opt<unsigned> MinProfitableStridedStores(
+ "slp-min-strided-stores", cl::init(2), cl::Hidden,
+ cl::desc(
+ "The minimum number of stores, which should be considered strided, "
+ "if the stride is > 1 or is runtime value"));
+
+static cl::opt<unsigned> MaxProfitableStride(
"slp-max-stride", cl::init(8), cl::Hidden,
cl::desc("The maximum stride, considered to be profitable."));
@@ -2347,10 +2353,11 @@ class slpvectorizer::BoUpSLP {
/// `0, 1, 2, 3, ...` we return empty vector for `SortedIndicies`.
/// \param SPtrInfo If the function return `true`, it also sets all the fields
/// of `SPtrInfo` necessary to generate the strided load later.
+ /// \param IsLoad Is this a strided load (true) or strided store (false)
bool analyzeRtStrideCandidate(ArrayRef<Value *> PointerOps, Type *ScalarTy,
Align CommonAlignment,
SmallVectorImpl<unsigned> &SortedIndices,
- StridedPtrInfo &SPtrInfo) const;
+ StridedPtrInfo &SPtrInfo, bool IsLoad) const;
/// Checks if the given array of loads can be represented as a vectorized,
/// scatter or just simple gather.
@@ -7136,7 +7143,7 @@ isMaskedLoadCompress(ArrayRef<Value *> VL, ArrayRef<Value *> PointerOps,
/// PointerOps:
/// 1. Target with strided load support is detected.
/// 2. The number of loads is greater than MinProfitableStridedLoads, or the
-/// potential stride <= MaxProfitableLoadStride and the potential stride is
+/// potential stride <= MaxProfitableStride and the potential stride is
/// power-of-2 (to avoid perf regressions for the very small number of loads)
/// and max distance > number of loads, or potential stride is -1.
/// 3. The loads are ordered, or number of unordered loads <=
@@ -7163,8 +7170,8 @@ bool BoUpSLP::isStridedLoad(ArrayRef<Value *> PointerOps, Type *ScalarTy,
if (IsAnyPointerUsedOutGraph ||
(AbsoluteDiff > Sz &&
(Sz > MinProfitableStridedLoads ||
- (AbsoluteDiff <= MaxProfitableLoadStride * Sz &&
- AbsoluteDiff % Sz == 0 && has_single_bit(AbsoluteDiff / Sz)))) ||
+ (AbsoluteDiff <= MaxProfitableStride * Sz && AbsoluteDiff % Sz == 0 &&
+ has_single_bit(AbsoluteDiff / Sz)))) ||
Diff == -(static_cast<int64_t>(Sz) - 1)) {
int64_t Stride = Diff / static_cast<int64_t>(Sz - 1);
if (Diff != Stride * static_cast<int64_t>(Sz - 1))
@@ -7278,7 +7285,8 @@ bool BoUpSLP::analyzeConstantStrideCandidate(
bool BoUpSLP::analyzeRtStrideCandidate(ArrayRef<Value *> PointerOps,
Type *ScalarTy, Align CommonAlignment,
SmallVectorImpl<unsigned> &SortedIndices,
- StridedPtrInfo &SPtrInfo) const {
+ StridedPtrInfo &SPtrInfo,
+ bool IsLoad) const {
// If each value in `PointerOps` is of the form `%x + Offset` where `Offset`
// is constant, we partition `PointerOps` sequence into subsequences of
// pointers with the same offset. For each offset we record values from
@@ -7325,7 +7333,9 @@ bool BoUpSLP::analyzeRtStrideCandidate(ArrayRef<Value *> PointerOps,
DL->getTypeSizeInBits(ScalarTy).getFixedValue() * NumOffsets);
}
FixedVectorType *StridedLoadTy = getWidenedType(NewScalarTy, VecSz);
- if (Sz <= MinProfitableStridedLoads || !TTI->isTypeLegal(StridedLoadTy) ||
+ unsigned MinProfitableStridedOps =
+ IsLoad ? MinProfitableStridedLoads : MinProfitableStridedStores;
+ if (Sz <= MinProfitableStridedOps || !TTI->isTypeLegal(StridedLoadTy) ||
!TTI->isLegalStridedLoadStore(StridedLoadTy, CommonAlignment))
return false;
@@ -7523,7 +7533,7 @@ BoUpSLP::LoadsState BoUpSLP::canVectorizeLoads(
Align CommonAlignment = computeCommonAlignment<LoadInst>(VL);
if (!IsSorted) {
if (analyzeRtStrideCandidate(PointerOps, ScalarTy, CommonAlignment, Order,
- SPtrInfo))
+ SPtrInfo, /*isLoad*/ true))
return LoadsState::StridedVectorize;
if (!TTI->isLegalMaskedGather(VecTy, CommonAlignment) ||
>From 4e5059e0f7d6afdf4ea51017f3cc63828b70cff9 Mon Sep 17 00:00:00 2001
From: bababuck <buchner.ryan at gmail.com>
Date: Tue, 10 Mar 2026 11:00:42 -0700
Subject: [PATCH 02/13] [SLP] Enable vectorization of strided stores
---
.../Transforms/Vectorize/SLPVectorizer.cpp | 204 +++++++++++---
.../RISCV/basic-strided-stores.ll | 250 ++----------------
2 files changed, 188 insertions(+), 266 deletions(-)
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 6d2287b67640f..1c63f792da9f4 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -200,6 +200,12 @@ static cl::opt<unsigned> MaxProfitableStride(
"slp-max-stride", cl::init(8), cl::Hidden,
cl::desc("The maximum stride, considered to be profitable."));
+static cl::opt<bool>
+ EnableStridedStores("slp-enable-strided-stores", cl::init(false),
+ cl::Hidden,
+ cl::desc("Enable SLP trees to be built from strided "
+ "store chains."));
+
static cl::opt<bool>
DisableTreeReorder("slp-disable-tree-reorder", cl::init(false), cl::Hidden,
cl::desc("Disable tree reordering even if it is "
@@ -8865,8 +8871,9 @@ void BoUpSLP::buildReorderableOperands(
continue;
if (UserTE->getOpcode() == Instruction::InsertElement && I == 0)
continue;
- if (UserTE->getOpcode() == Instruction::Store &&
- UserTE->State == TreeEntry::Vectorize && I == 1)
+ if (UserTE->getOpcode() == Instruction::Store && I == 1 &&
+ (UserTE->State == TreeEntry::Vectorize ||
+ UserTE->State == TreeEntry::StridedVectorize))
continue;
if (UserTE->getOpcode() == Instruction::Load &&
(UserTE->State == TreeEntry::Vectorize ||
@@ -9280,7 +9287,6 @@ void BoUpSLP::reorderBottomToTop(bool IgnoreReorder) {
Data.first->reorderOperands(Mask);
if (!isa<InsertElementInst, StoreInst>(Data.first->getMainOp()) ||
IsNotProfitableAltCodeNode(*Data.first) ||
- Data.first->State == TreeEntry::StridedVectorize ||
Data.first->State == TreeEntry::CompressVectorize) {
reorderScalars(Data.first->Scalars, Mask);
reorderOrder(Data.first->ReorderIndices, MaskOrder,
@@ -10706,11 +10712,16 @@ BoUpSLP::TreeEntry::EntryState BoUpSLP::getScalarsVectorizationState(
Ptr0 = PointerOps[CurrentOrder.front()];
PtrN = PointerOps[CurrentOrder.back()];
}
+ Align CommonAlignment = computeCommonAlignment<StoreInst>(VL0);
std::optional<int64_t> Dist =
getPointersDiff(ScalarTy, Ptr0, ScalarTy, PtrN, *DL, *SE);
// Check that the sorted pointer operands are consecutive.
if (static_cast<uint64_t>(*Dist) == VL.size() - 1)
return TreeEntry::Vectorize;
+ if (analyzeConstantStrideCandidate(PointerOps, ScalarTy, CommonAlignment,
+ CurrentOrder, *Dist, Ptr0, PtrN,
+ SPtrInfo))
+ return TreeEntry::StridedVectorize;
}
LLVM_DEBUG(dbgs() << "SLP: Non-consecutive store.\n");
@@ -12596,6 +12607,18 @@ void BoUpSLP::buildTreeRec(ArrayRef<Value *> VLRef, unsigned Depth,
return;
}
case Instruction::Store: {
+ if (State == TreeEntry::StridedVectorize) {
+ TreeEntry *TE =
+ newTreeEntry(VL, TreeEntry::StridedVectorize, Bundle, S,
+ UserTreeIdx, ReuseShuffleIndices, CurrentOrder);
+ TreeEntryToStridedPtrInfoMap[TE] = SPtrInfo;
+ LLVM_DEBUG(
+ dbgs() << "SLP: added a new TreeEntry (strided StoreInst).\n";
+ TE->dump());
+ TE->setOperands(Operands);
+ buildTreeRec(TE->getOperand(0), Depth + 1, {TE, 0});
+ return;
+ }
bool Consecutive = CurrentOrder.empty();
if (!Consecutive)
fixupOrderingIndices(CurrentOrder);
@@ -14260,10 +14283,18 @@ void BoUpSLP::transformNodes() {
/*VariableMask=*/false, CommonAlignment,
BaseSI),
CostKind);
- if (StridedCost < OriginalVecCost)
+ if (StridedCost < OriginalVecCost) {
// Strided store is more profitable than reverse + consecutive store -
// transform the node to strided store.
E.State = TreeEntry::StridedVectorize;
+ Type *StrideTy = DL->getIndexType(cast<StoreInst>(E.Scalars.front())
+ ->getPointerOperand()
+ ->getType());
+ StridedPtrInfo SPtrInfo;
+ SPtrInfo.StrideVal = ConstantInt::getSigned(StrideTy, -1);
+ SPtrInfo.Ty = VecTy;
+ TreeEntryToStridedPtrInfoMap[&E] = SPtrInfo;
+ }
} else if (!E.ReorderIndices.empty()) {
// Check for interleaved stores.
auto IsInterleaveMask = [&, &TTI = *TTI](ArrayRef<int> Mask) {
@@ -22013,12 +22044,21 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
}
Align CommonAlignment = computeCommonAlignment<StoreInst>(E->Scalars);
Type *StrideTy = DL->getIndexType(SI->getPointerOperandType());
+
+ const StridedPtrInfo &SPtrInfo = TreeEntryToStridedPtrInfoMap.at(E);
+ Value *Stride = SPtrInfo.StrideVal;
+ assert(Stride && "Missing StridedPointerInfo for tree entry.");
+ Value *StrideVal =
+ Builder.CreateIntCast(Stride, StrideTy, /*isSigned=*/true);
+ // vp_strided_store::stride is defined in bytes
+ StrideVal = Builder.CreateMul(
+ StrideVal,
+ ConstantInt::getSigned(
+ StrideTy, static_cast<int>(DL->getTypeAllocSize(ScalarTy))));
auto *Inst = Builder.CreateIntrinsic(
Intrinsic::experimental_vp_strided_store,
{VecTy, Ptr->getType(), StrideTy},
- {VecValue, Ptr,
- ConstantInt::getSigned(
- StrideTy, -static_cast<int>(DL->getTypeAllocSize(ScalarTy))),
+ {VecValue, Ptr, StrideVal,
Builder.getAllOnesMask(VecTy->getElementCount()),
Builder.getInt32(E->Scalars.size())});
Inst->addParamAttr(
@@ -25368,17 +25408,22 @@ class StoreChainContext {
explicit StoreChainContext(ArrayRef<Value *> Ops,
ArrayRef<SizePair> RangeSizes,
- SmallVector<unsigned> &RangeSizesByIdx)
+ SmallVector<unsigned> &RangeSizesByIdx,
+ unsigned Stride)
: Operands(Ops), RangeSizesStorage(RangeSizes),
- RangeSizesByIdx(RangeSizesByIdx) {}
+ RangeSizesByIdx(RangeSizesByIdx), Stride(Stride) {}
/// Set up initial values using the already set Operands
- bool initializeContext(BoUpSLP &R, const DataLayout &DL,
- const TargetTransformInfo &TTI);
+ bool initializeContext(
+ BoUpSLP &R, const DataLayout &DL, const TargetTransformInfo &TTI,
+ DenseSet<std::tuple<Value *, Value *, Value *, Value *, unsigned>>
+ &Visited);
/// Get the current VF
std::optional<unsigned> getCurrentVF() const;
/// Return the maximum VF for the context
unsigned getMaxVF() const { return MaxVF; }
+ /// Return the stride of the context
+ unsigned getStride() const { return Stride; }
/// Attempt to vectorize Operands for the given VF
/// Returns false if no more attempts should be made for the context
bool vectorizeOneVF(const TargetTransformInfo &TTI, unsigned VF,
@@ -25386,6 +25431,10 @@ class StoreChainContext {
llvm::function_ref<std::optional<bool>(
ArrayRef<Value *>, unsigned, unsigned, unsigned &)>
VectorizeStoreChain);
+ /// Add an additional store to the chain
+ /// \p Store store too append to Operands
+ /// \p Idx position within TryToVectorize::StoreSeq
+ void addOperand(Value *Store, unsigned Idx);
private:
bool isNotVectorized(const SizePair &P) const {
@@ -25482,10 +25531,17 @@ class StoreChainContext {
unsigned Repeat = 1;
/// Did any vectorization occur for the current iteration over CandidateVFs
bool RepeatChanged = false;
+ /// For constant strided stores, what is the stride amount
+ const unsigned Stride = 0;
/// Store information about failed vectorization attempts due to scheduling
SmallDenseMap<Value *, SizePair> NonSchedulable;
};
+void StoreChainContext::addOperand(Value *Store, unsigned Idx) {
+ Operands.push_back(Store);
+ RangeSizesStorage.push_back({Idx, 1});
+}
+
void StoreChainContext::markRangeVectorized(unsigned StartIdx, unsigned Length,
unsigned &FirstUnvecStore,
unsigned &MaxSliceEnd) {
@@ -25511,8 +25567,19 @@ void StoreChainContext::markRangeVectorized(unsigned StartIdx, unsigned Length,
}
}
-bool StoreChainContext::initializeContext(BoUpSLP &R, const DataLayout &DL,
- const TargetTransformInfo &TTI) {
+bool StoreChainContext::initializeContext(
+ BoUpSLP &R, const DataLayout &DL, const TargetTransformInfo &TTI,
+ DenseSet<std::tuple<Value *, Value *, Value *, Value *, unsigned>>
+ &Visited) {
+ if (!Visited
+ .insert({Operands.front(),
+ cast<StoreInst>(Operands.front())->getValueOperand(),
+ Operands.back(),
+ cast<StoreInst>(Operands.back())->getValueOperand(),
+ Operands.size()})
+ .second)
+ return false;
+
// Initialize range tracking in context.
RangeSizes = MutableArrayRef(RangeSizesStorage);
@@ -25538,6 +25605,8 @@ bool StoreChainContext::initializeContext(BoUpSLP &R, const DataLayout &DL,
ValueTy->getScalarType()));
MinVF /= getNumElements(StoreTy);
MinVF = std::max<unsigned>(2, MinVF);
+ if (Stride > 1)
+ MinVF = std::max<unsigned>(MinVF, MinProfitableStridedStores);
if (MaxVF < MinVF) {
LLVM_DEBUG(dbgs() << "SLP: Vectorization infeasible as MaxVF (" << MaxVF
@@ -25903,46 +25972,95 @@ bool SLPVectorizerPass::vectorizeStores(
bool Changed = false;
auto TryToVectorize = [&](const RelatedStoreInsts::DistToInstMap &StoreSeq) {
- int64_t PrevDist = -1;
- unsigned GlobalMaxVF = 0;
SmallVector<unsigned> RangeSizesByIdx(StoreSeq.size(), 1);
SmallVector<std::unique_ptr<StoreChainContext>> AllContexts;
BoUpSLP::ValueList Operands;
SmallVector<StoreChainContext::SizePair> RangeSizes;
+
+ // All chains that we're still building
+ struct PartialChainStatus {
+ // Has been added to AllContexts
+ // Wait to add to AllContexts until at least two stores are found
+ bool AddedToAllContexts;
+ union {
+ // If added, index into AllContexts
+ unsigned AllContextsIdx;
+ // Index into StoreSeq if not added to AllContexts yet
+ unsigned StoreSeqIdx;
+ };
+ // If not added to AllContexts, what is the single store in the chain
+ Value *FirstStore;
+ // What is the Stride of this chain
+ unsigned Stride;
+ };
+ SmallVector<SmallVector<PartialChainStatus, 1>> Chains(MaxProfitableStride +
+ 1);
+ auto GetChainsKey = [&](int64_t Query) -> unsigned {
+ // Just modulo function, get the index into Chains for a given query
+ int64_t Rem = (Query % (int64_t)Chains.size());
+ if (Rem < 0)
+ Rem += (int64_t)Chains.size();
+ return (unsigned)Rem;
+ };
+ int64_t LastDist;
for (auto [Idx, Data] : enumerate(StoreSeq)) {
auto &[Dist, InstIdx] = Data;
- if (Operands.empty() || Dist - PrevDist == 1) {
- Operands.push_back(Stores[InstIdx]);
- RangeSizes.emplace_back(Idx, 1);
- PrevDist = Dist;
- if (Idx != StoreSeq.size() - 1)
+ // Clean up chains that can't be continued
+ if (Idx > 0)
+ for (int64_t D = LastDist; D < Dist; ++D)
+ Chains[GetChainsKey(D)].clear();
+ LastDist = Dist;
+
+ // Track which stride lengths we found existing chains for
+ // Don't have to add new entries for these
+ SmallVector<bool> FoundStrides(MaxProfitableStride + 1, false);
+ for (auto &Status : Chains[GetChainsKey(Dist)]) {
+ if (Status.AddedToAllContexts) {
+ // Chain already in AllContexts()
+ AllContexts[Status.AllContextsIdx]->addOperand(Stores[InstIdx], Idx);
+ } else {
+ // Chain just a single element, not yet in AllContexts()
+ SmallVector<StoreChainContext::SizePair> RS = {
+ {Status.StoreSeqIdx, 1}, {Idx, 1}};
+ BoUpSLP::ValueList Ops = {Status.FirstStore, Stores[InstIdx]};
+ AllContexts.emplace_back(std::make_unique<StoreChainContext>(
+ Ops, RS, RangeSizesByIdx, Status.Stride));
+ Status.AllContextsIdx = AllContexts.size() - 1;
+ }
+ unsigned Key = GetChainsKey(Status.Stride + Dist);
+ Chains[Key].push_back({/*AddedToAllContexts*/ true,
+ Status.AllContextsIdx, /*FirstStore*/ nullptr,
+ Status.Stride});
+ FoundStrides[Status.Stride] = true;
+ }
+
+ // For any stride lengths that we didn't append to a chain for,
+ // instead start a new chain
+ for (auto Stride : seq<unsigned>(
+ 1, (EnableStridedStores ? MaxProfitableStride : 1) + 1)) {
+ if (FoundStrides[Stride])
continue;
- }
-
- if (Operands.size() > 1 &&
- Visited
- .insert({Operands.front(),
- cast<StoreInst>(Operands.front())->getValueOperand(),
- Operands.back(),
- cast<StoreInst>(Operands.back())->getValueOperand(),
- Operands.size()})
- .second) {
- AllContexts.emplace_back(std::make_unique<StoreChainContext>(
- Operands, RangeSizes, RangeSizesByIdx));
- if (!AllContexts.back()->initializeContext(R, *DL, *TTI))
- AllContexts.pop_back();
- else
- GlobalMaxVF = std::max(GlobalMaxVF, AllContexts.back()->getMaxVF());
- }
- Operands.clear();
- RangeSizes.clear();
- if (Idx != StoreSeq.size() - 1) {
- Operands.push_back(Stores[InstIdx]);
- RangeSizes.emplace_back(Idx, 1);
- PrevDist = Dist;
+ unsigned Key = GetChainsKey(Dist + Stride);
+ Chains[Key].push_back({/*AddedToAllContexts*/ false,
+ /*StoreSeqIdx*/ (unsigned)Idx, Stores[InstIdx],
+ Stride});
}
}
+ unsigned GlobalMaxVF = 0;
+ for (auto &CtxPtr : AllContexts)
+ if (CtxPtr->initializeContext(R, *DL, *TTI, Visited))
+ GlobalMaxVF = std::max(GlobalMaxVF, AllContexts.back()->getMaxVF());
+ else
+ CtxPtr.reset();
+
+ // Prioritize non-strided chains (Stride = 1)
+ llvm::stable_sort(AllContexts,
+ [](const std::unique_ptr<StoreChainContext> &A,
+ const std::unique_ptr<StoreChainContext> &B) {
+ return A && (!B || A->getStride() < B->getStride());
+ });
+
for (unsigned LimitVF = GlobalMaxVF; LimitVF > 0;
LimitVF = bit_ceil(LimitVF) / 2) {
for (auto &CtxPtr : AllContexts) {
diff --git a/llvm/test/Transforms/SLPVectorizer/RISCV/basic-strided-stores.ll b/llvm/test/Transforms/SLPVectorizer/RISCV/basic-strided-stores.ll
index c32875ffa402d..8dfc40386bfbc 100644
--- a/llvm/test/Transforms/SLPVectorizer/RISCV/basic-strided-stores.ll
+++ b/llvm/test/Transforms/SLPVectorizer/RISCV/basic-strided-stores.ll
@@ -1,42 +1,14 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
-; RUN: opt -mtriple=riscv64 -mattr=+m,+v -passes=slp-vectorizer -S < %s | FileCheck %s
+; RUN: opt -mtriple=riscv64 -mattr=+m,+v -passes=slp-vectorizer -S -slp-enable-strided-stores < %s | FileCheck %s
define void @constant_stride_2(ptr %pl, ptr %ps) {
; CHECK-LABEL: define void @constant_stride_2(
; CHECK-SAME: ptr [[PL:%.*]], ptr [[PS:%.*]]) #[[ATTR0:[0-9]+]] {
; CHECK-NEXT: [[GEP_L0:%.*]] = getelementptr i8, ptr [[PL]], i64 0
-; CHECK-NEXT: [[GEP_L1:%.*]] = getelementptr i8, ptr [[PL]], i64 1
-; CHECK-NEXT: [[GEP_L2:%.*]] = getelementptr i8, ptr [[PL]], i64 2
-; CHECK-NEXT: [[GEP_L3:%.*]] = getelementptr i8, ptr [[PL]], i64 3
-; CHECK-NEXT: [[GEP_L4:%.*]] = getelementptr i8, ptr [[PL]], i64 4
-; CHECK-NEXT: [[GEP_L5:%.*]] = getelementptr i8, ptr [[PL]], i64 5
-; CHECK-NEXT: [[GEP_L6:%.*]] = getelementptr i8, ptr [[PL]], i64 6
-; CHECK-NEXT: [[GEP_L7:%.*]] = getelementptr i8, ptr [[PL]], i64 7
-; CHECK-NEXT: [[LOAD0:%.*]] = load i8, ptr [[GEP_L0]], align 1
-; CHECK-NEXT: [[LOAD1:%.*]] = load i8, ptr [[GEP_L1]], align 1
-; CHECK-NEXT: [[LOAD2:%.*]] = load i8, ptr [[GEP_L2]], align 1
-; CHECK-NEXT: [[LOAD3:%.*]] = load i8, ptr [[GEP_L3]], align 1
-; CHECK-NEXT: [[LOAD4:%.*]] = load i8, ptr [[GEP_L4]], align 1
-; CHECK-NEXT: [[LOAD5:%.*]] = load i8, ptr [[GEP_L5]], align 1
-; CHECK-NEXT: [[LOAD6:%.*]] = load i8, ptr [[GEP_L6]], align 1
-; CHECK-NEXT: [[LOAD7:%.*]] = load i8, ptr [[GEP_L7]], align 1
; CHECK-NEXT: [[GEP_S0:%.*]] = getelementptr i8, ptr [[PS]], i64 0
-; CHECK-NEXT: [[GEP_S1:%.*]] = getelementptr i8, ptr [[PS]], i64 2
-; CHECK-NEXT: [[GEP_S2:%.*]] = getelementptr i8, ptr [[PS]], i64 4
-; CHECK-NEXT: [[GEP_S3:%.*]] = getelementptr i8, ptr [[PS]], i64 6
-; CHECK-NEXT: [[GEP_S4:%.*]] = getelementptr i8, ptr [[PS]], i64 8
-; CHECK-NEXT: [[GEP_S5:%.*]] = getelementptr i8, ptr [[PS]], i64 10
-; CHECK-NEXT: [[GEP_S6:%.*]] = getelementptr i8, ptr [[PS]], i64 12
-; CHECK-NEXT: [[GEP_S7:%.*]] = getelementptr i8, ptr [[PS]], i64 14
-; CHECK-NEXT: store i8 [[LOAD0]], ptr [[GEP_S0]], align 1
-; CHECK-NEXT: store i8 [[LOAD1]], ptr [[GEP_S1]], align 1
-; CHECK-NEXT: store i8 [[LOAD2]], ptr [[GEP_S2]], align 1
-; CHECK-NEXT: store i8 [[LOAD3]], ptr [[GEP_S3]], align 1
-; CHECK-NEXT: store i8 [[LOAD4]], ptr [[GEP_S4]], align 1
-; CHECK-NEXT: store i8 [[LOAD5]], ptr [[GEP_S5]], align 1
-; CHECK-NEXT: store i8 [[LOAD6]], ptr [[GEP_S6]], align 1
-; CHECK-NEXT: store i8 [[LOAD7]], ptr [[GEP_S7]], align 1
+; CHECK-NEXT: [[TMP1:%.*]] = load <8 x i8>, ptr [[GEP_L0]], align 1
+; CHECK-NEXT: call void @llvm.experimental.vp.strided.store.v8i8.p0.i64(<8 x i8> [[TMP1]], ptr align 1 [[GEP_S0]], i64 2, <8 x i1> splat (i1 true), i32 8)
; CHECK-NEXT: ret void
;
%gep_l0 = getelementptr i8, ptr %pl, i64 0
@@ -82,37 +54,9 @@ define void @constant_stride_7(ptr %pl, ptr %ps) {
; CHECK-LABEL: define void @constant_stride_7(
; CHECK-SAME: ptr [[PL:%.*]], ptr [[PS:%.*]]) #[[ATTR0]] {
; CHECK-NEXT: [[GEP_L0:%.*]] = getelementptr i8, ptr [[PL]], i64 0
-; CHECK-NEXT: [[GEP_L1:%.*]] = getelementptr i8, ptr [[PL]], i64 1
-; CHECK-NEXT: [[GEP_L2:%.*]] = getelementptr i8, ptr [[PL]], i64 2
-; CHECK-NEXT: [[GEP_L3:%.*]] = getelementptr i8, ptr [[PL]], i64 3
-; CHECK-NEXT: [[GEP_L4:%.*]] = getelementptr i8, ptr [[PL]], i64 4
-; CHECK-NEXT: [[GEP_L5:%.*]] = getelementptr i8, ptr [[PL]], i64 5
-; CHECK-NEXT: [[GEP_L6:%.*]] = getelementptr i8, ptr [[PL]], i64 6
-; CHECK-NEXT: [[GEP_L7:%.*]] = getelementptr i8, ptr [[PL]], i64 7
-; CHECK-NEXT: [[LOAD0:%.*]] = load i8, ptr [[GEP_L0]], align 1
-; CHECK-NEXT: [[LOAD1:%.*]] = load i8, ptr [[GEP_L1]], align 1
-; CHECK-NEXT: [[LOAD2:%.*]] = load i8, ptr [[GEP_L2]], align 1
-; CHECK-NEXT: [[LOAD3:%.*]] = load i8, ptr [[GEP_L3]], align 1
-; CHECK-NEXT: [[LOAD4:%.*]] = load i8, ptr [[GEP_L4]], align 1
-; CHECK-NEXT: [[LOAD5:%.*]] = load i8, ptr [[GEP_L5]], align 1
-; CHECK-NEXT: [[LOAD6:%.*]] = load i8, ptr [[GEP_L6]], align 1
-; CHECK-NEXT: [[LOAD7:%.*]] = load i8, ptr [[GEP_L7]], align 1
; CHECK-NEXT: [[GEP_S0:%.*]] = getelementptr i8, ptr [[PS]], i64 0
-; CHECK-NEXT: [[GEP_S1:%.*]] = getelementptr i8, ptr [[PS]], i64 7
-; CHECK-NEXT: [[GEP_S2:%.*]] = getelementptr i8, ptr [[PS]], i64 14
-; CHECK-NEXT: [[GEP_S3:%.*]] = getelementptr i8, ptr [[PS]], i64 21
-; CHECK-NEXT: [[GEP_S4:%.*]] = getelementptr i8, ptr [[PS]], i64 28
-; CHECK-NEXT: [[GEP_S5:%.*]] = getelementptr i8, ptr [[PS]], i64 35
-; CHECK-NEXT: [[GEP_S6:%.*]] = getelementptr i8, ptr [[PS]], i64 42
-; CHECK-NEXT: [[GEP_S7:%.*]] = getelementptr i8, ptr [[PS]], i64 49
-; CHECK-NEXT: store i8 [[LOAD0]], ptr [[GEP_S0]], align 1
-; CHECK-NEXT: store i8 [[LOAD1]], ptr [[GEP_S1]], align 1
-; CHECK-NEXT: store i8 [[LOAD2]], ptr [[GEP_S2]], align 1
-; CHECK-NEXT: store i8 [[LOAD3]], ptr [[GEP_S3]], align 1
-; CHECK-NEXT: store i8 [[LOAD4]], ptr [[GEP_S4]], align 1
-; CHECK-NEXT: store i8 [[LOAD5]], ptr [[GEP_S5]], align 1
-; CHECK-NEXT: store i8 [[LOAD6]], ptr [[GEP_S6]], align 1
-; CHECK-NEXT: store i8 [[LOAD7]], ptr [[GEP_S7]], align 1
+; CHECK-NEXT: [[TMP1:%.*]] = load <8 x i8>, ptr [[GEP_L0]], align 1
+; CHECK-NEXT: call void @llvm.experimental.vp.strided.store.v8i8.p0.i64(<8 x i8> [[TMP1]], ptr align 1 [[GEP_S0]], i64 7, <8 x i1> splat (i1 true), i32 8)
; CHECK-NEXT: ret void
;
%gep_l0 = getelementptr i8, ptr %pl, i64 0
@@ -217,37 +161,13 @@ define void @two_constant_strides(ptr %pl, ptr %ps) {
; CHECK-LABEL: define void @two_constant_strides(
; CHECK-SAME: ptr [[PL:%.*]], ptr [[PS:%.*]]) #[[ATTR0]] {
; CHECK-NEXT: [[GEP_L0:%.*]] = getelementptr i8, ptr [[PL]], i64 0
-; CHECK-NEXT: [[GEP_L1:%.*]] = getelementptr i8, ptr [[PL]], i64 1
-; CHECK-NEXT: [[GEP_L2:%.*]] = getelementptr i8, ptr [[PL]], i64 2
-; CHECK-NEXT: [[GEP_L3:%.*]] = getelementptr i8, ptr [[PL]], i64 3
; CHECK-NEXT: [[GEP_L4:%.*]] = getelementptr i8, ptr [[PL]], i64 4
-; CHECK-NEXT: [[GEP_L5:%.*]] = getelementptr i8, ptr [[PL]], i64 5
-; CHECK-NEXT: [[GEP_L6:%.*]] = getelementptr i8, ptr [[PL]], i64 6
-; CHECK-NEXT: [[GEP_L7:%.*]] = getelementptr i8, ptr [[PL]], i64 7
-; CHECK-NEXT: [[LOAD0:%.*]] = load i8, ptr [[GEP_L0]], align 1
-; CHECK-NEXT: [[LOAD1:%.*]] = load i8, ptr [[GEP_L1]], align 1
-; CHECK-NEXT: [[LOAD2:%.*]] = load i8, ptr [[GEP_L2]], align 1
-; CHECK-NEXT: [[LOAD3:%.*]] = load i8, ptr [[GEP_L3]], align 1
-; CHECK-NEXT: [[LOAD4:%.*]] = load i8, ptr [[GEP_L4]], align 1
-; CHECK-NEXT: [[LOAD5:%.*]] = load i8, ptr [[GEP_L5]], align 1
-; CHECK-NEXT: [[LOAD6:%.*]] = load i8, ptr [[GEP_L6]], align 1
-; CHECK-NEXT: [[LOAD7:%.*]] = load i8, ptr [[GEP_L7]], align 1
; CHECK-NEXT: [[GEP_S0:%.*]] = getelementptr i8, ptr [[PS]], i64 0
-; CHECK-NEXT: [[GEP_S1:%.*]] = getelementptr i8, ptr [[PS]], i64 2
-; CHECK-NEXT: [[GEP_S2:%.*]] = getelementptr i8, ptr [[PS]], i64 4
-; CHECK-NEXT: [[GEP_S3:%.*]] = getelementptr i8, ptr [[PS]], i64 6
; CHECK-NEXT: [[GEP_S4:%.*]] = getelementptr i8, ptr [[PS]], i64 9
-; CHECK-NEXT: [[GEP_S5:%.*]] = getelementptr i8, ptr [[PS]], i64 11
-; CHECK-NEXT: [[GEP_S6:%.*]] = getelementptr i8, ptr [[PS]], i64 13
-; CHECK-NEXT: [[GEP_S7:%.*]] = getelementptr i8, ptr [[PS]], i64 15
-; CHECK-NEXT: store i8 [[LOAD0]], ptr [[GEP_S0]], align 1
-; CHECK-NEXT: store i8 [[LOAD1]], ptr [[GEP_S1]], align 1
-; CHECK-NEXT: store i8 [[LOAD2]], ptr [[GEP_S2]], align 1
-; CHECK-NEXT: store i8 [[LOAD3]], ptr [[GEP_S3]], align 1
-; CHECK-NEXT: store i8 [[LOAD4]], ptr [[GEP_S4]], align 1
-; CHECK-NEXT: store i8 [[LOAD5]], ptr [[GEP_S5]], align 1
-; CHECK-NEXT: store i8 [[LOAD6]], ptr [[GEP_S6]], align 1
-; CHECK-NEXT: store i8 [[LOAD7]], ptr [[GEP_S7]], align 1
+; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i8>, ptr [[GEP_L0]], align 1
+; CHECK-NEXT: [[TMP2:%.*]] = load <4 x i8>, ptr [[GEP_L4]], align 1
+; CHECK-NEXT: call void @llvm.experimental.vp.strided.store.v4i8.p0.i64(<4 x i8> [[TMP1]], ptr align 1 [[GEP_S0]], i64 2, <4 x i1> splat (i1 true), i32 4)
+; CHECK-NEXT: call void @llvm.experimental.vp.strided.store.v4i8.p0.i64(<4 x i8> [[TMP2]], ptr align 1 [[GEP_S4]], i64 2, <4 x i1> splat (i1 true), i32 4)
; CHECK-NEXT: ret void
;
%gep_l0 = getelementptr i8, ptr %pl, i64 0
@@ -293,38 +213,14 @@ define void @constant_strides_variable_gap(ptr %pl, ptr %ps, i64 %gap) {
; CHECK-LABEL: define void @constant_strides_variable_gap(
; CHECK-SAME: ptr [[PL:%.*]], ptr [[PS:%.*]], i64 [[GAP:%.*]]) #[[ATTR0]] {
; CHECK-NEXT: [[GEP_L0:%.*]] = getelementptr i8, ptr [[PL]], i64 0
-; CHECK-NEXT: [[GEP_L1:%.*]] = getelementptr i8, ptr [[PL]], i64 1
-; CHECK-NEXT: [[GEP_L2:%.*]] = getelementptr i8, ptr [[PL]], i64 2
-; CHECK-NEXT: [[GEP_L3:%.*]] = getelementptr i8, ptr [[PL]], i64 3
; CHECK-NEXT: [[GEP_L4:%.*]] = getelementptr i8, ptr [[PL]], i64 4
-; CHECK-NEXT: [[GEP_L5:%.*]] = getelementptr i8, ptr [[PL]], i64 5
-; CHECK-NEXT: [[GEP_L6:%.*]] = getelementptr i8, ptr [[PL]], i64 6
-; CHECK-NEXT: [[GEP_L7:%.*]] = getelementptr i8, ptr [[PL]], i64 7
-; CHECK-NEXT: [[LOAD0:%.*]] = load i8, ptr [[GEP_L0]], align 1
-; CHECK-NEXT: [[LOAD1:%.*]] = load i8, ptr [[GEP_L1]], align 1
-; CHECK-NEXT: [[LOAD2:%.*]] = load i8, ptr [[GEP_L2]], align 1
-; CHECK-NEXT: [[LOAD3:%.*]] = load i8, ptr [[GEP_L3]], align 1
-; CHECK-NEXT: [[LOAD4:%.*]] = load i8, ptr [[GEP_L4]], align 1
-; CHECK-NEXT: [[LOAD5:%.*]] = load i8, ptr [[GEP_L5]], align 1
-; CHECK-NEXT: [[LOAD6:%.*]] = load i8, ptr [[GEP_L6]], align 1
-; CHECK-NEXT: [[LOAD7:%.*]] = load i8, ptr [[GEP_L7]], align 1
; CHECK-NEXT: [[GEP_S0:%.*]] = getelementptr i8, ptr [[PS]], i64 0
-; CHECK-NEXT: [[GEP_S1:%.*]] = getelementptr i8, ptr [[PS]], i64 7
-; CHECK-NEXT: [[GEP_S2:%.*]] = getelementptr i8, ptr [[PS]], i64 14
-; CHECK-NEXT: [[GEP_S3:%.*]] = getelementptr i8, ptr [[PS]], i64 21
; CHECK-NEXT: [[GAP_PS:%.*]] = getelementptr i8, ptr [[PS]], i64 [[GAP]]
; CHECK-NEXT: [[GEP_S4:%.*]] = getelementptr i8, ptr [[GAP_PS]], i64 28
-; CHECK-NEXT: [[GEP_S5:%.*]] = getelementptr i8, ptr [[GAP_PS]], i64 35
-; CHECK-NEXT: [[GEP_S6:%.*]] = getelementptr i8, ptr [[GAP_PS]], i64 42
-; CHECK-NEXT: [[GEP_S7:%.*]] = getelementptr i8, ptr [[GAP_PS]], i64 49
-; CHECK-NEXT: store i8 [[LOAD0]], ptr [[GEP_S0]], align 1
-; CHECK-NEXT: store i8 [[LOAD1]], ptr [[GEP_S1]], align 1
-; CHECK-NEXT: store i8 [[LOAD2]], ptr [[GEP_S2]], align 1
-; CHECK-NEXT: store i8 [[LOAD3]], ptr [[GEP_S3]], align 1
-; CHECK-NEXT: store i8 [[LOAD4]], ptr [[GEP_S4]], align 1
-; CHECK-NEXT: store i8 [[LOAD5]], ptr [[GEP_S5]], align 1
-; CHECK-NEXT: store i8 [[LOAD6]], ptr [[GEP_S6]], align 1
-; CHECK-NEXT: store i8 [[LOAD7]], ptr [[GEP_S7]], align 1
+; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i8>, ptr [[GEP_L4]], align 1
+; CHECK-NEXT: [[TMP2:%.*]] = load <4 x i8>, ptr [[GEP_L0]], align 1
+; CHECK-NEXT: call void @llvm.experimental.vp.strided.store.v4i8.p0.i64(<4 x i8> [[TMP2]], ptr align 1 [[GEP_S0]], i64 7, <4 x i1> splat (i1 true), i32 4)
+; CHECK-NEXT: call void @llvm.experimental.vp.strided.store.v4i8.p0.i64(<4 x i8> [[TMP1]], ptr align 1 [[GEP_S4]], i64 7, <4 x i1> splat (i1 true), i32 4)
; CHECK-NEXT: ret void
;
%gep_l0 = getelementptr i8, ptr %pl, i64 0
@@ -372,37 +268,13 @@ define void @overlapping_strides(ptr %pl, ptr %ps) {
; CHECK-LABEL: define void @overlapping_strides(
; CHECK-SAME: ptr [[PL:%.*]], ptr [[PS:%.*]]) #[[ATTR0]] {
; CHECK-NEXT: [[GEP_L0:%.*]] = getelementptr i8, ptr [[PL]], i64 0
-; CHECK-NEXT: [[GEP_L1:%.*]] = getelementptr i8, ptr [[PL]], i64 1
-; CHECK-NEXT: [[GEP_L2:%.*]] = getelementptr i8, ptr [[PL]], i64 2
-; CHECK-NEXT: [[GEP_L3:%.*]] = getelementptr i8, ptr [[PL]], i64 3
; CHECK-NEXT: [[GEP_L4:%.*]] = getelementptr i8, ptr [[PL]], i64 4
-; CHECK-NEXT: [[GEP_L5:%.*]] = getelementptr i8, ptr [[PL]], i64 5
-; CHECK-NEXT: [[GEP_L6:%.*]] = getelementptr i8, ptr [[PL]], i64 6
-; CHECK-NEXT: [[GEP_L7:%.*]] = getelementptr i8, ptr [[PL]], i64 7
-; CHECK-NEXT: [[LOAD0:%.*]] = load i8, ptr [[GEP_L0]], align 1
-; CHECK-NEXT: [[LOAD1:%.*]] = load i8, ptr [[GEP_L1]], align 1
-; CHECK-NEXT: [[LOAD2:%.*]] = load i8, ptr [[GEP_L2]], align 1
-; CHECK-NEXT: [[LOAD3:%.*]] = load i8, ptr [[GEP_L3]], align 1
-; CHECK-NEXT: [[LOAD4:%.*]] = load i8, ptr [[GEP_L4]], align 1
-; CHECK-NEXT: [[LOAD5:%.*]] = load i8, ptr [[GEP_L5]], align 1
-; CHECK-NEXT: [[LOAD6:%.*]] = load i8, ptr [[GEP_L6]], align 1
-; CHECK-NEXT: [[LOAD7:%.*]] = load i8, ptr [[GEP_L7]], align 1
; CHECK-NEXT: [[GEP_S0:%.*]] = getelementptr i8, ptr [[PS]], i64 0
-; CHECK-NEXT: [[GEP_S1:%.*]] = getelementptr i8, ptr [[PS]], i64 2
-; CHECK-NEXT: [[GEP_S2:%.*]] = getelementptr i8, ptr [[PS]], i64 4
-; CHECK-NEXT: [[GEP_S3:%.*]] = getelementptr i8, ptr [[PS]], i64 6
; CHECK-NEXT: [[GEP_S4:%.*]] = getelementptr i8, ptr [[PS]], i64 5
-; CHECK-NEXT: [[GEP_S5:%.*]] = getelementptr i8, ptr [[PS]], i64 8
-; CHECK-NEXT: [[GEP_S7:%.*]] = getelementptr i8, ptr [[PS]], i64 11
-; CHECK-NEXT: [[GEP_S8:%.*]] = getelementptr i8, ptr [[PS]], i64 14
-; CHECK-NEXT: store i8 [[LOAD0]], ptr [[GEP_S0]], align 1
-; CHECK-NEXT: store i8 [[LOAD1]], ptr [[GEP_S1]], align 1
-; CHECK-NEXT: store i8 [[LOAD2]], ptr [[GEP_S2]], align 1
-; CHECK-NEXT: store i8 [[LOAD3]], ptr [[GEP_S3]], align 1
-; CHECK-NEXT: store i8 [[LOAD4]], ptr [[GEP_S4]], align 1
-; CHECK-NEXT: store i8 [[LOAD5]], ptr [[GEP_S5]], align 1
-; CHECK-NEXT: store i8 [[LOAD6]], ptr [[GEP_S7]], align 1
-; CHECK-NEXT: store i8 [[LOAD7]], ptr [[GEP_S8]], align 1
+; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i8>, ptr [[GEP_L0]], align 1
+; CHECK-NEXT: [[TMP2:%.*]] = load <4 x i8>, ptr [[GEP_L4]], align 1
+; CHECK-NEXT: call void @llvm.experimental.vp.strided.store.v4i8.p0.i64(<4 x i8> [[TMP1]], ptr align 1 [[GEP_S0]], i64 2, <4 x i1> splat (i1 true), i32 4)
+; CHECK-NEXT: call void @llvm.experimental.vp.strided.store.v4i8.p0.i64(<4 x i8> [[TMP2]], ptr align 1 [[GEP_S4]], i64 3, <4 x i1> splat (i1 true), i32 4)
; CHECK-NEXT: ret void
;
%gep_l0 = getelementptr i8, ptr %pl, i64 0
@@ -448,24 +320,12 @@ define void @constant_stride_unit_stride(ptr %pl, ptr %ps) {
; CHECK-LABEL: define void @constant_stride_unit_stride(
; CHECK-SAME: ptr [[PL:%.*]], ptr [[PS:%.*]]) #[[ATTR0]] {
; CHECK-NEXT: [[GEP_L0:%.*]] = getelementptr i8, ptr [[PL]], i64 0
-; CHECK-NEXT: [[GEP_L1:%.*]] = getelementptr i8, ptr [[PL]], i64 1
-; CHECK-NEXT: [[GEP_L2:%.*]] = getelementptr i8, ptr [[PL]], i64 2
-; CHECK-NEXT: [[GEP_L3:%.*]] = getelementptr i8, ptr [[PL]], i64 3
; CHECK-NEXT: [[GEP_L4:%.*]] = getelementptr i8, ptr [[PL]], i64 4
-; CHECK-NEXT: [[LOAD0:%.*]] = load i8, ptr [[GEP_L0]], align 1
-; CHECK-NEXT: [[LOAD1:%.*]] = load i8, ptr [[GEP_L1]], align 1
-; CHECK-NEXT: [[LOAD2:%.*]] = load i8, ptr [[GEP_L2]], align 1
-; CHECK-NEXT: [[LOAD3:%.*]] = load i8, ptr [[GEP_L3]], align 1
; CHECK-NEXT: [[GEP_S0:%.*]] = getelementptr i8, ptr [[PS]], i64 0
-; CHECK-NEXT: [[GEP_S1:%.*]] = getelementptr i8, ptr [[PS]], i64 2
-; CHECK-NEXT: [[GEP_S2:%.*]] = getelementptr i8, ptr [[PS]], i64 4
-; CHECK-NEXT: [[GEP_S3:%.*]] = getelementptr i8, ptr [[PS]], i64 6
; CHECK-NEXT: [[GEP_S4:%.*]] = getelementptr i8, ptr [[PS]], i64 8
; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i8>, ptr [[GEP_L4]], align 1
-; CHECK-NEXT: store i8 [[LOAD0]], ptr [[GEP_S0]], align 1
-; CHECK-NEXT: store i8 [[LOAD1]], ptr [[GEP_S1]], align 1
-; CHECK-NEXT: store i8 [[LOAD2]], ptr [[GEP_S2]], align 1
-; CHECK-NEXT: store i8 [[LOAD3]], ptr [[GEP_S3]], align 1
+; CHECK-NEXT: [[TMP2:%.*]] = load <4 x i8>, ptr [[GEP_L0]], align 1
+; CHECK-NEXT: call void @llvm.experimental.vp.strided.store.v4i8.p0.i64(<4 x i8> [[TMP2]], ptr align 1 [[GEP_S0]], i64 2, <4 x i1> splat (i1 true), i32 4)
; CHECK-NEXT: store <4 x i8> [[TMP1]], ptr [[GEP_S4]], align 1
; CHECK-NEXT: ret void
;
@@ -513,24 +373,12 @@ define void @unit_stride_constant_stride(ptr %pl, ptr %ps) {
; CHECK-SAME: ptr [[PL:%.*]], ptr [[PS:%.*]]) #[[ATTR0]] {
; CHECK-NEXT: [[GEP_L0:%.*]] = getelementptr i8, ptr [[PL]], i64 0
; CHECK-NEXT: [[GEP_L4:%.*]] = getelementptr i8, ptr [[PL]], i64 4
-; CHECK-NEXT: [[GEP_L5:%.*]] = getelementptr i8, ptr [[PL]], i64 5
-; CHECK-NEXT: [[GEP_L6:%.*]] = getelementptr i8, ptr [[PL]], i64 6
-; CHECK-NEXT: [[GEP_L7:%.*]] = getelementptr i8, ptr [[PL]], i64 7
-; CHECK-NEXT: [[LOAD4:%.*]] = load i8, ptr [[GEP_L4]], align 1
-; CHECK-NEXT: [[LOAD5:%.*]] = load i8, ptr [[GEP_L5]], align 1
-; CHECK-NEXT: [[LOAD6:%.*]] = load i8, ptr [[GEP_L6]], align 1
-; CHECK-NEXT: [[LOAD7:%.*]] = load i8, ptr [[GEP_L7]], align 1
; CHECK-NEXT: [[GEP_S0:%.*]] = getelementptr i8, ptr [[PS]], i64 0
; CHECK-NEXT: [[GEP_S4:%.*]] = getelementptr i8, ptr [[PS]], i64 9
-; CHECK-NEXT: [[GEP_S5:%.*]] = getelementptr i8, ptr [[PS]], i64 11
-; CHECK-NEXT: [[GEP_S6:%.*]] = getelementptr i8, ptr [[PS]], i64 13
-; CHECK-NEXT: [[GEP_S7:%.*]] = getelementptr i8, ptr [[PS]], i64 15
; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i8>, ptr [[GEP_L0]], align 1
+; CHECK-NEXT: [[TMP2:%.*]] = load <4 x i8>, ptr [[GEP_L4]], align 1
; CHECK-NEXT: store <4 x i8> [[TMP1]], ptr [[GEP_S0]], align 1
-; CHECK-NEXT: store i8 [[LOAD4]], ptr [[GEP_S4]], align 1
-; CHECK-NEXT: store i8 [[LOAD5]], ptr [[GEP_S5]], align 1
-; CHECK-NEXT: store i8 [[LOAD6]], ptr [[GEP_S6]], align 1
-; CHECK-NEXT: store i8 [[LOAD7]], ptr [[GEP_S7]], align 1
+; CHECK-NEXT: call void @llvm.experimental.vp.strided.store.v4i8.p0.i64(<4 x i8> [[TMP2]], ptr align 1 [[GEP_S4]], i64 2, <4 x i1> splat (i1 true), i32 4)
; CHECK-NEXT: ret void
;
%gep_l0 = getelementptr i8, ptr %pl, i64 0
@@ -577,24 +425,12 @@ define void @overlap(ptr %pl, ptr %ps) {
; CHECK-SAME: ptr [[PL:%.*]], ptr [[PS:%.*]]) #[[ATTR0]] {
; CHECK-NEXT: [[GEP_L0:%.*]] = getelementptr i8, ptr [[PL]], i64 0
; CHECK-NEXT: [[GEP_L4:%.*]] = getelementptr i8, ptr [[PL]], i64 4
-; CHECK-NEXT: [[GEP_L5:%.*]] = getelementptr i8, ptr [[PL]], i64 5
-; CHECK-NEXT: [[GEP_L6:%.*]] = getelementptr i8, ptr [[PL]], i64 6
-; CHECK-NEXT: [[GEP_L7:%.*]] = getelementptr i8, ptr [[PL]], i64 7
-; CHECK-NEXT: [[LOAD4:%.*]] = load i8, ptr [[GEP_L4]], align 1
-; CHECK-NEXT: [[LOAD5:%.*]] = load i8, ptr [[GEP_L5]], align 1
-; CHECK-NEXT: [[LOAD6:%.*]] = load i8, ptr [[GEP_L6]], align 1
-; CHECK-NEXT: [[LOAD7:%.*]] = load i8, ptr [[GEP_L7]], align 1
; CHECK-NEXT: [[GEP_S0:%.*]] = getelementptr i8, ptr [[PS]], i64 0
; CHECK-NEXT: [[GEP_S4:%.*]] = getelementptr i8, ptr [[PS]], i64 5
-; CHECK-NEXT: [[GEP_S5:%.*]] = getelementptr i8, ptr [[PS]], i64 7
-; CHECK-NEXT: [[GEP_S6:%.*]] = getelementptr i8, ptr [[PS]], i64 9
-; CHECK-NEXT: [[GEP_S7:%.*]] = getelementptr i8, ptr [[PS]], i64 11
; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i8>, ptr [[GEP_L0]], align 1
+; CHECK-NEXT: [[TMP2:%.*]] = load <4 x i8>, ptr [[GEP_L4]], align 1
; CHECK-NEXT: store <4 x i8> [[TMP1]], ptr [[GEP_S0]], align 1
-; CHECK-NEXT: store i8 [[LOAD4]], ptr [[GEP_S4]], align 1
-; CHECK-NEXT: store i8 [[LOAD5]], ptr [[GEP_S5]], align 1
-; CHECK-NEXT: store i8 [[LOAD6]], ptr [[GEP_S6]], align 1
-; CHECK-NEXT: store i8 [[LOAD7]], ptr [[GEP_S7]], align 1
+; CHECK-NEXT: call void @llvm.experimental.vp.strided.store.v4i8.p0.i64(<4 x i8> [[TMP2]], ptr align 1 [[GEP_S4]], i64 2, <4 x i1> splat (i1 true), i32 4)
; CHECK-NEXT: ret void
;
%gep_l0 = getelementptr i8, ptr %pl, i64 0
@@ -640,19 +476,15 @@ define void @overlap2(ptr %pl, ptr %ps) {
; CHECK-LABEL: define void @overlap2(
; CHECK-SAME: ptr [[PL:%.*]], ptr [[PS:%.*]]) #[[ATTR0]] {
; CHECK-NEXT: [[GEP_L0:%.*]] = getelementptr i8, ptr [[PL]], i64 0
-; CHECK-NEXT: [[GEP_L1:%.*]] = getelementptr i8, ptr [[PL]], i64 1
; CHECK-NEXT: [[GEP_L2:%.*]] = getelementptr i8, ptr [[PL]], i64 2
; CHECK-NEXT: [[GEP_L3:%.*]] = getelementptr i8, ptr [[PL]], i64 3
-; CHECK-NEXT: [[LOAD0:%.*]] = load i8, ptr [[GEP_L0]], align 1
-; CHECK-NEXT: [[LOAD1:%.*]] = load i8, ptr [[GEP_L1]], align 1
; CHECK-NEXT: [[LOAD2:%.*]] = load i8, ptr [[GEP_L2]], align 1
; CHECK-NEXT: [[GEP_S0:%.*]] = getelementptr i8, ptr [[PS]], i64 0
-; CHECK-NEXT: [[GEP_S1:%.*]] = getelementptr i8, ptr [[PS]], i64 2
; CHECK-NEXT: [[GEP_S2:%.*]] = getelementptr i8, ptr [[PS]], i64 4
; CHECK-NEXT: [[GEP_S3:%.*]] = getelementptr i8, ptr [[PS]], i64 6
; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i8>, ptr [[GEP_L3]], align 1
-; CHECK-NEXT: store i8 [[LOAD0]], ptr [[GEP_S0]], align 1
-; CHECK-NEXT: store i8 [[LOAD1]], ptr [[GEP_S1]], align 1
+; CHECK-NEXT: [[TMP2:%.*]] = load <2 x i8>, ptr [[GEP_L0]], align 1
+; CHECK-NEXT: call void @llvm.experimental.vp.strided.store.v2i8.p0.i64(<2 x i8> [[TMP2]], ptr align 1 [[GEP_S0]], i64 2, <2 x i1> splat (i1 true), i32 2)
; CHECK-NEXT: store i8 [[LOAD2]], ptr [[GEP_S2]], align 1
; CHECK-NEXT: store <4 x i8> [[TMP1]], ptr [[GEP_S3]], align 1
; CHECK-NEXT: ret void
@@ -704,13 +536,6 @@ define void @vf_ordering_issue(ptr %pl, ptr %ps) {
; CHECK-NEXT: [[GEP_L21:%.*]] = getelementptr i8, ptr [[PL]], i64 83
; CHECK-NEXT: [[GEP_L22:%.*]] = getelementptr i8, ptr [[PL]], i64 32
; CHECK-NEXT: [[GEP_L3:%.*]] = getelementptr i8, ptr [[PL]], i64 15
-; CHECK-NEXT: [[GEP_L16:%.*]] = getelementptr i8, ptr [[PL]], i64 16
-; CHECK-NEXT: [[GEP_L18:%.*]] = getelementptr i8, ptr [[PL]], i64 17
-; CHECK-NEXT: [[GEP_L9:%.*]] = getelementptr i8, ptr [[PL]], i64 18
-; CHECK-NEXT: [[GEP_L19:%.*]] = getelementptr i8, ptr [[PL]], i64 19
-; CHECK-NEXT: [[GEP_L24:%.*]] = getelementptr i8, ptr [[PL]], i64 20
-; CHECK-NEXT: [[GEP_L25:%.*]] = getelementptr i8, ptr [[PL]], i64 21
-; CHECK-NEXT: [[GEP_L26:%.*]] = getelementptr i8, ptr [[PL]], i64 22
; CHECK-NEXT: [[GEP_L23:%.*]] = getelementptr i8, ptr [[PL]], i64 23
; CHECK-NEXT: [[LOAD5:%.*]] = load i8, ptr [[GEP_S0]], align 1
; CHECK-NEXT: [[LOAD7:%.*]] = load i8, ptr [[GEP_L1]], align 1
@@ -719,14 +544,6 @@ define void @vf_ordering_issue(ptr %pl, ptr %ps) {
; CHECK-NEXT: [[LOAD20:%.*]] = load i8, ptr [[GEP_L20]], align 1
; CHECK-NEXT: [[LOAD21:%.*]] = load i8, ptr [[GEP_L21]], align 1
; CHECK-NEXT: [[LOAD22:%.*]] = load i8, ptr [[GEP_L22]], align 1
-; CHECK-NEXT: [[LOAD17:%.*]] = load i8, ptr [[GEP_L3]], align 1
-; CHECK-NEXT: [[LOAD16:%.*]] = load i8, ptr [[GEP_L16]], align 1
-; CHECK-NEXT: [[LOAD18:%.*]] = load i8, ptr [[GEP_L18]], align 1
-; CHECK-NEXT: [[LOAD9:%.*]] = load i8, ptr [[GEP_L9]], align 1
-; CHECK-NEXT: [[LOAD19:%.*]] = load i8, ptr [[GEP_L19]], align 1
-; CHECK-NEXT: [[LOAD24:%.*]] = load i8, ptr [[GEP_L24]], align 1
-; CHECK-NEXT: [[LOAD25:%.*]] = load i8, ptr [[GEP_L25]], align 1
-; CHECK-NEXT: [[LOAD26:%.*]] = load i8, ptr [[GEP_L26]], align 1
; CHECK-NEXT: [[LOAD23:%.*]] = load i8, ptr [[GEP_L23]], align 1
; CHECK-NEXT: [[GEP_S5:%.*]] = getelementptr i8, ptr [[PS]], i64 0
; CHECK-NEXT: [[GEP_S7:%.*]] = getelementptr i8, ptr [[PS]], i64 2
@@ -737,16 +554,10 @@ define void @vf_ordering_issue(ptr %pl, ptr %ps) {
; CHECK-NEXT: [[GEP_S13:%.*]] = getelementptr i8, ptr [[PS]], i64 18
; CHECK-NEXT: [[GEP_S14:%.*]] = getelementptr i8, ptr [[PS]], i64 20
; CHECK-NEXT: [[GEP_S15:%.*]] = getelementptr i8, ptr [[PS]], i64 22
-; CHECK-NEXT: [[GEP_S16:%.*]] = getelementptr i8, ptr [[PS]], i64 24
-; CHECK-NEXT: [[GEP_S17:%.*]] = getelementptr i8, ptr [[PS]], i64 26
-; CHECK-NEXT: [[GEP_S18:%.*]] = getelementptr i8, ptr [[PS]], i64 28
-; CHECK-NEXT: [[GEP_S19:%.*]] = getelementptr i8, ptr [[PS]], i64 30
-; CHECK-NEXT: [[GEP_S20:%.*]] = getelementptr i8, ptr [[PS]], i64 32
-; CHECK-NEXT: [[GEP_S21:%.*]] = getelementptr i8, ptr [[PS]], i64 34
-; CHECK-NEXT: [[GEP_S22:%.*]] = getelementptr i8, ptr [[PS]], i64 36
; CHECK-NEXT: [[GEP_S23:%.*]] = getelementptr i8, ptr [[PS]], i64 38
; CHECK-NEXT: [[TMP1:%.*]] = load <8 x i8>, ptr [[GEP_L4]], align 1
; CHECK-NEXT: [[TMP2:%.*]] = add <8 x i8> [[TMP1]], splat (i8 1)
+; CHECK-NEXT: [[TMP3:%.*]] = load <8 x i8>, ptr [[GEP_L3]], align 1
; CHECK-NEXT: store i8 [[LOAD5]], ptr [[GEP_S5]], align 1
; CHECK-NEXT: store i8 [[LOAD7]], ptr [[GEP_S7]], align 1
; CHECK-NEXT: store i8 [[LOAD14]], ptr [[GEP_S9]], align 1
@@ -755,14 +566,7 @@ define void @vf_ordering_issue(ptr %pl, ptr %ps) {
; CHECK-NEXT: store i8 [[LOAD20]], ptr [[GEP_S12]], align 1
; CHECK-NEXT: store i8 [[LOAD21]], ptr [[GEP_S13]], align 1
; CHECK-NEXT: store i8 [[LOAD22]], ptr [[GEP_S14]], align 1
-; CHECK-NEXT: store i8 [[LOAD17]], ptr [[GEP_S15]], align 1
-; CHECK-NEXT: store i8 [[LOAD16]], ptr [[GEP_S16]], align 1
-; CHECK-NEXT: store i8 [[LOAD18]], ptr [[GEP_S17]], align 1
-; CHECK-NEXT: store i8 [[LOAD9]], ptr [[GEP_S18]], align 1
-; CHECK-NEXT: store i8 [[LOAD19]], ptr [[GEP_S19]], align 1
-; CHECK-NEXT: store i8 [[LOAD24]], ptr [[GEP_S20]], align 1
-; CHECK-NEXT: store i8 [[LOAD25]], ptr [[GEP_S21]], align 1
-; CHECK-NEXT: store i8 [[LOAD26]], ptr [[GEP_S22]], align 1
+; CHECK-NEXT: call void @llvm.experimental.vp.strided.store.v8i8.p0.i64(<8 x i8> [[TMP3]], ptr align 1 [[GEP_S15]], i64 2, <8 x i1> splat (i1 true), i32 8)
; CHECK-NEXT: store i8 [[LOAD23]], ptr [[GEP_S23]], align 1
; CHECK-NEXT: ret void
;
>From 463e889706c392b955f5d56d78b33b76f230c570 Mon Sep 17 00:00:00 2001
From: bababuck <buchner.ryan at gmail.com>
Date: Thu, 26 Mar 2026 17:34:43 -0700
Subject: [PATCH 03/13] [SLP][NFC] Optimize for when strided stores are not
enabled
---
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 1c63f792da9f4..57b84918014d7 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -25976,6 +25976,7 @@ bool SLPVectorizerPass::vectorizeStores(
SmallVector<std::unique_ptr<StoreChainContext>> AllContexts;
BoUpSLP::ValueList Operands;
SmallVector<StoreChainContext::SizePair> RangeSizes;
+ unsigned MaxStride = EnableStridedStores ? MaxProfitableStride : 1;
// All chains that we're still building
struct PartialChainStatus {
@@ -25993,8 +25994,7 @@ bool SLPVectorizerPass::vectorizeStores(
// What is the Stride of this chain
unsigned Stride;
};
- SmallVector<SmallVector<PartialChainStatus, 1>> Chains(MaxProfitableStride +
- 1);
+ SmallVector<SmallVector<PartialChainStatus, 1>> Chains(MaxStride + 1);
auto GetChainsKey = [&](int64_t Query) -> unsigned {
// Just modulo function, get the index into Chains for a given query
int64_t Rem = (Query % (int64_t)Chains.size());
@@ -26033,11 +26033,10 @@ bool SLPVectorizerPass::vectorizeStores(
Status.Stride});
FoundStrides[Status.Stride] = true;
}
-
+ Chains[GetChainsKey(Dist)].clear();
// For any stride lengths that we didn't append to a chain for,
// instead start a new chain
- for (auto Stride : seq<unsigned>(
- 1, (EnableStridedStores ? MaxProfitableStride : 1) + 1)) {
+ for (auto Stride : seq<unsigned>(1, MaxStride + 1)) {
if (FoundStrides[Stride])
continue;
unsigned Key = GetChainsKey(Dist + Stride);
>From 946bf9df70692c562e2be9ce1f378c82734a8033 Mon Sep 17 00:00:00 2001
From: bababuck <buchner.ryan at gmail.com>
Date: Thu, 26 Mar 2026 17:35:01 -0700
Subject: [PATCH 04/13] [SLP][NFC] Optimize case when large distance between
stores
Decrease the amount of time spent clearing vectors
---
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 57b84918014d7..902cf50be16b1 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -26007,7 +26007,8 @@ bool SLPVectorizerPass::vectorizeStores(
auto &[Dist, InstIdx] = Data;
// Clean up chains that can't be continued
if (Idx > 0)
- for (int64_t D = LastDist; D < Dist; ++D)
+ for (int64_t D = LastDist;
+ D < std::min(Dist, LastDist + (int64_t)Chains.size()); ++D)
Chains[GetChainsKey(D)].clear();
LastDist = Dist;
>From 974d40a23c30f384f7262328d02f078b549e10af Mon Sep 17 00:00:00 2001
From: bababuck <buchner.ryan at gmail.com>
Date: Tue, 10 Mar 2026 15:43:06 -0700
Subject: [PATCH 05/13] [SLP] Assert no strided store revectorization
---
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 902cf50be16b1..03613d7fb5481 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -25571,6 +25571,8 @@ bool StoreChainContext::initializeContext(
BoUpSLP &R, const DataLayout &DL, const TargetTransformInfo &TTI,
DenseSet<std::tuple<Value *, Value *, Value *, Value *, unsigned>>
&Visited) {
+ assert((Stride == 1 || !SLPReVec) &&
+ "Strided stores not supported for revectorization");
if (!Visited
.insert({Operands.front(),
cast<StoreInst>(Operands.front())->getValueOperand(),
>From efed0997f066a46be10f4bc679bda34eb67a6104 Mon Sep 17 00:00:00 2001
From: bababuck <buchner.ryan at gmail.com>
Date: Mon, 30 Mar 2026 13:15:44 -0700
Subject: [PATCH 06/13] [SLP] Add braces to subobject
Not sure I agree with the need for the when subobject is union, but the warning causes smoketest to fail.
---
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 03613d7fb5481..738d82b6d8d41 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -26032,7 +26032,8 @@ bool SLPVectorizerPass::vectorizeStores(
}
unsigned Key = GetChainsKey(Status.Stride + Dist);
Chains[Key].push_back({/*AddedToAllContexts*/ true,
- Status.AllContextsIdx, /*FirstStore*/ nullptr,
+ {Status.AllContextsIdx},
+ /*FirstStore*/ nullptr,
Status.Stride});
FoundStrides[Status.Stride] = true;
}
@@ -26044,7 +26045,8 @@ bool SLPVectorizerPass::vectorizeStores(
continue;
unsigned Key = GetChainsKey(Dist + Stride);
Chains[Key].push_back({/*AddedToAllContexts*/ false,
- /*StoreSeqIdx*/ (unsigned)Idx, Stores[InstIdx],
+ {/*StoreSeqIdx*/ (unsigned)Idx},
+ Stores[InstIdx],
Stride});
}
}
>From 3597b628ad261758fc8ee950f67bfdfa5e9712fa Mon Sep 17 00:00:00 2001
From: bababuck <buchner.ryan at gmail.com>
Date: Tue, 31 Mar 2026 13:26:02 -0700
Subject: [PATCH 07/13] Fix /**/ formatting
---
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 738d82b6d8d41..2491e617aa497 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -26031,9 +26031,9 @@ bool SLPVectorizerPass::vectorizeStores(
Status.AllContextsIdx = AllContexts.size() - 1;
}
unsigned Key = GetChainsKey(Status.Stride + Dist);
- Chains[Key].push_back({/*AddedToAllContexts*/ true,
+ Chains[Key].push_back({/*AddedToAllContexts=*/true,
{Status.AllContextsIdx},
- /*FirstStore*/ nullptr,
+ /*FirstStore=*/nullptr,
Status.Stride});
FoundStrides[Status.Stride] = true;
}
@@ -26044,8 +26044,8 @@ bool SLPVectorizerPass::vectorizeStores(
if (FoundStrides[Stride])
continue;
unsigned Key = GetChainsKey(Dist + Stride);
- Chains[Key].push_back({/*AddedToAllContexts*/ false,
- {/*StoreSeqIdx*/ (unsigned)Idx},
+ Chains[Key].push_back({/*AddedToAllContexts=*/false,
+ {/*StoreSeqIdx=*/(unsigned)Idx},
Stores[InstIdx],
Stride});
}
>From 4938095640e2585c2618d3b4d8b16177fd55d812 Mon Sep 17 00:00:00 2001
From: bababuck <buchner.ryan at gmail.com>
Date: Wed, 1 Apr 2026 09:27:20 -0700
Subject: [PATCH 08/13] [SLP][NFC] Assert stores are ordered during tree
building
---
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 2491e617aa497..5b188cc98a8b0 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -12607,6 +12607,8 @@ void BoUpSLP::buildTreeRec(ArrayRef<Value *> VLRef, unsigned Depth,
return;
}
case Instruction::Store: {
+ assert(CurrentOrder.empty() &&
+ "Expected ordered store during tree building");
if (State == TreeEntry::StridedVectorize) {
TreeEntry *TE =
newTreeEntry(VL, TreeEntry::StridedVectorize, Bundle, S,
@@ -12619,18 +12621,10 @@ void BoUpSLP::buildTreeRec(ArrayRef<Value *> VLRef, unsigned Depth,
buildTreeRec(TE->getOperand(0), Depth + 1, {TE, 0});
return;
}
- bool Consecutive = CurrentOrder.empty();
- if (!Consecutive)
- fixupOrderingIndices(CurrentOrder);
TreeEntry *TE = newTreeEntry(VL, Bundle /*vectorized*/, S, UserTreeIdx,
ReuseShuffleIndices, CurrentOrder);
- if (Consecutive)
- LLVM_DEBUG(dbgs() << "SLP: added a new TreeEntry (StoreInst).\n";
- TE->dump());
- else
- LLVM_DEBUG(
- dbgs() << "SLP: added a new TreeEntry (jumbled StoreInst).\n";
- TE->dump());
+ LLVM_DEBUG(dbgs() << "SLP: added a new TreeEntry (StoreInst).\n";
+ TE->dump());
TE->setOperands(Operands);
buildTreeRec(TE->getOperand(0), Depth + 1, {TE, 0});
return;
>From 579ef7a305f5f5d5c562da108144e34d1fedd85c Mon Sep 17 00:00:00 2001
From: bababuck <buchner.ryan at gmail.com>
Date: Tue, 7 Apr 2026 12:06:44 -0700
Subject: [PATCH 09/13] stats
---
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 5b188cc98a8b0..ef40f48de10fa 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -112,6 +112,9 @@ using namespace std::placeholders;
#define DEBUG_TYPE "SLP"
STATISTIC(NumVectorInstructions, "Number of vector instructions generated");
+STATISTIC(NumStridedStoreChains, "Number of vectorized stride stores");
+STATISTIC(NumStoreChains, "Number of vector stores created");
+STATISTIC(NumVectorizedStores, "Number of vectorized stores");
DEBUG_COUNTER(VectorizedGraphs, "slp-vectorized",
"Controls which SLP graphs should be vectorized.");
@@ -25819,6 +25822,10 @@ bool StoreChainContext::vectorizeOneVF(
// it again.
markRangeVectorized(SliceStartIdx, VF, FirstUnvecStore, MaxSliceEnd);
SliceStartIdx += VF;
+ ++NumStoreChains;
+ if (Stride > 1)
+ ++NumStridedStoreChains;
+ NumVectorizedStores += VF;
continue;
}
if (VF > 2 && Res && !allOfRangeProfitable(SliceStartIdx, VF, TreeSize)) {
>From e8671b891861384219a94ecebd7b4aca876bf151 Mon Sep 17 00:00:00 2001
From: bababuck <buchner.ryan at gmail.com>
Date: Tue, 7 Apr 2026 14:49:58 -0700
Subject: [PATCH 10/13] [SLP] Fix bug
---
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index ef40f48de10fa..7e9627e41392c 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -26055,7 +26055,7 @@ bool SLPVectorizerPass::vectorizeStores(
unsigned GlobalMaxVF = 0;
for (auto &CtxPtr : AllContexts)
if (CtxPtr->initializeContext(R, *DL, *TTI, Visited))
- GlobalMaxVF = std::max(GlobalMaxVF, AllContexts.back()->getMaxVF());
+ GlobalMaxVF = std::max(GlobalMaxVF, CtxPtr->getMaxVF());
else
CtxPtr.reset();
>From 6ce4b7a6ac42a05fa043565701e393d9a4fe2cf2 Mon Sep 17 00:00:00 2001
From: bababuck <buchner.ryan at gmail.com>
Date: Wed, 8 Apr 2026 11:27:20 -0700
Subject: [PATCH 11/13] Fix more /**/ formatting
---
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 7e9627e41392c..74158cd4fff8d 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -7542,7 +7542,7 @@ BoUpSLP::LoadsState BoUpSLP::canVectorizeLoads(
Align CommonAlignment = computeCommonAlignment<LoadInst>(VL);
if (!IsSorted) {
if (analyzeRtStrideCandidate(PointerOps, ScalarTy, CommonAlignment, Order,
- SPtrInfo, /*isLoad*/ true))
+ SPtrInfo, /*isLoad=*/ true))
return LoadsState::StridedVectorize;
if (!TTI->isLegalMaskedGather(VecTy, CommonAlignment) ||
>From 10bb917d94773f4e8ade0424fb2e5dc40514c04b Mon Sep 17 00:00:00 2001
From: bababuck <buchner.ryan at gmail.com>
Date: Wed, 8 Apr 2026 12:08:43 -0700
Subject: [PATCH 12/13] Lint
---
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 41824e0ce3c10..8b4de566c19aa 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -7542,7 +7542,7 @@ BoUpSLP::LoadsState BoUpSLP::canVectorizeLoads(
Align CommonAlignment = computeCommonAlignment<LoadInst>(VL);
if (!IsSorted) {
if (analyzeRtStrideCandidate(PointerOps, ScalarTy, CommonAlignment, Order,
- SPtrInfo, /*isLoad=*/ true))
+ SPtrInfo, /*isLoad=*/true))
return LoadsState::StridedVectorize;
if (!TTI->isLegalMaskedGather(VecTy, CommonAlignment) ||
>From 7364e3c086a371d1009dade779e7a9ba9c49e7db Mon Sep 17 00:00:00 2001
From: bababuck <buchner.ryan at gmail.com>
Date: Wed, 8 Apr 2026 13:30:38 -0700
Subject: [PATCH 13/13] Address reviewer feedback
---
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 8b4de566c19aa..cd23112db1e69 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -10715,15 +10715,15 @@ BoUpSLP::TreeEntry::EntryState BoUpSLP::getScalarsVectorizationState(
Ptr0 = PointerOps[CurrentOrder.front()];
PtrN = PointerOps[CurrentOrder.back()];
}
- Align CommonAlignment = computeCommonAlignment<StoreInst>(VL0);
+ Align CommonAlignment = computeCommonAlignment<StoreInst>(VL);
std::optional<int64_t> Dist =
getPointersDiff(ScalarTy, Ptr0, ScalarTy, PtrN, *DL, *SE);
// Check that the sorted pointer operands are consecutive.
if (static_cast<uint64_t>(*Dist) == VL.size() - 1)
return TreeEntry::Vectorize;
- if (analyzeConstantStrideCandidate(PointerOps, ScalarTy, CommonAlignment,
- CurrentOrder, *Dist, Ptr0, PtrN,
- SPtrInfo))
+ if (EnableStridedStores && analyzeConstantStrideCandidate(
+ PointerOps, ScalarTy, CommonAlignment,
+ CurrentOrder, *Dist, Ptr0, PtrN, SPtrInfo))
return TreeEntry::StridedVectorize;
}
@@ -26014,7 +26014,7 @@ bool SLPVectorizerPass::vectorizeStores(
SmallVector<std::unique_ptr<StoreChainContext>> AllContexts;
BoUpSLP::ValueList Operands;
SmallVector<StoreChainContext::SizePair> RangeSizes;
- unsigned MaxStride = EnableStridedStores ? MaxProfitableStride : 1;
+ const unsigned MaxStride = EnableStridedStores ? MaxProfitableStride : 1;
// All chains that we're still building
struct PartialChainStatus {
More information about the llvm-commits
mailing list