Skip to content

Commit 09d5ec9

Browse files
committed
max
1 parent 823bde1 commit 09d5ec9

File tree

2 files changed

+50
-32
lines changed

2 files changed

+50
-32
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -triple dxil-pc-shadermodel6.3-library %s \
2+
// RUN: -fnative-half-type -emit-llvm -disable-llvm-passes -o - | \
3+
// RUN: FileCheck %s --check-prefixes=CHECK,NATIVE_HALF
4+
// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -triple dxil-pc-shadermodel6.3-library %s \
5+
// RUN: -emit-llvm -disable-llvm-passes -o - | \
6+
// RUN: FileCheck %s --check-prefixes=CHECK,NO_HALF
7+
8+
#ifdef __HLSL_ENABLE_16_BIT
9+
// NATIVE_HALF-LABEL: define noundef <4 x i16> {{.*}}test_max_short4_mismatch
10+
// NATIVE_HALF: call <4 x i16> @llvm.smax.v4i16
11+
int16_t4 test_max_short4_mismatch(int16_t4 p0, int16_t p1) { return max(p0, p1); }
12+
13+
// NATIVE_HALF-LABEL: define noundef <4 x i16> {{.*}}test_max_ushort4_mismatch
14+
// NATIVE_HALF: call <4 x i16> @llvm.umax.v4i16
15+
uint16_t4 test_max_ushort4_mismatch(uint16_t4 p0, uint16_t p1) { return max(p0, p1); }
16+
#endif
17+
18+
// CHECK-LABEL: define noundef <4 x i32> {{.*}}test_max_int4_mismatch
19+
// CHECK: call <4 x i32> @llvm.smax.v4i32
20+
int4 test_max_int4_mismatch(int4 p0, int p1) { return max(p0, p1); }
21+
22+
// CHECK-LABEL: define noundef <4 x i32> {{.*}}test_max_uint4_mismatch
23+
// CHECK: call <4 x i32> @llvm.umax.v4i32
24+
uint4 test_max_uint4_mismatch(uint4 p0, uint p1) { return max(p0, p1); }
25+
26+
// CHECK-LABEL: define noundef <4 x i64> {{.*}}test_max_long4_mismatch
27+
// CHECK: call <4 x i64> @llvm.smax.v4i64
28+
int64_t4 test_max_long4_mismatch(int64_t4 p0, int64_t p1) { return max(p0, p1); }
29+
30+
// CHECK-LABEL: define noundef <4 x i64> {{.*}}test_max_ulong4_mismatch
31+
// CHECK: call <4 x i64> @llvm.umax.v4i64
32+
uint64_t4 test_max_ulong4_mismatch(uint64_t4 p0, uint64_t p1) { return max(p0, p1); }
33+
34+
// NATIVE_HALF-LABEL: define noundef nofpclass(nan inf) <4 x half> {{.*}}test_max_half4_mismatch
35+
// NATIVE_HALF: call reassoc nnan ninf nsz arcp afn <4 x half> @llvm.maxnum.v4f16
36+
// NO_HALF-LABEL: define noundef nofpclass(nan inf) <4 x float> {{.*}}test_max_half4_mismatch
37+
// NO_HALF: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.maxnum.v4f32(
38+
half4 test_max_half4_mismatch(half4 p0, half p1) { return max(p0, p1); }
39+
40+
// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> {{.*}}test_max_float4_mismatch
41+
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.maxnum.v4f32
42+
float4 test_max_float4_mismatch(float4 p0, float p1) { return max(p0, p1); }
43+
44+
// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x double> {{.*}}test_max_double4_mismatch
45+
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x double> @llvm.maxnum.v4f64
46+
double4 test_max_double4_mismatch(double4 p0, double p1) { return max(p0, p1); }
47+
48+
// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x double> {{.*}}test_max_double4_mismatch2
49+
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x double> @llvm.maxnum.v4f64
50+
double4 test_max_double4_mismatch2(double4 p0, double p1) { return max(p1, p0); }

