[Mlir-commits] [mlir] [mlir][LLVMIR] Check number of elements in `mlir.constant` verifier (PR #102906)
Matthias Springer
llvmlistbot at llvm.org
Mon Aug 12 07:32:29 PDT 2024
================
@@ -2728,13 +2740,30 @@ LogicalResult LLVM::ConstantOp::verify() {
if (isa<IntegerType>(getType()) && !getType().isInteger(floatWidth)) {
return emitOpError() << "expected integer type of width " << floatWidth;
}
- }
- if (auto splatAttr = dyn_cast<SplatElementsAttr>(getValue())) {
- if (!isa<VectorType>(getType()) && !isa<LLVM::LLVMArrayType>(getType()) &&
- !isa<LLVM::LLVMFixedVectorType>(getType()) &&
- !isa<LLVM::LLVMScalableVectorType>(getType()))
+ } else if (isa<ElementsAttr, ArrayAttr>(getValue())) {
+ if (isa<LLVM::LLVMScalableVectorType>(getType())) {
----------------
matthias-springer wrote:
I was also wondering about that. We have test cases such as:
```
mlir/test/Conversion/MathToLLVM/math-to-llvm.mlir: // CHECK: %[[ONE:.*]] = llvm.mlir.constant(dense<1.000000e+00> : vector<[4]xf32>) : vector<[4]xf32>
mlir/test/Dialect/ArmSVE/legalize-for-llvm.mlir: // CHECK-NEXT: %[[RES0:.*]] = llvm.mlir.constant(dense<false> : vector<2x[16]xi1>) : !llvm.array<2 x vector<[16]xi1>>
```
This is what the op documentation says: `The operation produces a new SSA value of the specified LLVM IR dialect type. The type of that value _must_ correspond to the attribute type converted to LLVM IR.
`
https://github.com/llvm/llvm-project/pull/102906
More information about the Mlir-commits
mailing list