[Mlir-commits] [mlir] Adding constraints to subview ValueBounds (PR #202994)

Matthias Springer llvmlistbot at llvm.org
Wed Jun 10 07:48:16 PDT 2026


================
@@ -135,6 +135,8 @@ struct SubViewOpInterface
         ++ctr;
       if (ctr == dim) {
         cstr.bound(value)[dim] == subViewOp.getMixedSizes()[i];
+        cstr.bound(value)[dim] <= cstr.getExpr(subViewOp.getSource(), i) -
----------------
matthias-springer wrote:

I'm not sure if this is correct. This is from the `memref.subview` documentation:

```
    The offset, size and stride operands must be in-bounds with respect to the
    source memref. When possible, the static operation verifier will detect
    out-of-bounds subviews. Subviews that cannot be confirmed to be in-bounds
    or out-of-bounds based on compile-time information are valid. However,
    performing an out-of-bounds subview at runtime is undefined behavior.
```

This seems to indicate that a `memref.subview` may run out-of-bounds. (Accessing the out-of-bounds part of the result subview is UB.)


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


More information about the Mlir-commits mailing list