clang/test/CodeGenHLSL/builtins/max.hlsl

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ int16_t3 test_max_short3(int16_t3 p0, int16_t3 p1) { return max(p0, p1); }
1818
// NATIVE_HALF-LABEL: define noundef <4 x i16> @_Z15test_max_short4
1919
// NATIVE_HALF: call <4 x i16> @llvm.smax.v4i16
2020
int16_t4 test_max_short4(int16_t4 p0, int16_t4 p1) { return max(p0, p1); }
21-
// NATIVE_HALF-LABEL: define noundef <4 x i16> {{.*}}test_max_short4_mismatch
22-
// NATIVE_HALF: call <4 x i16> @llvm.smax.v4i16
23-
int16_t4 test_max_short4_mismatch(int16_t4 p0, int16_t p1) { return max(p0, p1); }
2421

2522
// NATIVE_HALF-LABEL: define noundef i16 @_Z15test_max_ushort
2623
// NATIVE_HALF: call i16 @llvm.umax.i16(
@@ -34,9 +31,6 @@ uint16_t3 test_max_ushort3(uint16_t3 p0, uint16_t3 p1) { return max(p0, p1); }
3431
// NATIVE_HALF-LABEL: define noundef <4 x i16> @_Z16test_max_ushort4
3532
// NATIVE_HALF: call <4 x i16> @llvm.umax.v4i16
3633
uint16_t4 test_max_ushort4(uint16_t4 p0, uint16_t4 p1) { return max(p0, p1); }
37-
// NATIVE_HALF-LABEL: define noundef <4 x i16> {{.*}}test_max_ushort4_mismatch
38-
// NATIVE_HALF: call <4 x i16> @llvm.umax.v4i16
39-
uint16_t4 test_max_ushort4_mismatch(uint16_t4 p0, uint16_t p1) { return max(p0, p1); }
4034
#endif
4135

4236
// CHECK-LABEL: define noundef i32 @_Z12test_max_int
@@ -51,9 +45,6 @@ int3 test_max_int3(int3 p0, int3 p1) { return max(p0, p1); }
5145
// CHECK-LABEL: define noundef <4 x i32> @_Z13test_max_int4
5246
// CHECK: call <4 x i32> @llvm.smax.v4i32
5347
int4 test_max_int4(int4 p0, int4 p1) { return max(p0, p1); }
54-
// CHECK-LABEL: define noundef <4 x i32> {{.*}}test_max_int4_mismatch
55-
// CHECK: call <4 x i32> @llvm.smax.v4i32
56-
int4 test_max_int4_mismatch(int4 p0, int p1) { return max(p0, p1); }
5748

5849
// CHECK-LABEL: define noundef i32 @_Z13test_max_uint
5950
// CHECK: call i32 @llvm.umax.i32(
@@ -67,9 +58,6 @@ uint3 test_max_uint3(uint3 p0, uint3 p1) { return max(p0, p1); }
6758
// CHECK-LABEL: define noundef <4 x i32> @_Z14test_max_uint4
6859
// CHECK: call <4 x i32> @llvm.umax.v4i32
6960
uint4 test_max_uint4(uint4 p0, uint4 p1) { return max(p0, p1); }
70-
// CHECK-LABEL: define noundef <4 x i32> {{.*}}test_max_uint4_mismatch
71-
// CHECK: call <4 x i32> @llvm.umax.v4i32
72-
uint4 test_max_uint4_mismatch(uint4 p0, uint p1) { return max(p0, p1); }
7361

7462
// CHECK-LABEL: define noundef i64 @_Z13test_max_long
7563
// CHECK: call i64 @llvm.smax.i64(
@@ -83,9 +71,6 @@ int64_t3 test_max_long3(int64_t3 p0, int64_t3 p1) { return max(p0, p1); }
8371
// CHECK-LABEL: define noundef <4 x i64> @_Z14test_max_long4
8472
// CHECK: call <4 x i64> @llvm.smax.v4i64
8573
int64_t4 test_max_long4(int64_t4 p0, int64_t4 p1) { return max(p0, p1); }
86-
// CHECK-LABEL: define noundef <4 x i64> {{.*}}test_max_long4_mismatch
87-
// CHECK: call <4 x i64> @llvm.smax.v4i64
88-
int64_t4 test_max_long4_mismatch(int64_t4 p0, int64_t p1) { return max(p0, p1); }
8974

