[#llvm-getPtrStride-05] = xref:llvm.adoc[llvm]::getPtrStride :relfileprefix: ../ :mrdocs: If the pointer has a constant stride return it in units of the access type size. If the pointer is loop‐invariant, return 0. Otherwise return std::nullopt. == Synopsis Declared in `<llvm/Analysis/LoopAccessAnalysis.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- std::optional<int64_t> getPtrStride( xref:llvm/PredicatedScalarEvolution.adoc[PredicatedScalarEvolution]& PSE, xref:llvm/Type.adoc[Type]* AccessTy, xref:llvm/Value.adoc[Value]* Ptr, xref:llvm/Loop.adoc[Loop] const* Lp, xref:llvm/DominatorTree.adoc[DominatorTree] const& DT, xref:llvm/DenseMap-0c.adoc[DenseMap<Value*, SCEV const*>] const& StridesMap = DenseMap<Value *, const SCEV *>(), bool ShouldCheckWrap = true, xref:llvm/SmallVectorImpl-06c.adoc[SmallVectorImpl<SCEVPredicate const*>]* Predicates = nullptr); ---- == Description Ensure that it does not wrap in the address space, assuming the predicate associated with `PSE` is true. If necessary this method will version the stride of the pointer according to `PtrToStride` and therefore add further predicates to `PSE.` If `Predicates` is non‐null, add no‐wrap SCEV predicates if needed. Note that the analysis results are defined if‐and‐only‐if the original memory access was defined. If that access was dead, or UB, then the result of this function is undefined. == Return Value The constant stride in access‐type units, 0 if invariant, or std::nullopt. == Parameters [cols="1,4"] |=== | Name| Description | *PSE* | Predicated SCEV used to analyze and version the pointer. | *AccessTy* | Type of the memory access through `Ptr.` | *Ptr* | Pointer whose stride is queried. | *Lp* | Loop in which `Ptr` is accessed. | *DT* | Dominator tree used for context‐sensitive reasoning. | *StridesMap* | Map from pointers to symbolic stride SCEVs. | *ShouldCheckWrap* | When true, ensure the pointer does not wrap. | *Predicates* | Optional vector that collects required SCEV predicates. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#