Support index type in memrefs/vectors

Hi!

I’m just curious… I wanted to check where we are with regarding supporting index type as element type of memref and vector. The documentation talks about some early problems that MLIR wasn’t ready to address at that time:
MLIR Rationale - MLIR. I wonder if those problems are still there and if we are ready to address them now :slight_smile:.

I cannot be very specific but I have a use case where I need a memref of a constant number of indexes (let’s say memref<3xindex>), and then load them into a vector (vector<3xindex>). This code would then be lowered to LLVM using the proper target-specific index size. I’m currently workarounding this limitation by using the target-specific index type (i.e., i32/i64) early on in MLIR for memrefs/vectors. However, I have to be doing all the i32/i64 <-> index castings when these aggregate types interact with other index types, which makes some other transformation a bit more complicated.

Any plans on supporting index memrefs/vectors?

Thanks,
Diego

We previously touched on this in the later parts of the thread [RFC] Remove MemRefType element type check? Or add pointer support to ‘std’ dialect? - #10 by _sean_silva

There was some consensus to loosen the restriction. I think we would accept a patch doing that and updating the rationale doc. See @ftynse’s last post in that thread for a bit more ramifications of doing this that you will need to look out for.

1 Like

Thanks for the pointer!

Absolutely. It is the right time to move forward on this. There are multiple unnecessary pains due to this restriction.