[Mlir-commits] [mlir] b6dfe4d - [mlir][Vector] Fix `vector.mask` parser for incorrect passthru cases (#140319)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon May 19 11:20:48 PDT 2025
Author: Diego Caballero
Date: 2025-05-19T11:20:45-07:00
New Revision: b6dfe4dbfecc753a28c82e044e022dff6e7365b1
URL: https://github.com/llvm/llvm-project/commit/b6dfe4dbfecc753a28c82e044e022dff6e7365b1
DIFF: https://github.com/llvm/llvm-project/commit/b6dfe4dbfecc753a28c82e044e022dff6e7365b1.diff
LOG: [mlir][Vector] Fix `vector.mask` parser for incorrect passthru cases (#140319)
This MR fixes a crash when parsing an invalid `vector.mask` with a
passtru operand.
Added:
Modified:
mlir/lib/Dialect/Vector/IR/VectorOps.cpp
mlir/test/Dialect/Vector/invalid.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
index 7ae43b64a5deb..1b5534d4d94ff 100644
--- a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
+++ b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
@@ -6517,9 +6517,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 at +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 at +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 at +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>
More information about the Mlir-commits
mailing list