| 1 |
// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -triple dxil-pc-shadermodel6.3-library %s \ |
| 2 |
// RUN: -fnative-half-type -fnative-int16-type -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,NATIVE_HALF |
| 3 |
// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -triple dxil-pc-shadermodel6.3-library %s \ |
| 4 |
// RUN: -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF |
| 5 |
|
| 6 |
#ifdef __HLSL_ENABLE_16_BIT |
| 7 |
// NATIVE_HALF-LABEL: define hidden noundef <4 x i16> {{.*}}test_max_short4_mismatch |
| 8 |
// NATIVE_HALF: [[CONV0:%.*]] = insertelement <4 x i16> poison, i16 %{{.*}}, i64 0 |
| 9 |
// NATIVE_HALF: [[CONV1:%.*]] = shufflevector <4 x i16> [[CONV0]], <4 x i16> poison, <4 x i32> zeroinitializer |
| 10 |
// NATIVE_HALF: [[MAX:%.*]] = call noundef <4 x i16> @llvm.smax.v4i16(<4 x i16> %{{.*}}, <4 x i16> [[CONV1]]) |
| 11 |
// NATIVE_HALF: ret <4 x i16> [[MAX]] |
| 12 |
int16_t4 test_max_short4_mismatch(int16_t4 p0, int16_t p1) { return max(p0, p1); } |
| 13 |
|
| 14 |
// NATIVE_HALF-LABEL: define hidden noundef <4 x i16> {{.*}}test_max_ushort4_mismatch |
| 15 |
// NATIVE_HALF: [[CONV0:%.*]] = insertelement <4 x i16> poison, i16 %{{.*}}, i64 0 |
| 16 |
// NATIVE_HALF: [[CONV1:%.*]] = shufflevector <4 x i16> [[CONV0]], <4 x i16> poison, <4 x i32> zeroinitializer |
| 17 |
// NATIVE_HALF: [[MAX:%.*]] = call noundef <4 x i16> @llvm.umax.v4i16(<4 x i16> %{{.*}}, <4 x i16> [[CONV1]]) |
| 18 |
// NATIVE_HALF: ret <4 x i16> [[MAX]] |
| 19 |
uint16_t4 test_max_ushort4_mismatch(uint16_t4 p0, uint16_t p1) { return max(p0, p1); } |
| 20 |
#endif |
| 21 |
|
| 22 |
// CHECK-LABEL: define hidden noundef <4 x i32> {{.*}}test_max_int4_mismatch |
| 23 |
// CHECK: [[CONV0:%.*]] = insertelement <4 x i32> poison, i32 %{{.*}}, i64 0 |
| 24 |
// CHECK: [[CONV1:%.*]] = shufflevector <4 x i32> [[CONV0]], <4 x i32> poison, <4 x i32> zeroinitializer |
| 25 |
// CHECK: [[MAX:%.*]] = call noundef <4 x i32> @llvm.smax.v4i32(<4 x i32> %{{.*}}, <4 x i32> [[CONV1]]) |
| 26 |
// CHECK: ret <4 x i32> [[MAX]] |
| 27 |
int4 test_max_int4_mismatch(int4 p0, int p1) { return max(p0, p1); } |
| 28 |
|
| 29 |
// CHECK-LABEL: define hidden noundef <4 x i32> {{.*}}test_max_uint4_mismatch |
| 30 |
// CHECK: [[CONV0:%.*]] = insertelement <4 x i32> poison, i32 %{{.*}}, i64 0 |
| 31 |
// CHECK: [[CONV1:%.*]] = shufflevector <4 x i32> [[CONV0]], <4 x i32> poison, <4 x i32> zeroinitializer |
| 32 |
// CHECK: [[MAX:%.*]] = call noundef <4 x i32> @llvm.umax.v4i32(<4 x i32> %{{.*}}, <4 x i32> [[CONV1]]) |
| 33 |
// CHECK: ret <4 x i32> [[MAX]] |
| 34 |
uint4 test_max_uint4_mismatch(uint4 p0, uint p1) { return max(p0, p1); } |
| 35 |
|
| 36 |
// CHECK-LABEL: define hidden noundef <4 x i64> {{.*}}test_max_long4_mismatch |
| 37 |
// CHECK: [[CONV0:%.*]] = insertelement <4 x i64> poison, i64 %{{.*}}, i64 0 |
| 38 |
// CHECK: [[CONV1:%.*]] = shufflevector <4 x i64> [[CONV0]], <4 x i64> poison, <4 x i32> zeroinitializer |
| 39 |
// CHECK: [[MAX:%.*]] = call noundef <4 x i64> @llvm.smax.v4i64(<4 x i64> %{{.*}}, <4 x i64> [[CONV1]]) |
| 40 |
// CHECK: ret <4 x i64> [[MAX]] |
| 41 |
int64_t4 test_max_long4_mismatch(int64_t4 p0, int64_t p1) { return max(p0, p1); } |
| 42 |
|
| 43 |
// CHECK-LABEL: define hidden noundef <4 x i64> {{.*}}test_max_ulong4_mismatch |
| 44 |
// CHECK: [[CONV0:%.*]] = insertelement <4 x i64> poison, i64 %{{.*}}, i64 0 |
| 45 |
// CHECK: [[CONV1:%.*]] = shufflevector <4 x i64> [[CONV0]], <4 x i64> poison, <4 x i32> zeroinitializer |
| 46 |
// CHECK: [[MAX:%.*]] = call noundef <4 x i64> @llvm.umax.v4i64(<4 x i64> %{{.*}}, <4 x i64> [[CONV1]]) |
| 47 |
// CHECK: ret <4 x i64> [[MAX]] |
| 48 |
uint64_t4 test_max_ulong4_mismatch(uint64_t4 p0, uint64_t p1) { return max(p0, p1); } |
| 49 |
|
| 50 |
// NATIVE_HALF-LABEL: define hidden noundef nofpclass(nan inf) <4 x half> {{.*}}test_max_half4_mismatch |
| 51 |
// NATIVE_HALF: [[CONV0:%.*]] = insertelement <4 x half> poison, half %{{.*}}, i64 0 |
| 52 |
// NATIVE_HALF: [[CONV1:%.*]] = shufflevector <4 x half> [[CONV0]], <4 x half> poison, <4 x i32> zeroinitializer |
| 53 |
// NATIVE_HALF: [[MAX:%.*]] = call reassoc nnan ninf nsz arcp afn noundef <4 x half> @llvm.maxnum.v4f16(<4 x half> %{{.*}}, <4 x half> [[CONV1]]) |
| 54 |
// NATIVE_HALF: ret <4 x half> [[MAX]] |
| 55 |
// NO_HALF-LABEL: define hidden noundef nofpclass(nan inf) <4 x float> {{.*}}test_max_half4_mismatch |
| 56 |
// NO_HALF: [[CONV0:%.*]] = insertelement <4 x float> poison, float %{{.*}}, i64 0 |
| 57 |
// NO_HALF: [[CONV1:%.*]] = shufflevector <4 x float> [[CONV0]], <4 x float> poison, <4 x i32> zeroinitializer |
| 58 |
// NO_HALF: [[MAX:%.*]] = call reassoc nnan ninf nsz arcp afn noundef <4 x float> @llvm.maxnum.v4f32(<4 x float> %{{.*}}, <4 x float> [[CONV1]]) |
| 59 |
// NO_HALF: ret <4 x float> [[MAX]] |
| 60 |
half4 test_max_half4_mismatch(half4 p0, half p1) { return max(p0, p1); } |
| 61 |
|
| 62 |
// CHECK-LABEL: define hidden noundef nofpclass(nan inf) <4 x float> {{.*}}test_max_float4_mismatch |
| 63 |
// CHECK: [[CONV0:%.*]] = insertelement <4 x float> poison, float %{{.*}}, i64 0 |
| 64 |
// CHECK: [[CONV1:%.*]] = shufflevector <4 x float> [[CONV0]], <4 x float> poison, <4 x i32> zeroinitializer |
| 65 |
// CHECK: [[MAX:%.*]] = call reassoc nnan ninf nsz arcp afn noundef <4 x float> @llvm.maxnum.v4f32(<4 x float> %{{.*}}, <4 x float> [[CONV1]]) |
| 66 |
// CHECK: ret <4 x float> [[MAX]] |
| 67 |
float4 test_max_float4_mismatch(float4 p0, float p1) { return max(p0, p1); } |
| 68 |
|
| 69 |
// CHECK-LABEL: define hidden noundef nofpclass(nan inf) <4 x double> {{.*}}test_max_double4_mismatch |
| 70 |
// CHECK: [[CONV0:%.*]] = insertelement <4 x double> poison, double %{{.*}}, i64 0 |
| 71 |
// CHECK: [[CONV1:%.*]] = shufflevector <4 x double> [[CONV0]], <4 x double> poison, <4 x i32> zeroinitializer |
| 72 |
// CHECK: [[MAX:%.*]] = call reassoc nnan ninf nsz arcp afn noundef <4 x double> @llvm.maxnum.v4f64(<4 x double> %{{.*}}, <4 x double> [[CONV1]]) |
| 73 |
// CHECK: ret <4 x double> [[MAX]] |
| 74 |
double4 test_max_double4_mismatch(double4 p0, double p1) { return max(p0, p1); } |
| 75 |
|
| 76 |
// CHECK-LABEL: define hidden noundef nofpclass(nan inf) <4 x double> {{.*}}test_max_double4_mismatch2 |
| 77 |
// CHECK: [[CONV0:%.*]] = insertelement <4 x double> poison, double %{{.*}}, i64 0 |
| 78 |
// CHECK: [[CONV1:%.*]] = shufflevector <4 x double> [[CONV0]], <4 x double> poison, <4 x i32> zeroinitializer |
| 79 |
// CHECK: [[MAX:%.*]] = call reassoc nnan ninf nsz arcp afn noundef <4 x double> @llvm.maxnum.v4f64(<4 x double> [[CONV1]], <4 x double> %{{.*}}) |
| 80 |
// CHECK: ret <4 x double> [[MAX]] |
| 81 |
double4 test_max_double4_mismatch2(double4 p0, double p1) { return max(p1, p0); } |