[Mlir-commits] [mlir] [MLIR][Vector]Add constraints to vector.shape_cast(constant) -> constant (PR #147691)

Diego Caballero llvmlistbot at llvm.org
Tue Jul 22 10:35:02 PDT 2025


dcaballe wrote:

> The original solution in https://github.com/llvm/llvm-project/pull/147691 actually does a good job -- it uses the element type of the original attribute instead of the result.

My main concern about that fix is that the code is specialized to enable the folder on `llvm.mlir.constant` ops by specializing the implementation to the specific type semantics/constraints of `llvm.mlir.constant`. However, any op implementing the `ConstantOpLikeInterface` would hit that code, right?

```
  %0 = my_dialect.constant ...
  %1 = vector.shape_cast %0 : vector<12xi128> to vector<1x12xi128>
```

I think the fix should go in the direction of making the folder robust enough to handle any `ConstantOpLikeInterface`, even if that means bailing out in some cases, such as the `llvm.mlir.constant`. Perhaps we can just check that the attribute and return type match and bail out otherwise?

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


More information about the Mlir-commits mailing list