[Mlir-commits] [mlir] [mlir][spirv] Fix crash in ArithToSPIRV trunc-i lowering on tensor types (PR #179009)
Jakub Kuderski
llvmlistbot at llvm.org
Mon Feb 2 07:53:18 PST 2026
================
@@ -199,3 +199,49 @@ func.func @type_conversion_failure(%arg0: i32) {
}
} // end module
+
+// -----
+
+module attributes {
+ spirv.target_env = #spirv.target_env<
+ #spirv.vce<v1.0, [], []>, #spirv.resource_limits<>>
+} {
+
+// Tensor truncation is not supported; ensure conversion fails gracefully (no crash).
+func.func @unsupported_tensor_trunci(%arg0: tensor<1xi32>) -> tensor<1xi16> {
+ // expected-error at +1 {{failed to legalize operation 'arith.trunci'}}
+ %t = arith.trunci %arg0 : tensor<1xi32> to tensor<1xi16>
+ return %t : tensor<1xi16>
+}
+
+} // end module
+
+// -----
+
+module attributes {
+ spirv.target_env = #spirv.target_env<
+ #spirv.vce<v1.0, [], []>, #spirv.resource_limits<>>
+} {
+
+ // Tensor extui is not supported; ensure conversion fails (and does not crash).
+ func.func @unsupported_tensor_extui(%arg0: tensor<1xi8>) -> tensor<1xi32> {
+ // expected-error @+1 {{failed to legalize operation 'arith.extui'}}
+ %t = arith.extui %arg0 : tensor<1xi8> to tensor<1xi32>
+ return %t : tensor<1xi32>
+ }
+} // end module
+
+// -----
+
+module attributes {
+ spirv.target_env = #spirv.target_env<
+ #spirv.vce<v1.0, [], []>, #spirv.resource_limits<>>
+} {
+
+ // Tensor extsi is not supported; ensure conversion fails (and does not crash).
+ func.func @unsupported_tensor_extsi(%arg0: tensor<1xi8>) -> tensor<1xi32> {
+ // expected-error @+1 {{failed to legalize operation 'arith.extsi'}}
+ %t = arith.extsi %arg0 : tensor<1xi8> to tensor<1xi32>
----------------
kuhar wrote:
This is not always the case, but I'm not sure when it comes to dialect conversion -- could you check?
https://github.com/llvm/llvm-project/pull/179009
More information about the Mlir-commits
mailing list