[llvm] [HLSL][SPIRV] Add error test for unpackhalf2x16 (PR #166969)

Tim Corringham via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 7 09:29:05 PST 2025


https://github.com/tcorringham created https://github.com/llvm/llvm-project/pull/166969

Add an error test to check that a suitable error diagnostic is generated for the use of the GL::unpackhalf2x16 operation in
 invalid contexts.

Fixes #166965

>From 02f44e5a5a0062113b2b61a72d5d7c8a4b7372c2 Mon Sep 17 00:00:00 2001
From: Tim Corringham <tcorring at amd.com>
Date: Fri, 7 Nov 2025 17:23:57 +0000
Subject: [PATCH] [HLSL][SPIRV] Add error test for unpackhalf2x16

Add an error test to check that a suitable error diagnostic is
generated for the use of the GL::unpackhalf2x16 operation in
 invalid contexts.

Fixes #166965
---
 .../test/CodeGen/SPIRV/opencl/unpackhalf2x16-error.ll | 11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 llvm/test/CodeGen/SPIRV/opencl/unpackhalf2x16-error.ll

diff --git a/llvm/test/CodeGen/SPIRV/opencl/unpackhalf2x16-error.ll b/llvm/test/CodeGen/SPIRV/opencl/unpackhalf2x16-error.ll
new file mode 100644
index 0000000000000..1d3ba2a38e55b
--- /dev/null
+++ b/llvm/test/CodeGen/SPIRV/opencl/unpackhalf2x16-error.ll
@@ -0,0 +1,11 @@
+; RUN: not llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o /dev/null 2>&1 | FileCheck %s
+; RUN: not llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o /dev/null 2>&1 | FileCheck %s
+
+; CHECK: LLVM ERROR: %5:vfid(<2 x s64>) = nnan ninf nsz arcp afn reassoc G_INTRINSIC intrinsic(@llvm.spv.unpackhalf2x16), %0:iid(s64) is only supported with the GLSL extended instruction set.
+
+define hidden spir_func noundef nofpclass(nan inf) float @_Z9test_funcj(i32 noundef %0) local_unnamed_addr #0 {
+  %2 = tail call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.spv.unpackhalf2x16.v2f32(i32 %0)
+  %3 = extractelement <2 x float> %2, i64 0
+  ret float %3
+}
+



More information about the llvm-commits mailing list