Something some others and I have come across is a need for an index curry for memref types. By this specifically I mean that I would like to be able to perform the first level of indexing to a load/store prior to the load/store operation
This is somewhat similar to the subview op, but not exactly the same. In particular subview requires knowing the remaining size/bounds/access pattern, whereas this is not necessarily always available in our use case.
A simple example of this op would be as follows:
%idx = ... : index
%ref = ... : memref<?x5xi32>
%sref = subindex %ref %idx : memref<?x5xi32> to memref<5xi32>
%loaded = load %sref[%c3]
A second, related use case is performing an offset on the first index (again without knowing the remaining bounds). This could be a different operation, but for ease I’ve also demonstrated it using “subindex” again.
%idx = ... : index
%ref = ... : memref<?xi32>
%sref = subindex %ref %idx : memref<?xi32> to memref<?xi32>
%loaded = load %sref[%c3]; // perform a load at 3 + %idx
I wonder if people have seen similar issues and generally if they have thoughts on this.
For our use case, we’ve implemented a simple version of the above “subindex” that does the corresponding operations, with relevant canonicalizations that attempts to remove the subindex when it sees a load/store/etc.
cc @ftynse @lorenzo_chelini @kumasento