9075
// CHECK-LABEL: define noundef i64 @_Z14test_max_ulong
9176
// CHECK: call i64 @llvm.umax.i64(
@@ -99,9 +84,6 @@ uint64_t3 test_max_ulong3(uint64_t3 p0, uint64_t3 p1) { return max(p0, p1); }
9984
// CHECK-LABEL: define noundef <4 x i64> @_Z15test_max_ulong4
10085
// CHECK: call <4 x i64> @llvm.umax.v4i64
10186
uint64_t4 test_max_ulong4(uint64_t4 p0, uint64_t4 p1) { return max(p0, p1); }
102-
// CHECK-LABEL: define noundef <4 x i64> {{.*}}test_max_ulong4_mismatch
103-
// CHECK: call <4 x i64> @llvm.umax.v4i64
104-
uint64_t4 test_max_ulong4_mismatch(uint64_t4 p0, uint64_t p1) { return max(p0, p1); }
10587

10688
// NATIVE_HALF-LABEL: define noundef nofpclass(nan inf) half @_Z13test_max_half
10789
// NATIVE_HALF: call reassoc nnan ninf nsz arcp afn half @llvm.maxnum.f16(
@@ -123,11 +105,6 @@ half3 test_max_half3(half3 p0, half3 p1) { return max(p0, p1); }
123105
// NO_HALF-LABEL: define noundef nofpclass(nan inf) <4 x float> @_Z14test_max_half4
124106
// NO_HALF: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.maxnum.v4f32(
125107
half4 test_max_half4(half4 p0, half4 p1) { return max(p0, p1); }
126-
// NATIVE_HALF-LABEL: define noundef nofpclass(nan inf) <4 x half> {{.*}}test_max_half4_mismatch
127-
// NATIVE_HALF: call reassoc nnan ninf nsz arcp afn <4 x half> @llvm.maxnum.v4f16
128-
// NO_HALF-LABEL: define noundef nofpclass(nan inf) <4 x float> {{.*}}test_max_half4_mismatch
129-
// NO_HALF: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.maxnum.v4f32(
130-
half4 test_max_half4_mismatch(half4 p0, half p1) { return max(p0, p1); }
131108

132109
// CHECK-LABEL: define noundef nofpclass(nan inf) float @_Z14test_max_float
133110
// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.maxnum.f32(
@@ -141,9 +118,6 @@ float3 test_max_float3(float3 p0, float3 p1) { return max(p0, p1); }
141118
// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> @_Z15test_max_float4
142119
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.maxnum.v4f32
143120
float4 test_max_float4(float4 p0, float4 p1) { return max(p0, p1); }
144-
// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> {{.*}}test_max_float4_mismatch
145-
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.maxnum.v4f32
146-
float4 test_max_float4_mismatch(float4 p0, float p1) { return max(p0, p1); }
147121

148122
// CHECK-LABEL: define noundef nofpclass(nan inf) double @_Z15test_max_double
149123
// CHECK: call reassoc nnan ninf nsz arcp afn double @llvm.maxnum.f64(
@@ -157,9 +131,3 @@ double3 test_max_double3(double3 p0, double3 p1) { return max(p0, p1); }
157131
// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x double> @_Z16test_max_double4
158132
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x double> @llvm.maxnum.v4f64
159133
double4 test_max_double4(double4 p0, double4 p1) { return max(p0, p1); }
160-
// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x double> {{.*}}test_max_double4_mismatch
161-
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x double> @llvm.maxnum.v4f64
162-
double4 test_max_double4_mismatch(double4 p0, double p1) { return max(p0, p1); }
163-
// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x double> {{.*}}test_max_double4_mismatch2
164-
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x double> @llvm.maxnum.v4f64
165-
double4 test_max_double4_mismatch2(double4 p0, double p1) { return max(p1, p0); }

0 commit comments

Comments
 (0)