Skip to content

Commit a617a49

Browse files
author
Tim Corringham
committed
Update tests for f16tof32()
Replace the f16tof32 test with an unpackhalf2x16 test, to match changes to the spirv codegen for f16to32 support. Adjust the f16tof32-errors.hlsl diagnostics test.
1 parent 1ea977b commit a617a49

File tree

3 files changed

+25
-83
lines changed

3 files changed

+25
-83
lines changed

clang/test/SemaHLSL/BuiltIns/f16tof32-errors.hlsl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify
1+
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.6-library %s -fnative-int16-type -emit-llvm-only -disable-llvm-passes -verify
22

33
float builtin_f16tof32_too_few_arg() {
44
return __builtin_hlsl_elementwise_f16tof32();
@@ -22,12 +22,12 @@ float builtin_f16tof32_bool4(bool4 p0) {
2222
// expected-error@-1 {{1st argument must be a scalar or vector of unsigned integer types (was 'bool4' (aka 'vector<bool, 4>')}}
2323
}
2424

25-
float builtin_f16tof32_int16_t(int16_t p0) {
25+
float builtin_f16tof32_short(short p0) {
2626
return __builtin_hlsl_elementwise_f16tof32(p0);
27-
// expected-error@-1 {{1st argument must be a scalar or vector of unsigned integer types (was 'int16_t' (aka 'short'))}}
27+
// expected-error@-1 {{1st argument must be a scalar or vector of unsigned integer types (was 'short')}}
2828
}
2929

30-
float builtin_f16tof32_int16_t(unsigned short p0) {
30+
float builtin_f16tof32_unsigned_short(unsigned short p0) {
3131
return __builtin_hlsl_elementwise_f16tof32(p0);
3232
// expected-error@-1 {{incorrect number of bits in integer (expected 32 bits, have 16)}}
3333
}
@@ -84,13 +84,13 @@ float f16tof32_bool(bool p0) {
8484

8585
float f16tof32_bool3(bool3 p0) {
8686
return f16tof32(p0);
87-
// expected-error@-1 {{1st argument must be a scalar or vector of unsigned integer types (was 'bool3' (aka 'vector<bool, 3>')}}
87+
// expected-error@-1 {{1st argument must be a scalar or vector of unsigned integer types (was 'bool3' (aka 'vector<bool, 3>'))}}
8888
}
8989

9090

91-
float f16tof32_int16_t(int16_t p0) {
91+
float f16tof32_int16_t(short p0) {
9292
return f16tof32(p0);
93-
// expected-error@-1 {{1st argument must be a scalar or vector of unsigned integer types (was 'int16_t' (aka 'short'))}}
93+
// expected-error@-1 {{1st argument must be a scalar or vector of unsigned integer types (was 'short')}}
9494
}
9595

9696
float f16tof32_int16_t(unsigned short p0) {

llvm/test/CodeGen/SPIRV/hlsl-intrinsics/f16tof32.ll

Lines changed: 0 additions & 76 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv-unknown-vulkan %s -o - | FileCheck %s
2+
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan %s -o - -filetype=obj | spirv-val %}
3+
4+
; CHECK-DAG: [[SET:%.*]] = OpExtInstImport "GLSL.std.450"
5+
; CHECK-DAG: [[UINT:%.*]] = OpTypeInt 32 0
6+
; CHECK-DAG: [[FLOAT:%.*]] = OpTypeFloat 32
7+
; CHECK-DAG: [[FLOAT2:%.*]] = OpTypeVector [[FLOAT]] 2
8+
9+
; CHECK: [[P0:%.*]] = OpFunctionParameter [[UINT]]
10+
; CHECK: [[UNPACK2:%.*]] = OpExtInst [[FLOAT2]] [[SET]] UnpackHalf2x16 [[P0]]
11+
; CHECK: [[UNPACK:%.*]] = OpCompositeExtract [[FLOAT]] [[UNPACK2]] 0
12+
; CHECK: OpReturnValue [[UNPACK]]
13+
define hidden spir_func noundef nofpclass(nan inf) float @_Z9test_funcj(i32 noundef %0) local_unnamed_addr #0 {
14+
%2 = tail call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.spv.unpackhalf2x16.v2f32(i32 %0)
15+
%3 = extractelement <2 x float> %2, i64 0
16+
ret float %3
17+
}
18+

0 commit comments

Comments
 (0)