[llvm-branch-commits] [llvm] [llubi] Add support for vp.strided.load and vp.strided.store (PR #241715)

Luke Lau via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Nov 12 22:22:10 PST 2026


================
@@ -1075,6 +1075,35 @@ class InstExecutor : public InstVisitor<InstExecutor, void>,
                                         std::move(Data), Mode, IsStore);
   }
 
+  /// Implements llvm.experimental.vp.strided.{load,store} as a vp.gather or
+  /// vp.scatter of the pointers <Ptr, Ptr + Stride, Ptr + 2 * Stride, ...>.
+  /// \p Stride is signed and the arithmetic wraps in the pointer index type. An
+  /// align attribute on the base pointer applies to every lane's pointer.
+  AnyValue callVPStridedLoadStoreIntrinsic(CallBase &CB, const AnyValue &Ptr,
+                                           const AnyValue &Stride,
+                                           const AnyValue &Mask,
+                                           const AnyValue &EVL, AnyValue Data,
+                                           bool IsStore) {
+    const unsigned IndexBW =
+        DL.getIndexTypeSizeInBits(CB.getArgOperand(IsStore ? 1 : 0)->getType());
+    std::vector<AnyValue> LanePtrs(Mask.asAggregate().size(),
+                                   AnyValue::poison());
+    if (!Stride.isPoison()) {
+      const APInt StrideIdx = Stride.asInteger().sextOrTrunc(IndexBW);
+      for (auto [I, LanePtr] : enumerate(LanePtrs)) {
+        AnyValue AccumulatedOffset = AnyValue::poison();
+        LanePtr = Ctx.computePtrAdd(Ptr, StrideIdx * APInt(IndexBW, I),
+                                    GEPNoWrapFlags::none(), AccumulatedOffset);
----------------
lukel97 wrote:

Does vp.strided.load imply inbounds? It's defined in terms of vp.gather which is in turn defined as a llvm.masked.gather, which from the LangRef doesn't seem to imply that the individual scalar loads need to be inbounds of the base pointer.

LoopVectorizer and RISCVGatherScatterLowering also convert masked.gathers to vp.strided.loads without checking for the inbounds flag

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


More information about the llvm-branch-commits mailing list