[Mlir-commits] [mlir] emit inbounds and nuw attributes in memref. (PR #138984)

Andrzej WarzyƄski llvmlistbot at llvm.org
Mon May 12 12:33:57 PDT 2025


banach-space wrote:

> It is guaranteed that memref.load and memref.store must be inbounds: 0 <= idx < dim_size.

I don't quite follow this statement - is it really guaranteed? Looking at one of the tests that has been updated:
```mlir
func.func @static_store(%static : memref<10x42xf32>, %i : index, %j : index, %val : f32) {
  memref.store %val, %static[%i, %j] : memref<10x42xf32>
  return
}
```

How can we be sure that `i` and `j` are in bounds? I appreciate that the docs ( [memref.store](https://mlir.llvm.org/docs/Dialects/MemRef/#memrefstore-memrefstoreop)) state that:
> The indices must be in-bounds: 0 <= idx < dim_size

but there's just nothing to enforce that, is there? It would be good to somehow document that this assumption is used when lowering to `llvm.getelemptr`.

Also, why `nuw` instead of `nsuw`?

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


More information about the Mlir-commits mailing list