[Mlir-commits] [mlir] [mlir][Vector] Add constant folding for vector.from_elements operation (PR #145849)

Yang Bai llvmlistbot at llvm.org
Thu Jun 26 04:01:05 PDT 2025


yangtetris wrote:

I found that the following MLIR code causes a crash:
```
%c1 = llvm.mlir.constant(1 : index) : i64
%c2 = llvm.mlir.constant(2 : index) : i64
%res = vector.from_elements %c1, %c2 : vector<2xi64>
```
The error is:
llvm-project/mlir/lib/IR/BuiltinAttributes.cpp:978: static mlir::DenseElementsAttr mlir::DenseElementsAttr::get(mlir::ShapedType, llvm::ArrayRef<mlir::Attribute>): Assertion `intAttr.getType() == eltType && "expected integer attribute type to equal element type"' failed.

It seems that this issue is the same as [this one](https://github.com/llvm/llvm-project/issues/74236). So I committed a change that applies `convertIntegerAttr` before creating the dense elements attribute.

@Groverkss could you please take another look? Thanks!


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


More information about the Mlir-commits mailing list