1 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
2 // RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \
3 // RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s \
4 // RUN: --check-prefixes=CHECK,DXIL_CHECK,DXIL_NATIVE_HALF,NATIVE_HALF
5 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
6 // RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
7 // RUN: -o - | FileCheck %s --check-prefixes=CHECK,DXIL_CHECK,NO_HALF,DXIL_NO_HALF
8 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
9 // RUN: spirv-unknown-vulkan-compute %s -fnative-half-type \
10 // RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s \
11 // RUN: --check-prefixes=CHECK,NATIVE_HALF,SPIR_NATIVE_HALF,SPIR_CHECK
12 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
13 // RUN: spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
14 // RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF,SPIR_NO_HALF,SPIR_CHECK
16 // DXIL_NATIVE_HALF: define noundef half @
17 // SPIR_NATIVE_HALF: define spir_func noundef half @
18 // NATIVE_HALF: %hlsl.rcp = fdiv half 0xH3C00, %{{.*}}
19 // NATIVE_HALF: ret half %hlsl.rcp
20 // DXIL_NO_HALF: define noundef float @
21 // SPIR_NO_HALF: define spir_func noundef float @
22 // NO_HALF: %hlsl.rcp = fdiv float 1.000000e+00, %{{.*}}
23 // NO_HALF: ret float %hlsl.rcp
24 half test_rcp_half(half p0) { return rcp(p0); }
26 // DXIL_NATIVE_HALF: define noundef <2 x half> @
27 // SPIR_NATIVE_HALF: define spir_func noundef <2 x half> @
28 // NATIVE_HALF: %hlsl.rcp = fdiv <2 x half> splat (half 0xH3C00), %{{.*}}
29 // NATIVE_HALF: ret <2 x half> %hlsl.rcp
30 // DXIL_NO_HALF: define noundef <2 x float> @
31 // SPIR_NO_HALF: define spir_func noundef <2 x float> @
32 // NO_HALF: %hlsl.rcp = fdiv <2 x float> splat (float 1.000000e+00), %{{.*}}
33 // NO_HALF: ret <2 x float> %hlsl.rcp
34 half2 test_rcp_half2(half2 p0) { return rcp(p0); }
36 // DXIL_NATIVE_HALF: define noundef <3 x half> @
37 // SPIR_NATIVE_HALF: define spir_func noundef <3 x half> @
38 // NATIVE_HALF: %hlsl.rcp = fdiv <3 x half> splat (half 0xH3C00), %{{.*}}
39 // NATIVE_HALF: ret <3 x half> %hlsl.rcp
40 // DXIL_NO_HALF: define noundef <3 x float> @
41 // SPIR_NO_HALF: define spir_func noundef <3 x float> @
42 // NO_HALF: %hlsl.rcp = fdiv <3 x float> splat (float 1.000000e+00), %{{.*}}
43 // NO_HALF: ret <3 x float> %hlsl.rcp
44 half3 test_rcp_half3(half3 p0) { return rcp(p0); }
46 // DXIL_NATIVE_HALF: define noundef <4 x half> @
47 // SPIR_NATIVE_HALF: define spir_func noundef <4 x half> @
48 // NATIVE_HALF: %hlsl.rcp = fdiv <4 x half> splat (half 0xH3C00), %{{.*}}
49 // NATIVE_HALF: ret <4 x half> %hlsl.rcp
50 // DXIL_NO_HALF: define noundef <4 x float> @
51 // SPIR_NO_HALF: define spir_func noundef <4 x float> @
52 // NO_HALF: %hlsl.rcp = fdiv <4 x float> splat (float 1.000000e+00), %{{.*}}
53 // NO_HALF: ret <4 x float> %hlsl.rcp
54 half4 test_rcp_half4(half4 p0) { return rcp(p0); }
56 // DXIL_CHECK: define noundef float @
57 // SPIR_CHECK: define spir_func noundef float @
58 // CHECK: %hlsl.rcp = fdiv float 1.000000e+00, %{{.*}}
59 // CHECK: ret float %hlsl.rcp
60 float test_rcp_float(float p0) { return rcp(p0); }
62 // DXIL_CHECK: define noundef <2 x float> @
63 // SPIR_CHECK: define spir_func noundef <2 x float> @
64 // CHECK: %hlsl.rcp = fdiv <2 x float> splat (float 1.000000e+00), %{{.*}}
65 // CHECK: ret <2 x float> %hlsl.rcp
66 float2 test_rcp_float2(float2 p0) { return rcp(p0); }
68 // DXIL_CHECK: define noundef <3 x float> @
69 // SPIR_CHECK: define spir_func noundef <3 x float> @
70 // CHECK: %hlsl.rcp = fdiv <3 x float> splat (float 1.000000e+00), %{{.*}}
71 // CHECK: ret <3 x float> %hlsl.rcp
72 float3 test_rcp_float3(float3 p0) { return rcp(p0); }
74 // DXIL_CHECK: define noundef <4 x float> @
75 // SPIR_CHECK: define spir_func noundef <4 x float> @
76 // CHECK: %hlsl.rcp = fdiv <4 x float> splat (float 1.000000e+00), %{{.*}}
77 // CHECK: ret <4 x float> %hlsl.rcp
78 float4 test_rcp_float4(float4 p0) { return rcp(p0); }
80 // DXIL_CHECK: define noundef double @
81 // SPIR_CHECK: define spir_func noundef double @
82 // CHECK: %hlsl.rcp = fdiv double 1.000000e+00, %{{.*}}
83 // CHECK: ret double %hlsl.rcp
84 double test_rcp_double(double p0) { return rcp(p0); }
86 // DXIL_CHECK: define noundef <2 x double> @
87 // SPIR_CHECK: define spir_func noundef <2 x double> @
88 // CHECK: %hlsl.rcp = fdiv <2 x double> splat (double 1.000000e+00), %{{.*}}
89 // CHECK: ret <2 x double> %hlsl.rcp
90 double2 test_rcp_double2(double2 p0) { return rcp(p0); }
92 // DXIL_CHECK: define noundef <3 x double> @
93 // SPIR_CHECK: define spir_func noundef <3 x double> @
94 // CHECK: %hlsl.rcp = fdiv <3 x double> splat (double 1.000000e+00), %{{.*}}
95 // CHECK: ret <3 x double> %hlsl.rcp
96 double3 test_rcp_double3(double3 p0) { return rcp(p0); }
98 // DXIL_CHECK: define noundef <4 x double> @
99 // SPIR_CHECK: define spir_func noundef <4 x double> @
100 // CHECK: %hlsl.rcp = fdiv <4 x double> splat (double 1.000000e+00), %{{.*}}
101 // CHECK: ret <4 x double> %hlsl.rcp
102 double4 test_rcp_double4(double4 p0) { return rcp(p0); }