[Mlir-commits] [mlir] [mlir][vector] Clarify the semantics of gather/scatter indexing (nfc) (PR #181357)

Krzysztof Drewniak llvmlistbot at llvm.org
Mon Mar 16 14:54:29 PDT 2026


krzysz00 wrote:

So, this PR implements the semantics I was pushing for initially with its "going off the end of the last dimension proceeds as if in the identity layout" wording.

That definition doesn't match the lowering implemented in https://github.com/llvm/llvm-project/pull/184706 , which attempts to account for the multi-dimensionality of the memref, and has semantics that are meaningfully different from lowering directly to something like LLVM's gather.

I also had the sense that your initial RFC was *disagreeing* with the sort of "ignore subviews" indexing I'd been calling for when I first tried to clarify vector.gather semantics, and now we've ended up back where I started.

So, to state the question:

```
%indices = <0, 1, 2, 3> : vector<4xindex>
%res = vector.gather %memref[%c0, %c0], %indices : memref<2x2xf32, strided[128, 1]> to vector<4xf32>
```

If we let `float* base` be the base of `%memref` there (so that logical indexing works), is it
```
%res = <base[0], base[1], base[2], base[3]>
```
as your documentation update and VectorToLLVM suggests, or
```
%res = <base[0], base[1], base[128], base[129]>
```
as the new delinearization-based change suggests?

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


More information about the Mlir-commits mailing list