[clang] [llvm] Hlsl asint16 intrinsic (PR #131900)

Farzon Lotfi via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 19 08:47:47 PDT 2025


================
@@ -0,0 +1,55 @@
+; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s
+; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %}
+
+; CHECK: OpCapability Int16
+; CHECK: OpCapability Float16
+; CHECK-DAG: %[[#int_16:]] = OpTypeInt 16 0
+; CHECK-DAG: %[[#float_16:]] = OpTypeFloat 16
+; CHECK-DAG: %[[#vec4_int_16:]] = OpTypeVector %[[#int_16]] 4
+; CHECK-DAG: %[[#vec4_float_16:]] = OpTypeVector %[[#float_16]] 4
+
+
+define i16 @test_int16(i16 returned %p0) {
+entry:
+  ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#int_16]]
+  ; CHECK: OpReturnValue %[[#arg0]]
+  ret i16 %p0
+}
+
+define i16 @test_half(half nofpclass(nan inf) %p0) {
+entry:
+  ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#float_16:]]
+  ; CHECK: %[[#]] = OpBitcast %[[#int_16]] %[[#arg0]]
+  %0 = bitcast half %p0 to i16
----------------
farzonl wrote:

This case is already covered by `llvm/test/CodeGen/SPIRV/bitcast.ll`

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


More information about the llvm-commits mailing list