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

Arnab Dutta llvmlistbot at llvm.org
Sun Apr 27 20:12:59 PDT 2025


================
@@ -1845,6 +1781,95 @@ LogicalResult mlir::affine::normalizeMemRef(AllocLikeOp allocOp) {
   return success();
 }
 
+LogicalResult
+mlir::affine::normalizeMemRef(memref::ReinterpretCastOp reinterpretCastOp) {
+  MemRefType memrefType = reinterpretCastOp.getType();
+  AffineMap oldLayoutMap = memrefType.getLayout().getAffineMap();
+  Value oldMemRef = reinterpretCastOp.getResult();
+
+  // If `oldLayoutMap` is identity, `memrefType` is already normalized.
+  if (oldLayoutMap.isIdentity())
+    return success();
+
+  // Fetch a new memref type after normalizing the old memref to have an
+  // identity map layout.
+  MemRefType newMemRefType = normalizeMemRefType(memrefType);
+  newMemRefType.dump();
----------------
arnab-polymage wrote:

Thanks for catching this. Will remove.

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


More information about the Mlir-commits mailing list