diff --git a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp index 79bf87ccd34af..4f663b8d47a26 100644 --- a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp +++ b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp @@ -6516,9 +6516,15 @@ ParseResult MaskOp::parse(OpAsmParser &parser, OperationState &result) { if (parser.resolveOperand(mask, maskType, result.operands)) return failure(); - if (parsePassthru.succeeded()) + if (parsePassthru.succeeded()) { + if (resultTypes.empty()) + return parser.emitError( + parser.getNameLoc(), + "expects a result if passthru operand is provided"); + if (parser.resolveOperand(passthru, resultTypes[0], result.operands)) return failure(); + } return success(); } diff --git a/mlir/test/Dialect/Vector/invalid.mlir b/mlir/test/Dialect/Vector/invalid.mlir index be65d4c2eef58..740c6b7ae3174 100644 --- a/mlir/test/Dialect/Vector/invalid.mlir +++ b/mlir/test/Dialect/Vector/invalid.mlir @@ -1747,6 +1747,24 @@ func.func @vector_mask_0d_mask(%arg0: tensor<2x4xi32>, // ----- +func.func @vector_mask_empty_passthru_no_return_type(%mask : vector<8xi1>, + %passthru : vector<8xi32>) { + // expected-error@+1 {{'vector.mask' expects a result if passthru operand is provided}} + vector.mask %mask, %passthru { } : vector<8xi1> + return +} + +// ----- + +func.func @vector_mask_empty_passthru_empty_return_type(%mask : vector<8xi1>, + %passthru : vector<8xi32>) { + // expected-error@+1 {{'vector.mask' expects a result if passthru operand is provided}} + vector.mask %mask, %passthru { } : vector<8xi1> -> () + return +} + +// ----- + func.func @vector_scalable_insert_unaligned(%subv: vector<4xi32>, %vec: vector<[16]xi32>) { // expected-error@+1 {{op failed to verify that position is a multiple of the source length.}} %0 = vector.scalable.insert %subv, %vec[2] : vector<4xi32> into vector<[16]xi32>