[Mlir-commits] [mlir] [mlir][mem2reg] Promote memory slots through transparent view operations (PR #196924)
Tobias Gysi
llvmlistbot at llvm.org
Mon May 11 22:01:58 PDT 2026
================
@@ -550,18 +557,37 @@ Value MemorySlotPromoter::promoteInBlock(Block *block, Value reachingDef) {
if (info.userToBlockingUses[memOp->getParentRegion()].contains(memOp))
reachingDefs.insert({memOp, reachingDef});
- if (memOp.storesTo(slot)) {
+ MemorySlot viewSlot = getOpViewSlot(memOp, slot).value_or(slot);
+ if (memOp.storesTo(viewSlot)) {
----------------
gysit wrote:
A bitcast on pointers should fold after the opaque pointer change (if it is even valid). So in practice the LLVM dialect implementation should be fine.
I agree that there will be changes needed to make views work. For example, the algo that searches the loads/stores from the slot for sure needs to walk through the views.
Mixing dialects is probably a good argument for some sort of `SlotViewOpInterface`. It seems to be used for two things: 1) finding the underlying slot and 2) type conversion. With regards to the type conversion I wonder if this couldn't be done as part of `PromotableMemOpInteface` since we essentially need to slot type and the load/store type to create the cast? Although maybe this is not the case if you mix dialects.
https://github.com/llvm/llvm-project/pull/196924
More information about the Mlir-commits
mailing list