spirv::getElementPtr can return null (for memrefs with affine map) but patterns didn't handle this.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Thanks for fixing this! Just one nit: could you also update the comment for spirv::getElementPtr to mention that it can return nullptr when it cannot perform the index calculation?
Also, is there any plans to actually support memrefs with dynamic offset and strides?
Awesome, thanks!
Dynamic shapes / strides are a bit tricky for the SPIR-V side due to that we cannot always use a memref descriptor for it like LLVM (see the details here). In IREE we have been working with another approach towards it, without the memref descriptor. Basically we flatten the n-D memref into 1-D (effectively what the memref descriptor is doing under the hood for CPU side, relying on LLVM proper) before converting to SPIR-V using this pass. And then SPIR-V conversion only needs to handle the case where we have a 1-D flat memref/buffer. It effectively pushes the index calculation to a previous stage; instead of relying it being done at SPIR-V level. I'd like to upstream that sometime later.