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

James Newling llvmlistbot at llvm.org
Fri Jul 11 09:37:46 PDT 2025


https://github.com/newling commented:


This PR https://github.com/llvm/llvm-project/pull/133988 moved the canonicalizer to a folder, that is probably what triggered your error. 

I am not sure if 

```mlir 
%0 = llvm.mlir.constant(dense<0.000000e+00> : vector<12xf8E4M3FN>) : vector<12xi8>
```

is valid. I can see the bitwidth of the element, and the number of elements is the same between the 2 vectors. But I'd have thought they must be identical. Maybe there is a verification missing in `LogicalResult LLVM::ConstantOp::verify() `?


When I run 

`mlir-opt --verify-diagnostics  playtime.mlir`

on 

```mlir
func.func @canonicalize_extract_shapecast_different_element_type()->vector<12xi128> {
  %0 = llvm.mlir.constant(dense<0.000000e+00> : vector<12xf8E4M3FN>) : vector<12xi128>
  %1 = vector.shape_cast %0 : vector<12xi128> to vector<1x12xi128>
  %2 = vector.extract %1[0] : vector<12xi128> from vector<1x12xi128>
  return %2 : vector<12xi128>
}
```

I don't get an error either, but this example looks especially wrong because the number of bits is different between the element types. 

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


More information about the Mlir-commits mailing list