[Mlir-commits] [mlir] [mlir][linalg] Emit proper diagnostic instead of crashing in SelectOp with index type (PR #183652)

Andrzej WarzyƄski llvmlistbot at llvm.org
Fri Mar 6 09:06:07 PST 2026


================
@@ -2172,3 +2172,15 @@ func.func @matmul_invalid_mixed_types(%t: tensor<?xf16>, %f: vector<4xf16>)
                                 outs(%f : vector<4xf16>) -> tensor<?xf16>
   func.return %0, %f : tensor<?xf16>, vector<4xf16>
 }
+
+// -----
+
+// Regression test: linalg.select with index type operands should emit a
+// diagnostic instead of crashing (https://github.com/llvm/llvm-project/issues/179046).
+func.func @select_invalid_index_type(%cond: index, %a: index, %b: index,
+                                     %out: tensor<1xindex>) -> tensor<1xindex> {
+  // expected-error @below {{unsupported non numeric type}}
+  %0 = linalg.select ins(%cond, %a, %b : index, index, index)
+                     outs(%out : tensor<1xindex>) -> tensor<1xindex>
+  return %0 : tensor<1xindex>
+}
----------------
banach-space wrote:

I know that your goal is to fix https://github.com/llvm/llvm-project/issues/179046, but I find this test confusing.

Ultimately, `linalg.select` parsing should fail in two cases:
* `%cond` is not a boolean
* `type(%lhs) != `type(%rhs)`

Which of the two cases is tested here and Is using `index` for `%lhs` and `%rhs` significant here?

My kind request - ignore the case presented in #179046 (the edge case is not clear) and instead make sure that tests in this file cover all interesting cases. That's currently not the case for `linalg.select`, so thanks for looking into this!

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


More information about the Mlir-commits mailing list