Debian Codegraph @

clang/test/CodeGenHLSL/builtins/abs.hlsl

raw
1 // RUN: %clang_cc1 -std=hlsl2021 -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,NATIVE_HALF
5 // RUN: %clang_cc1 -std=hlsl2021 -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,NO_HALF
8
9 using hlsl::abs;
10
11 #ifdef __HLSL_ENABLE_16_BIT
12 // NATIVE_HALF: define noundef i16 @
13 // NATIVE_HALF: call i16 @llvm.abs.i16(
14 int16_t test_abs_int16_t(int16_t p0) { return abs(p0); }
15 // NATIVE_HALF: define noundef <2 x i16> @
16 // NATIVE_HALF: call <2 x i16> @llvm.abs.v2i16(
17 int16_t2 test_abs_int16_t2(int16_t2 p0) { return abs(p0); }
18 // NATIVE_HALF: define noundef <3 x i16> @
19 // NATIVE_HALF: call <3 x i16> @llvm.abs.v3i16(
20 int16_t3 test_abs_int16_t3(int16_t3 p0) { return abs(p0); }
21 // NATIVE_HALF: define noundef <4 x i16> @
22 // NATIVE_HALF: call <4 x i16> @llvm.abs.v4i16(
23 int16_t4 test_abs_int16_t4(int16_t4 p0) { return abs(p0); }
24 #endif // __HLSL_ENABLE_16_BIT
25
26 // NATIVE_HALF: define noundef half @
27 // NATIVE_HALF: call half @llvm.fabs.f16(
28 // NO_HALF: define noundef float @"?test_abs_half@@YA$halff@$halff@@Z"(
29 // NO_HALF: call float @llvm.fabs.f32(float %0)
30 half test_abs_half(half p0) { return abs(p0); }
31 // NATIVE_HALF: define noundef <2 x half> @
32 // NATIVE_HALF: call <2 x half> @llvm.fabs.v2f16(
33 // NO_HALF: define noundef <2 x float> @"?test_abs_half2@@YAT?$__vector@$halff@$01@__clang@@T12@@Z"(
34 // NO_HALF: call <2 x float> @llvm.fabs.v2f32(
35 half2 test_abs_half2(half2 p0) { return abs(p0); }
36 // NATIVE_HALF: define noundef <3 x half> @
37 // NATIVE_HALF: call <3 x half> @llvm.fabs.v3f16(
38 // NO_HALF: define noundef <3 x float> @"?test_abs_half3@@YAT?$__vector@$halff@$02@__clang@@T12@@Z"(
39 // NO_HALF: call <3 x float> @llvm.fabs.v3f32(
40 half3 test_abs_half3(half3 p0) { return abs(p0); }
41 // NATIVE_HALF: define noundef <4 x half> @
42 // NATIVE_HALF: call <4 x half> @llvm.fabs.v4f16(
43 // NO_HALF: define noundef <4 x float> @"?test_abs_half4@@YAT?$__vector@$halff@$03@__clang@@T12@@Z"(
44 // NO_HALF: call <4 x float> @llvm.fabs.v4f32(
45 half4 test_abs_half4(half4 p0) { return abs(p0); }
46 // CHECK: define noundef i32 @
47 // CHECK: call i32 @llvm.abs.i32(
48 int test_abs_int(int p0) { return abs(p0); }
49 // CHECK: define noundef <2 x i32> @
50 // CHECK: call <2 x i32> @llvm.abs.v2i32(
51 int2 test_abs_int2(int2 p0) { return abs(p0); }
52 // CHECK: define noundef <3 x i32> @
53 // CHECK: call <3 x i32> @llvm.abs.v3i32(
54 int3 test_abs_int3(int3 p0) { return abs(p0); }
55 // CHECK: define noundef <4 x i32> @
56 // CHECK: call <4 x i32> @llvm.abs.v4i32(
57 int4 test_abs_int4(int4 p0) { return abs(p0); }
58 // CHECK: define noundef float @
59 // CHECK: call float @llvm.fabs.f32(
60 float test_abs_float(float p0) { return abs(p0); }
61 // CHECK: define noundef <2 x float> @
62 // CHECK: call <2 x float> @llvm.fabs.v2f32(
63 float2 test_abs_float2(float2 p0) { return abs(p0); }
64 // CHECK: define noundef <3 x float> @
65 // CHECK: call <3 x float> @llvm.fabs.v3f32(
66 float3 test_abs_float3(float3 p0) { return abs(p0); }
67 // CHECK: define noundef <4 x float> @
68 // CHECK: call <4 x float> @llvm.fabs.v4f32(
69 float4 test_abs_float4(float4 p0) { return abs(p0); }
70 // CHECK: define noundef i64 @
71 // CHECK: call i64 @llvm.abs.i64(
72 int64_t test_abs_int64_t(int64_t p0) { return abs(p0); }
73 // CHECK: define noundef <2 x i64> @
74 // CHECK: call <2 x i64> @llvm.abs.v2i64(
75 int64_t2 test_abs_int64_t2(int64_t2 p0) { return abs(p0); }
76 // CHECK: define noundef <3 x i64> @
77 // CHECK: call <3 x i64> @llvm.abs.v3i64(
78 int64_t3 test_abs_int64_t3(int64_t3 p0) { return abs(p0); }
79 // CHECK: define noundef <4 x i64> @
80 // CHECK: call <4 x i64> @llvm.abs.v4i64(
81 int64_t4 test_abs_int64_t4(int64_t4 p0) { return abs(p0); }
82 // CHECK: define noundef double @
83 // CHECK: call double @llvm.fabs.f64(
84 double test_abs_double(double p0) { return abs(p0); }
85 // CHECK: define noundef <2 x double> @
86 // CHECK: call <2 x double> @llvm.fabs.v2f64(
87 double2 test_abs_double2(double2 p0) { return abs(p0); }
88 // CHECK: define noundef <3 x double> @
89 // CHECK: call <3 x double> @llvm.fabs.v3f64(
90 double3 test_abs_double3(double3 p0) { return abs(p0); }
91 // CHECK: define noundef <4 x double> @
92 // CHECK: call <4 x double> @llvm.fabs.v4f64(
93 double4 test_abs_double4(double4 p0) { return abs(p0); }