[llvm] [LV] Avoid adding stray predicates in isConsecutivePtr (PR #213662)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 5 23:59:38 PDT 2026


================
@@ -461,12 +461,14 @@ int LoopVectorizationLegality::isConsecutivePtr(Type *AccessTy,
   const auto &Strides = LAI && AllowRuntimeSCEVChecks
                             ? LAI->getSymbolicStrides()
                             : DenseMap<Value *, const SCEV *>();
-  int Stride = getPtrStride(PSE, AccessTy, Ptr, TheLoop, *DT, Strides,
-                            AllowRuntimeSCEVChecks, false)
+  SmallVector<const SCEVPredicate *> Predicates;
+  int Stride = getPtrStride(PSE, AccessTy, Ptr, TheLoop, *DT, Strides, false,
+                            AllowRuntimeSCEVChecks ? &Predicates : nullptr)
                    .value_or(0);
-  if (Stride == 1 || Stride == -1)
-    return Stride;
-  return 0;
+  if (std::abs(Stride) != 1)
----------------
lukel97 wrote:

Don't use std::abs as it has UB if Stride is INT_MIN

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


More information about the llvm-commits mailing list