[Mlir-commits] [mlir] [mlir] Add Memref Normalization support for reinterpret_cast op (PR #133417)

Arnab Dutta llvmlistbot at llvm.org
Wed Apr 9 21:01:49 PDT 2025


================
@@ -353,16 +354,25 @@ void NormalizeMemRefs::normalizeFuncOpMemRefs(func::FuncOp funcOp,
   // Turn memrefs' non-identity layouts maps into ones with identity. Collect
   // alloc/alloca ops first and then process since normalizeMemRef
   // replaces/erases ops during memref rewriting.
-  SmallVector<memref::AllocOp, 4> allocOps;
-  funcOp.walk([&](memref::AllocOp op) { allocOps.push_back(op); });
-  for (memref::AllocOp allocOp : allocOps)
+  SmallVector<AllocOp, 4> allocOps;
+  funcOp.walk([&](AllocOp op) { allocOps.push_back(op); });
+  for (AllocOp allocOp : allocOps)
     (void)normalizeMemRef(allocOp);
 
-  SmallVector<memref::AllocaOp> allocaOps;
-  funcOp.walk([&](memref::AllocaOp op) { allocaOps.push_back(op); });
-  for (memref::AllocaOp allocaOp : allocaOps)
+  SmallVector<AllocaOp> allocaOps;
+  funcOp.walk([&](AllocaOp op) { allocaOps.push_back(op); });
+  for (AllocaOp allocaOp : allocaOps)
     (void)normalizeMemRef(allocaOp);
 
+  // Turn memrefs' non-identity layouts maps into ones with identity. Collect
+  // reinterpret_cast ops first and then process since normalizeMemRef
+  // replaces/erases ops during memref rewriting.
+  SmallVector<ReinterpretCastOp> reinterpretCastOps;
+  funcOp.walk(
+      [&](ReinterpretCastOp op) { reinterpretCastOps.push_back(op); });
----------------
arnab-polymage wrote:

It won't currently becaue we process only dereferencing uses of an op which is to be normalized.

https://github.com/llvm/llvm-project/pull/133417


More information about the Mlir-commits mailing list