Debian Codegraph @

clang/test/CodeGenHLSL/builtins/max.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 #ifdef __HLSL_ENABLE_16_BIT
10 // NATIVE_HALF: define noundef i16 @
11 // NATIVE_HALF: call i16 @llvm.smax.i16(
12 int16_t test_max_short(int16_t p0, int16_t p1) { return max(p0, p1); }
13 // NATIVE_HALF: define noundef <2 x i16> @
14 // NATIVE_HALF: call <2 x i16> @llvm.smax.v2i16(
15 int16_t2 test_max_short2(int16_t2 p0, int16_t2 p1) { return max(p0, p1); }
16 // NATIVE_HALF: define noundef <3 x i16> @
17 // NATIVE_HALF: call <3 x i16> @llvm.smax.v3i16
18 int16_t3 test_max_short3(int16_t3 p0, int16_t3 p1) { return max(p0, p1); }
19 // NATIVE_HALF: define noundef <4 x i16> @
20 // NATIVE_HALF: call <4 x i16> @llvm.smax.v4i16
21 int16_t4 test_max_short4(int16_t4 p0, int16_t4 p1) { return max(p0, p1); }
22
23 // NATIVE_HALF: define noundef i16 @
24 // NATIVE_HALF: call i16 @llvm.umax.i16(
25 uint16_t test_max_ushort(uint16_t p0, uint16_t p1) { return max(p0, p1); }
26 // NATIVE_HALF: define noundef <2 x i16> @
27 // NATIVE_HALF: call <2 x i16> @llvm.umax.v2i16
28 uint16_t2 test_max_ushort2(uint16_t2 p0, uint16_t2 p1) { return max(p0, p1); }
29 // NATIVE_HALF: define noundef <3 x i16> @
30 // NATIVE_HALF: call <3 x i16> @llvm.umax.v3i16
31 uint16_t3 test_max_ushort3(uint16_t3 p0, uint16_t3 p1) { return max(p0, p1); }
32 // NATIVE_HALF: define noundef <4 x i16> @
33 // NATIVE_HALF: call <4 x i16> @llvm.umax.v4i16
34 uint16_t4 test_max_ushort4(uint16_t4 p0, uint16_t4 p1) { return max(p0, p1); }
35 #endif
36
37 // CHECK: define noundef i32 @
38 // CHECK: call i32 @llvm.smax.i32(
39 int test_max_int(int p0, int p1) { return max(p0, p1); }
40 // CHECK: define noundef <2 x i32> @
41 // CHECK: call <2 x i32> @llvm.smax.v2i32
42 int2 test_max_int2(int2 p0, int2 p1) { return max(p0, p1); }
43 // CHECK: define noundef <3 x i32> @
44 // CHECK: call <3 x i32> @llvm.smax.v3i32
45 int3 test_max_int3(int3 p0, int3 p1) { return max(p0, p1); }
46 // CHECK: define noundef <4 x i32> @
47 // CHECK: call <4 x i32> @llvm.smax.v4i32
48 int4 test_max_int4(int4 p0, int4 p1) { return max(p0, p1); }
49
50 // CHECK: define noundef i32 @
51 // CHECK: call i32 @llvm.umax.i32(
52 int test_max_uint(uint p0, uint p1) { return max(p0, p1); }
53 // CHECK: define noundef <2 x i32> @
54 // CHECK: call <2 x i32> @llvm.umax.v2i32
55 uint2 test_max_uint2(uint2 p0, uint2 p1) { return max(p0, p1); }
56 // CHECK: define noundef <3 x i32> @
57 // CHECK: call <3 x i32> @llvm.umax.v3i32
58 uint3 test_max_uint3(uint3 p0, uint3 p1) { return max(p0, p1); }
59 // CHECK: define noundef <4 x i32> @
60 // CHECK: call <4 x i32> @llvm.umax.v4i32
61 uint4 test_max_uint4(uint4 p0, uint4 p1) { return max(p0, p1); }
62
63 // CHECK: define noundef i64 @
64 // CHECK: call i64 @llvm.smax.i64(
65 int64_t test_max_long(int64_t p0, int64_t p1) { return max(p0, p1); }
66 // CHECK: define noundef <2 x i64> @
67 // CHECK: call <2 x i64> @llvm.smax.v2i64
68 int64_t2 test_max_long2(int64_t2 p0, int64_t2 p1) { return max(p0, p1); }
69 // CHECK: define noundef <3 x i64> @
70 // CHECK: call <3 x i64> @llvm.smax.v3i64
71 int64_t3 test_max_long3(int64_t3 p0, int64_t3 p1) { return max(p0, p1); }
72 // CHECK: define noundef <4 x i64> @
73 // CHECK: call <4 x i64> @llvm.smax.v4i64
74 int64_t4 test_max_long4(int64_t4 p0, int64_t4 p1) { return max(p0, p1); }
75
76 // CHECK: define noundef i64 @
77 // CHECK: call i64 @llvm.umax.i64(
78 uint64_t test_max_long(uint64_t p0, uint64_t p1) { return max(p0, p1); }
79 // CHECK: define noundef <2 x i64> @
80 // CHECK: call <2 x i64> @llvm.umax.v2i64
81 uint64_t2 test_max_long2(uint64_t2 p0, uint64_t2 p1) { return max(p0, p1); }
82 // CHECK: define noundef <3 x i64> @
83 // CHECK: call <3 x i64> @llvm.umax.v3i64
84 uint64_t3 test_max_long3(uint64_t3 p0, uint64_t3 p1) { return max(p0, p1); }
85 // CHECK: define noundef <4 x i64> @
86 // CHECK: call <4 x i64> @llvm.umax.v4i64
87 uint64_t4 test_max_long4(uint64_t4 p0, uint64_t4 p1) { return max(p0, p1); }
88
89 // NATIVE_HALF: define noundef half @
90 // NATIVE_HALF: call half @llvm.maxnum.f16(
91 // NO_HALF: define noundef float @"?test_max_half
92 // NO_HALF: call float @llvm.maxnum.f32(
93 half test_max_half(half p0, half p1) { return max(p0, p1); }
94 // NATIVE_HALF: define noundef <2 x half> @
95 // NATIVE_HALF: call <2 x half> @llvm.maxnum.v2f16
96 // NO_HALF: define noundef <2 x float> @"?test_max_half2
97 // NO_HALF: call <2 x float> @llvm.maxnum.v2f32(
98 half2 test_max_half2(half2 p0, half2 p1) { return max(p0, p1); }
99 // NATIVE_HALF: define noundef <3 x half> @
100 // NATIVE_HALF: call <3 x half> @llvm.maxnum.v3f16
101 // NO_HALF: define noundef <3 x float> @"?test_max_half3
102 // NO_HALF: call <3 x float> @llvm.maxnum.v3f32(
103 half3 test_max_half3(half3 p0, half3 p1) { return max(p0, p1); }
104 // NATIVE_HALF: define noundef <4 x half> @
105 // NATIVE_HALF: call <4 x half> @llvm.maxnum.v4f16
106 // NO_HALF: define noundef <4 x float> @"?test_max_half4
107 // NO_HALF: call <4 x float> @llvm.maxnum.v4f32(
108 half4 test_max_half4(half4 p0, half4 p1) { return max(p0, p1); }
109
110 // CHECK: define noundef float @"?test_max_float
111 // CHECK: call float @llvm.maxnum.f32(
112 float test_max_float(float p0, float p1) { return max(p0, p1); }
113 // CHECK: define noundef <2 x float> @"?test_max_float2
114 // CHECK: call <2 x float> @llvm.maxnum.v2f32
115 float2 test_max_float2(float2 p0, float2 p1) { return max(p0, p1); }
116 // CHECK: define noundef <3 x float> @"?test_max_float3
117 // CHECK: call <3 x float> @llvm.maxnum.v3f32
118 float3 test_max_float3(float3 p0, float3 p1) { return max(p0, p1); }
119 // CHECK: define noundef <4 x float> @"?test_max_float4
120 // CHECK: call <4 x float> @llvm.maxnum.v4f32
121 float4 test_max_float4(float4 p0, float4 p1) { return max(p0, p1); }
122
123 // CHECK: define noundef double @
124 // CHECK: call double @llvm.maxnum.f64(
125 double test_max_double(double p0, double p1) { return max(p0, p1); }
126 // CHECK: define noundef <2 x double> @
127 // CHECK: call <2 x double> @llvm.maxnum.v2f64
128 double2 test_max_double2(double2 p0, double2 p1) { return max(p0, p1); }
129 // CHECK: define noundef <3 x double> @
130 // CHECK: call <3 x double> @llvm.maxnum.v3f64
131 double3 test_max_double3(double3 p0, double3 p1) { return max(p0, p1); }
132 // CHECK: define noundef <4 x double> @
133 // CHECK: call <4 x double> @llvm.maxnum.v4f64
134 double4 test_max_double4(double4 p0, double4 p1) { return max(p0, p1); }