[Mlir-commits] [mlir] [mlir][bufferization] Add XFAIL test for bufferize-function-boundaries returning unranked memref (PR #176746)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Feb 9 03:29:14 PST 2026


================
@@ -0,0 +1,19 @@
+// RUN: mlir-opt %s -one-shot-bufferize="bufferize-function-boundaries" -verify-each | FileCheck %s
----------------
tridhapuku wrote:

Hi @matthias-springer,
I’m considering tightening **foldMemRefCasts** at **func.return** to only strip a memref.cast when dropping it is guaranteed not to lose useful return-type precision.

Right now, **foldMemRefCasts** can drop a memref.cast without checking whether the cast result carries more compile-time information than the source (so removing it could hide information that return-type tightening would otherwise see).

I’d keep the cast (don’t “unpack”) if it’s precision-gaining in any of these ways:

1. **Rank:** don’t unpack unranked → ranked
2. **Shape:** don’t unpack if dst has any static dim where src is dynamic
3. **Layout:** don’t unpack if dst layout is strictly more specific (handle identity vs StridedLayoutAttr; stay conservative for other layout maps)
4. **Memory space:** don’t unpack if memory space differs (could erase “where the buffer lives”, e.g. default vs GPU/shared/etc.)

Does this “**only drop non-precision-gaining casts (plus memspace mismatch)**” policy sound acceptable? I’ll follow up with a PR + targeted tests and adjust as needed based on review.

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


More information about the Mlir-commits mailing list