[Mlir-commits] [mlir] [mlir][vector] reject negative strides for `vector.load`/`vector.store` (PR #204611)

Andrzej WarzyƄski llvmlistbot at llvm.org
Mon Jun 22 02:53:00 PDT 2026


================
@@ -6194,6 +6194,13 @@ LogicalResult vector::LoadOp::verify() {
   if (failed(verifyLoadStoreMemRefLayout(*this, resVecTy, memRefTy)))
     return failure();
 
+  // Negative strides are not supported on vector.load.
+  auto [strides, offset] = memRefTy.getStridesAndOffset();
+  for (int64_t stride : strides) {
+    if (ShapedType::isStatic(stride) && stride < 0)
+      return emitOpError("memref strides must be non-negative");
+  }
----------------
banach-space wrote:

>From what I can tell, this duplicates [hasNonNegativeStrides](https://github.com/llvm/llvm-project/blob/a696a09aa7a40a3f764157b090367dd74399d863/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp#L226-L234). I suggest moving `hasNonNegativeStrides` to https://github.com/llvm/llvm-project/blob/d2dd4ce545bd5753f37181f2821bc8ac07601de8/mlir/include/mlir/Dialect/MemRef/Utils/MemRefUtils.h

and then re-using here.

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


More information about the Mlir-commits mailing list