[Mlir-commits] [mlir] [mlir][SPIRV] Improve ub.unreachable lowering test case (PR #170083)

Matthias Springer llvmlistbot at llvm.org
Mon Dec 1 00:07:38 PST 2025


https://github.com/matthias-springer created https://github.com/llvm/llvm-project/pull/170083

Addresses a comment on the PR that introduces the ub.reachable -> spriv.Unreachable lowering (https://github.com/llvm/llvm-project/pull/169872#discussion_r2573670611).

>From 9b86aef4c10ee78b406af4579609508d974c7392 Mon Sep 17 00:00:00 2001
From: Matthias Springer <me at m-sp.org>
Date: Mon, 1 Dec 2025 08:04:54 +0000
Subject: [PATCH] [mlir][SPIRV] Improve ub.unreachable lowering test case

---
 mlir/test/Conversion/UBToSPIRV/ub-to-spirv.mlir | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/mlir/test/Conversion/UBToSPIRV/ub-to-spirv.mlir b/mlir/test/Conversion/UBToSPIRV/ub-to-spirv.mlir
index edbe8b8001bba..9c277cf99b9a8 100644
--- a/mlir/test/Conversion/UBToSPIRV/ub-to-spirv.mlir
+++ b/mlir/test/Conversion/UBToSPIRV/ub-to-spirv.mlir
@@ -1,4 +1,4 @@
-// RUN: mlir-opt -split-input-file -convert-ub-to-spirv -verify-diagnostics %s | FileCheck %s
+// RUN: mlir-opt -split-input-file -convert-ub-to-spirv %s | FileCheck %s
 
 module attributes {
   spirv.target_env = #spirv.target_env<
@@ -22,15 +22,17 @@ func.func @check_poison() {
 
 // -----
 
-// No successful test because the dialect conversion framework does not convert
-// unreachable blocks.
-
 module attributes {
   spirv.target_env = #spirv.target_env<
     #spirv.vce<v1.0, [Int8, Int16, Int64, Float16, Float64, Shader], []>, #spirv.resource_limits<>>
 } {
-func.func @check_unrechable() {
-// expected-error at +1{{cannot be used in reachable block}}
-  spirv.Unreachable
+// CHECK-LABEL: @check_unrechable
+func.func @check_unrechable(%c: i1) {
+  cf.cond_br %c, ^bb1, ^bb2
+^bb1:
+// CHECK: spirv.Unreachable
+  ub.unreachable
+^bb2:
+  return
 }
 }



More information about the Mlir-commits mailing list