[Mlir-commits] [mlir] [MLIR][Arith] Fix crash in `arith.select` verification with mixed types (PR #178840)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Feb 3 07:52:41 PST 2026
https://github.com/zeyi2 updated https://github.com/llvm/llvm-project/pull/178840
>From f72439df36c78967811e7e1ae64f140034209419 Mon Sep 17 00:00:00 2001
From: mtx <mitchell.xu2 at gmail.com>
Date: Thu, 29 Jan 2026 23:59:56 +0800
Subject: [PATCH 1/2] [mlir][arith] Fix crash in arith.select verification with
mixed types
---
mlir/include/mlir/Dialect/Arith/IR/ArithOps.td | 4 +++-
mlir/test/Dialect/Arith/invalid.mlir | 11 +++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td b/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
index 77d780425c3c3..c8754954c181d 100644
--- a/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
+++ b/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
@@ -1742,7 +1742,9 @@ class BooleanConditionOrMatchingShape<string condition, string result> :
PredOpTrait<
condition # " is signless i1 or has matching shape",
Or<[TypeIsPred<condition, I1>,
- AllShapesMatch<[condition, result]>.predicate]>>;
+ And<[SubstLeaves<"$_self", "$" # condition # ".getType()", IsShapedTypePred>,
+ SubstLeaves<"$_self", "$" # result # ".getType()", IsShapedTypePred>,
+ AllShapesMatch<[condition, result]>.predicate]>]>>;
def SelectOp : Arith_Op<"select", [Pure,
AllTypesMatch<["true_value", "false_value", "result"]>,
diff --git a/mlir/test/Dialect/Arith/invalid.mlir b/mlir/test/Dialect/Arith/invalid.mlir
index 2e3debcb263c0..0e8c3e119ed21 100644
--- a/mlir/test/Dialect/Arith/invalid.mlir
+++ b/mlir/test/Dialect/Arith/invalid.mlir
@@ -869,3 +869,14 @@ func.func @bitcast_index_1(%arg0 : index) -> i64 {
%0 = arith.bitcast %arg0 : index to i64
return %0 : i64
}
+
+// -----
+
+func.func @select_vector_condition_scalar_operands() {
+ %0 = vector.vscale
+ %1 = vector.constant_mask [1] : vector<1xi1>
+ %3 = arith.index_castui %0 : index to i32
+ // expected-error @+1 {{'arith.select' op failed to verify that condition is signless i1 or has matching shape}}
+ %4 = arith.select %1, %3, %3 : vector<1xi1>, i32
+ return
+}
>From a00806c306cff42841270ae6a55dbe608276c08d Mon Sep 17 00:00:00 2001
From: mtx <mitchell.xu2 at gmail.com>
Date: Tue, 3 Feb 2026 23:52:14 +0800
Subject: [PATCH 2/2] Reduce testcases
---
mlir/test/Dialect/Arith/invalid.mlir | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/mlir/test/Dialect/Arith/invalid.mlir b/mlir/test/Dialect/Arith/invalid.mlir
index 0e8c3e119ed21..70b23e56a712c 100644
--- a/mlir/test/Dialect/Arith/invalid.mlir
+++ b/mlir/test/Dialect/Arith/invalid.mlir
@@ -872,11 +872,8 @@ func.func @bitcast_index_1(%arg0 : index) -> i64 {
// -----
-func.func @select_vector_condition_scalar_operands() {
- %0 = vector.vscale
- %1 = vector.constant_mask [1] : vector<1xi1>
- %3 = arith.index_castui %0 : index to i32
+func.func @select_vector_condition_scalar_operands(%arg0: vector<1xi1>, %arg1: i32) {
// expected-error @+1 {{'arith.select' op failed to verify that condition is signless i1 or has matching shape}}
- %4 = arith.select %1, %3, %3 : vector<1xi1>, i32
+ %0 = arith.select %arg0, %arg1, %arg1 : vector<1xi1>, i32
return
}
More information about the Mlir-commits
mailing list