[Mlir-commits] [mlir] [mlir][memref] Enforce consistent reinterpret_cast metadata (PR #217338)

ioana ghiban llvmlistbot at llvm.org
Thu Aug 20 02:29:55 PDT 2026


================
@@ -72,6 +72,29 @@ func.func @simplify_subview_all_dynamic(
 
 // -----
 
+// Check that constant folding of the descriptor is reflected in the result
+// type of the reinterpret_cast. The subview sizes remain dynamic because they
+// are SSA operands, while its offset and strides fold to static values.
----------------
ioghiban wrote:

The sizes could also be folded in principle, but `resolveSubviewStridedMetadata` treats them differently.

Offsets and strides are passed through:
```cpp
makeComposedFoldedAffineApply(...)
```
which looks through constant operands and returns static attributes such as `10`, `8`, and `2`.

Sizes are copied directly:
```cpp
finalSizes.push_back(subSizes[i]);
```

Therefore, `%c2` and `%c3` remain `Value`-backed `OpFoldResult`s. Later, `decomposeMixedValues` called by `updateTypeFromMetadata` classifies:
- `Attribute` → static type metadata
- `Value` → dynamic type metadata

It does not inspect whether a `Value` was defined by `arith.constant`.

So, while they're both statically known, the pattern represents them differently (perhaps something for a future PR/RFC?).
An additional normalisation step could fold the sizes, but the current transformation does not perform one.

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


More information about the Mlir-commits mailing list