This patch implements the mem2reg interfaces for MemRef types. This only supports scalar memrefs of a small list of types. It would be beneficial to create more interfaces for default values before expanding support to more types. Additionally, I am working on an upcoming revision to bring SROA to MLIR that should help with non-scalar memrefs.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Is there any limitation on the sizes of buffers that can be promoted? Obviously you don't want memref<16x16xf64> to get promoted.
mlir/test/Transforms/mem2reg-memref.mlir | ||
---|---|---|
1 | I believe the policy is that this test should go with the rest of the MemRef dialect tests, not in the Transforms tests |
Thanks for the reviews!
mlir/lib/Dialect/MemRef/IR/MemRefMem2Reg.cpp | ||
---|---|---|
38 | @Mogball This implementation only allows mem2reg on scalar memrefs, this is the check enforcing that. | |
84–85 | getMemRef() == slot.ptr for stores is exercised by deny_store_of_alloca. For the rest, this logic is hard to trigger from mem2reg because it would typically mean that the interface implementation for allocators is buggy. So it could make sense to make this an assert it in theory, but the interface specification is more flexible than that, expecting no crash. Notably, nothing prevents a third-party user of the interface to ask for the use of a slot that has nothing to do with this load. Considering how the testing infrastructure works, I feel like the burden of testing falls on the user here, because I don't really know how to test it in practice. I would like to hear your opinion about this. I still added a test (promotable_nonpromotable_intertwined) that would be likely to trigger this in case of bug. | |
mlir/test/Transforms/mem2reg-memref.mlir | ||
1 | Okay! I also moved the LLVM tests which were put in the same place. |
mlir/lib/Dialect/MemRef/IR/MemRefMem2Reg.cpp | ||
---|---|---|
38 | swag |
@Mogball This implementation only allows mem2reg on scalar memrefs, this is the check enforcing that.