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

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 6 06:04:26 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 (Stride != 1 && Stride != -1)
+    return 0;
+  for_each(Predicates, [&](const SCEVPredicate *P) { PSE.addPredicate(*P); });
----------------
lukel97 wrote:

```suggestion
  PSE.addPredicates(Predicates);
```

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


More information about the llvm-commits mailing list