[llvm] [LAA] Allow vectorizing `A[NonZeroNonConstantStride*I] += 1` (PR #186262)

Igor Kirillov via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 26 07:34:01 PDT 2026


================
@@ -1646,15 +1648,16 @@ void AccessAnalysis::buildDependenceSets() {
   }
 }
 
-/// Check whether the access through \p Ptr has a constant stride.
-std::optional<int64_t>
-llvm::getPtrStride(PredicatedScalarEvolution &PSE, Type *AccessTy, Value *Ptr,
-                   const Loop *Lp, const DominatorTree &DT,
-                   const DenseMap<Value *, const SCEV *> &StridesMap,
-                   bool Assume, bool ShouldCheckWrap) {
+/// Check whether the access through \p Ptr has a loop invariant stride of a
+/// statically known sign.
+static const SCEV *
+getPtrStrideScev(PredicatedScalarEvolution &PSE, Type *AccessTy, Value *Ptr,
+                 const Loop *Lp, const DominatorTree &DT,
+                 const DenseMap<Value *, const SCEV *> &StridesMap, bool Assume,
+                 bool ShouldCheckWrap) {
   const SCEV *PtrScev = replaceSymbolicStrideSCEV(PSE, StridesMap, Ptr);
   if (PSE.getSE()->isLoopInvariant(PtrScev, Lp))
-    return 0;
+    return PSE.getSE()->getZero(Type::getInt64Ty(AccessTy->getContext()));
----------------
igogo-x86 wrote:

Not sure if hard-coded Int64Ty is correct here for every architecture.

https://github.com/llvm/llvm-project/pull/186262


More information about the llvm-commits mailing list