[llvm] [SLP] Bail out on store-to-load forwarding hazards (PR #199606)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 1 08:20:48 PDT 2026
================
@@ -28885,6 +28903,156 @@ bool SLPVectorizerPass::runImpl(Function &F, ScalarEvolution *SE_,
return Changed;
}
+/// Returns the constant loop-carried byte stride of \p Ptr in \p L, i.e. the
+/// step of its affine SCEV recurrence, or std::nullopt when \p Ptr is not a
+/// simple affine recurrence in \p L with a constant step. This is the same
+/// notion as LoopAccessAnalysis's CommonStride; it is computed here directly
+/// from ScalarEvolution rather than via getPtrStride, whose no-wrap versioning
+/// and PredicatedScalarEvolution machinery is meant for legality, not costing.
+static std::optional<int64_t>
+getConstantLoopStrideInBytes(Value *Ptr, ScalarEvolution &SE, const Loop *L) {
+ const auto *AR = dyn_cast<SCEVAddRecExpr>(SE.getSCEV(Ptr));
+ if (!AR || AR->getLoop() != L)
+ return std::nullopt;
+ const auto *Step = dyn_cast<SCEVConstant>(AR->getStepRecurrence(SE));
+ if (!Step)
+ return std::nullopt;
+ const APInt &StepVal = Step->getAPInt();
+ if (StepVal.getSignificantBits() > 64)
+ return std::nullopt;
+ return StepVal.getSExtValue();
+}
+
+bool BoUpSLP::findStoreLoadForwardingConflict(StoreInst *BaseStore,
+ unsigned VF) {
+ if (!BaseStore)
+ return false;
+
+ StoreInst *FirstStore = BaseStore;
----------------
alexey-bataev wrote:
Remove FirstStore, use BaseStore instead
https://github.com/llvm/llvm-project/pull/199606
More information about the llvm-commits
mailing list