xref: /llvm-project/clang/test/CodeGenHLSL/builtins/asfloat.hlsl (revision 1bfc3d0de591b6b4e18ee720bd24f58e45d597ef)
1// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -O1 -o - | FileCheck %s
2
3// CHECK: define {{.*}}test_uint{{.*}}(i32 {{.*}} [[VAL:%.*]]){{.*}}
4// CHECK: bitcast i32 [[VAL]] to float
5float test_uint(uint p0) {
6  return asfloat(p0);
7}
8
9// CHECK: define {{.*}}test_int{{.*}}(i32 {{.*}} [[VAL:%.*]]){{.*}}
10// CHECK: bitcast i32 [[VAL]] to float
11float test_int(int p0) {
12  return asfloat(p0);
13}
14
15// CHECK: define {{.*}}test_float{{.*}}(float {{.*}} [[VAL:%.*]]){{.*}}
16// CHECK-NOT: bitcast
17// CHECK: ret float [[VAL]]
18float test_float(float p0) {
19  return asfloat(p0);
20}
21
22// CHECK: define {{.*}}test_vector_uint{{.*}}(<4 x i32> {{.*}} [[VAL:%.*]]){{.*}}
23// CHECK: bitcast <4 x i32> [[VAL]] to <4 x float>
24
25float4 test_vector_uint(uint4 p0) {
26  return asfloat(p0);
27}
28
29// CHECK: define {{.*}}test_vector_int{{.*}}(<4 x i32> {{.*}} [[VAL:%.*]]){{.*}}
30// CHECK: bitcast <4 x i32> [[VAL]] to <4 x float>
31float4 test_vector_int(int4 p0) {
32  return asfloat(p0);
33}
34
35// CHECK: define {{.*}}test_vector_float{{.*}}(<4 x float> {{.*}} [[VAL:%.*]]){{.*}}
36// CHECK-NOT: bitcast
37// CHECK: ret <4 x float> [[VAL]]
38float4 test_vector_float(float4 p0) {
39  return asfloat(p0);
40}
41