| 1 |
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.3-library %s \ |
| 2 |
// RUN: -fnative-half-type -fnative-int16-type -emit-llvm -disable-llvm-passes -o - | \ |
| 3 |
// RUN: FileCheck %s --check-prefixes=CHECK,NATIVE_HALF |
| 4 |
// RUN: %clang_cc1 -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 |
using hlsl::abs; |
| 9 |
|
| 10 |
#ifdef __HLSL_ENABLE_16_BIT |
| 11 |
// NATIVE_HALF-LABEL: define hidden noundef i16 @_Z16test_abs_int16_t |
| 12 |
// NATIVE_HALF: call i16 @llvm.abs.i16( |
| 13 |
int16_t test_abs_int16_t(int16_t p0) { return abs(p0); } |
| 14 |
// NATIVE_HALF-LABEL: define hidden noundef <2 x i16> @_Z17test_abs_int16_t2 |
| 15 |
// NATIVE_HALF: call <2 x i16> @llvm.abs.v2i16( |
| 16 |
int16_t2 test_abs_int16_t2(int16_t2 p0) { return abs(p0); } |
| 17 |
// NATIVE_HALF-LABEL: define hidden noundef <3 x i16> @_Z17test_abs_int16_t3 |
| 18 |
// NATIVE_HALF: call <3 x i16> @llvm.abs.v3i16( |
| 19 |
int16_t3 test_abs_int16_t3(int16_t3 p0) { return abs(p0); } |
| 20 |
// NATIVE_HALF-LABEL: define hidden noundef <4 x i16> @_Z17test_abs_int16_t4 |
| 21 |
// NATIVE_HALF: call <4 x i16> @llvm.abs.v4i16( |
| 22 |
int16_t4 test_abs_int16_t4(int16_t4 p0) { return abs(p0); } |
| 23 |
|
| 24 |
// NATIVE_HALF-LABEL: define {{.*}}hlsl3abs{{.*}}(i16 |
| 25 |
// NATIVE_HALF: [[Alloca:%.*]] = alloca i16 |
| 26 |
// NATIVE_HALF-NEXT: store i16 {{%.*}}, ptr [[Alloca]] |
| 27 |
// NATIVE_HALF-NEXT: [[Val:%.*]] = load i16, ptr [[Alloca]] |
| 28 |
// NATIVE_HALF-NEXT: ret i16 [[Val]] |
| 29 |
uint16_t test_abs_uint64_t(uint16_t p0) { return abs(p0); } |
| 30 |
|
| 31 |
// NATIVE_HALF-LABEL: define {{.*}}hlsl3abs{{.*}}(<2 x i16 |
| 32 |
// NATIVE_HALF: [[Alloca:%.*]] = alloca <2 x i16> |
| 33 |
// NATIVE_HALF-NEXT: store <2 x i16> {{%.*}}, ptr [[Alloca]] |
| 34 |
// NATIVE_HALF-NEXT: [[Val:%.*]] = load <2 x i16>, ptr [[Alloca]] |
| 35 |
// NATIVE_HALF-NEXT: ret <2 x i16> [[Val]] |
| 36 |
uint16_t2 test_abs_uint64_t2(uint16_t2 p0) { return abs(p0); } |
| 37 |
|
| 38 |
// NATIVE_HALF-LABEL: define {{.*}}hlsl3abs{{.*}}(<3 x i16 |
| 39 |
// NATIVE_HALF: [[Alloca:%.*]] = alloca <3 x i16> |
| 40 |
// NATIVE_HALF-NEXT: store <3 x i16> {{%.*}}, ptr [[Alloca]] |
| 41 |
// NATIVE_HALF-NEXT: [[Val:%.*]] = load <3 x i16>, ptr [[Alloca]] |
| 42 |
// NATIVE_HALF-NEXT: ret <3 x i16> [[Val]] |
| 43 |
uint16_t3 test_abs_uint64_t3(uint16_t3 p0) { return abs(p0); } |
| 44 |
|
| 45 |
// NATIVE_HALF-LABEL: define {{.*}}hlsl3abs{{.*}}(<4 x i16 |
| 46 |
// NATIVE_HALF: [[Alloca:%.*]] = alloca <4 x i16> |
| 47 |
// NATIVE_HALF-NEXT: store <4 x i16> {{%.*}}, ptr [[Alloca]] |
| 48 |
// NATIVE_HALF-NEXT: [[Val:%.*]] = load <4 x i16>, ptr [[Alloca]] |
| 49 |
// NATIVE_HALF-NEXT: ret <4 x i16> [[Val]] |
| 50 |
uint16_t4 test_abs_uint64_t4(uint16_t4 p0) { return abs(p0); } |
| 51 |
#endif // __HLSL_ENABLE_16_BIT |
| 52 |
|
| 53 |
// NATIVE_HALF-LABEL: define hidden noundef nofpclass(nan inf) half @_Z13test_abs_half |
| 54 |
// NATIVE_HALF: call reassoc nnan ninf nsz arcp afn half @llvm.fabs.f16( |
| 55 |
// NO_HALF-LABEL: define hidden noundef nofpclass(nan inf) float @_Z13test_abs_half |
| 56 |
// NO_HALF: call reassoc nnan ninf nsz arcp afn float @llvm.fabs.f32(float %0) |
| 57 |
half test_abs_half(half p0) { return abs(p0); } |
| 58 |
// NATIVE_HALF-LABEL: define hidden noundef nofpclass(nan inf) <2 x half> @_Z14test_abs_half2 |
| 59 |
// NATIVE_HALF: call reassoc nnan ninf nsz arcp afn <2 x half> @llvm.fabs.v2f16( |
| 60 |
// NO_HALF-LABEL: define hidden noundef nofpclass(nan inf) <2 x float> @_Z14test_abs_half2 |
| 61 |
// NO_HALF: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.fabs.v2f32( |
| 62 |
half2 test_abs_half2(half2 p0) { return abs(p0); } |
| 63 |
// NATIVE_HALF-LABEL: define hidden noundef nofpclass(nan inf) <3 x half> @_Z14test_abs_half3 |
| 64 |
// NATIVE_HALF: call reassoc nnan ninf nsz arcp afn <3 x half> @llvm.fabs.v3f16( |
| 65 |
// NO_HALF-LABEL: define hidden noundef nofpclass(nan inf) <3 x float> @_Z14test_abs_half3 |
| 66 |
// NO_HALF: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.fabs.v3f32( |
| 67 |
half3 test_abs_half3(half3 p0) { return abs(p0); } |
| 68 |
// NATIVE_HALF-LABEL: define hidden noundef nofpclass(nan inf) <4 x half> @_Z14test_abs_half4 |
| 69 |
// NATIVE_HALF: call reassoc nnan ninf nsz arcp afn <4 x half> @llvm.fabs.v4f16( |
| 70 |
// NO_HALF-LABEL: define hidden noundef nofpclass(nan inf) <4 x float> @_Z14test_abs_half4 |
| 71 |
// NO_HALF: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.fabs.v4f32( |
| 72 |
half4 test_abs_half4(half4 p0) { return abs(p0); } |
| 73 |
|
| 74 |
// CHECK-LABEL: define hidden noundef i32 @_Z12test_abs_int |
| 75 |
// CHECK: call i32 @llvm.abs.i32( |
| 76 |
int test_abs_int(int p0) { return abs(p0); } |
| 77 |
// CHECK-LABEL: define hidden noundef <2 x i32> @_Z13test_abs_int2 |
| 78 |
// CHECK: call <2 x i32> @llvm.abs.v2i32( |
| 79 |
int2 test_abs_int2(int2 p0) { return abs(p0); } |
| 80 |
// CHECK-LABEL: define hidden noundef <3 x i32> @_Z13test_abs_int3 |
| 81 |
// CHECK: call <3 x i32> @llvm.abs.v3i32( |
| 82 |
int3 test_abs_int3(int3 p0) { return abs(p0); } |
| 83 |
// CHECK-LABEL: define hidden noundef <4 x i32> @_Z13test_abs_int4 |
| 84 |
// CHECK: call <4 x i32> @llvm.abs.v4i32( |
| 85 |
int4 test_abs_int4(int4 p0) { return abs(p0); } |
| 86 |
|
| 87 |
// CHECK-LABEL: define hidden noundef nofpclass(nan inf) float @_Z14test_abs_float |
| 88 |
// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.fabs.f32( |
| 89 |
float test_abs_float(float p0) { return abs(p0); } |
| 90 |
// CHECK-LABEL: define hidden noundef nofpclass(nan inf) <2 x float> @_Z15test_abs_float2 |
| 91 |
// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.fabs.v2f32( |
| 92 |
float2 test_abs_float2(float2 p0) { return abs(p0); } |
| 93 |
// CHECK-LABEL: define hidden noundef nofpclass(nan inf) <3 x float> @_Z15test_abs_float3 |
| 94 |
// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.fabs.v3f32( |
| 95 |
float3 test_abs_float3(float3 p0) { return abs(p0); } |
| 96 |
// CHECK-LABEL: define hidden noundef nofpclass(nan inf) <4 x float> @_Z15test_abs_float4 |
| 97 |
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.fabs.v4f32( |
| 98 |
float4 test_abs_float4(float4 p0) { return abs(p0); } |
| 99 |
|
| 100 |
// CHECK-LABEL: define hidden noundef i64 @_Z16test_abs_int64_t |
| 101 |
// CHECK: call i64 @llvm.abs.i64( |
| 102 |
int64_t test_abs_int64_t(int64_t p0) { return abs(p0); } |
| 103 |
// CHECK-LABEL: define hidden noundef <2 x i64> @_Z17test_abs_int64_t2 |
| 104 |
// CHECK: call <2 x i64> @llvm.abs.v2i64( |
| 105 |
int64_t2 test_abs_int64_t2(int64_t2 p0) { return abs(p0); } |
| 106 |
// CHECK-LABEL: define hidden noundef <3 x i64> @_Z17test_abs_int64_t3 |
| 107 |
// CHECK: call <3 x i64> @llvm.abs.v3i64( |
| 108 |
int64_t3 test_abs_int64_t3(int64_t3 p0) { return abs(p0); } |
| 109 |
// CHECK-LABEL: define hidden noundef <4 x i64> @_Z17test_abs_int64_t4 |
| 110 |
// CHECK: call <4 x i64> @llvm.abs.v4i64( |
| 111 |
int64_t4 test_abs_int64_t4(int64_t4 p0) { return abs(p0); } |
| 112 |
|
| 113 |
// CHECK-LABEL: define hidden noundef nofpclass(nan inf) double @_Z15test_abs_double |
| 114 |
// CHECK: call reassoc nnan ninf nsz arcp afn double @llvm.fabs.f64( |
| 115 |
double test_abs_double(double p0) { return abs(p0); } |
| 116 |
// CHECK-LABEL: define hidden noundef nofpclass(nan inf) <2 x double> @_Z16test_abs_double2 |
| 117 |
// CHECK: call reassoc nnan ninf nsz arcp afn <2 x double> @llvm.fabs.v2f64( |
| 118 |
double2 test_abs_double2(double2 p0) { return abs(p0); } |
| 119 |
// CHECK-LABEL: define hidden noundef nofpclass(nan inf) <3 x double> @_Z16test_abs_double3 |
| 120 |
// CHECK: call reassoc nnan ninf nsz arcp afn <3 x double> @llvm.fabs.v3f64( |
| 121 |
double3 test_abs_double3(double3 p0) { return abs(p0); } |
| 122 |
// CHECK-LABEL: define hidden noundef nofpclass(nan inf) <4 x double> @_Z16test_abs_double4 |
| 123 |
// CHECK: call reassoc nnan ninf nsz arcp afn <4 x double> @llvm.fabs.v4f64( |
| 124 |
double4 test_abs_double4(double4 p0) { return abs(p0); } |
| 125 |
|
| 126 |
|
| 127 |
// CHECK-LABEL: define {{.*}}hlsl3abs{{.*}}(i32 |
| 128 |
// CHECK: [[Alloca:%.*]] = alloca i32 |
| 129 |
// CHECK-NEXT: store i32 {{%.*}}, ptr [[Alloca]] |
| 130 |
// CHECK-NEXT: [[Val:%.*]] = load i32, ptr [[Alloca]] |
| 131 |
// CHECK-NEXT: ret i32 [[Val]] |
| 132 |
uint test_abs_uint(uint p0) { return abs(p0); } |
| 133 |
|
| 134 |
// CHECK-LABEL: define {{.*}}hlsl3abs{{.*}}(<2 x i32 |
| 135 |
// CHECK: [[Alloca:%.*]] = alloca <2 x i32> |
| 136 |
// CHECK-NEXT: store <2 x i32> {{%.*}}, ptr [[Alloca]] |
| 137 |
// CHECK-NEXT: [[Val:%.*]] = load <2 x i32>, ptr [[Alloca]] |
| 138 |
// CHECK-NEXT: ret <2 x i32> [[Val]] |
| 139 |
uint2 test_abs_uint2(uint2 p0) { return abs(p0); } |
| 140 |
|
| 141 |
// CHECK-LABEL: define {{.*}}hlsl3abs{{.*}}(<3 x i32 |
| 142 |
// CHECK: [[Alloca:%.*]] = alloca <3 x i32> |
| 143 |
// CHECK-NEXT: store <3 x i32> {{%.*}}, ptr [[Alloca]] |
| 144 |
// CHECK-NEXT: [[Val:%.*]] = load <3 x i32>, ptr [[Alloca]] |
| 145 |
// CHECK-NEXT: ret <3 x i32> [[Val]] |
| 146 |
uint3 test_abs_uint3(uint3 p0) { return abs(p0); } |
| 147 |
|
| 148 |
// CHECK-LABEL: define {{.*}}hlsl3abs{{.*}}(<4 x i32 |
| 149 |
// CHECK: [[Alloca:%.*]] = alloca <4 x i32> |
| 150 |
// CHECK-NEXT: store <4 x i32> {{%.*}}, ptr [[Alloca]] |
| 151 |
// CHECK-NEXT: [[Val:%.*]] = load <4 x i32>, ptr [[Alloca]] |
| 152 |
// CHECK-NEXT: ret <4 x i32> [[Val]] |
| 153 |
uint4 test_abs_uint4(uint4 p0) { return abs(p0); } |
| 154 |
|
| 155 |
// CHECK-LABEL: define {{.*}}hlsl3abs{{.*}}(i64 |
| 156 |
// CHECK: [[Alloca:%.*]] = alloca i64 |
| 157 |
// CHECK-NEXT: store i64 {{%.*}}, ptr [[Alloca]] |
| 158 |
// CHECK-NEXT: [[Val:%.*]] = load i64, ptr [[Alloca]] |
| 159 |
// CHECK-NEXT: ret i64 [[Val]] |
| 160 |
uint64_t test_abs_uint64_t(uint64_t p0) { return abs(p0); } |
| 161 |
|
| 162 |
// CHECK-LABEL: define {{.*}}hlsl3abs{{.*}}(<2 x i64 |
| 163 |
// CHECK: [[Alloca:%.*]] = alloca <2 x i64> |
| 164 |
// CHECK-NEXT: store <2 x i64> {{%.*}}, ptr [[Alloca]] |
| 165 |
// CHECK-NEXT: [[Val:%.*]] = load <2 x i64>, ptr [[Alloca]] |
| 166 |
// CHECK-NEXT: ret <2 x i64> [[Val]] |
| 167 |
uint64_t2 test_abs_uint64_t2(uint64_t2 p0) { return abs(p0); } |
| 168 |
|
| 169 |
// CHECK-LABEL: define {{.*}}hlsl3abs{{.*}}(<3 x i64 |
| 170 |
// CHECK: [[Alloca:%.*]] = alloca <3 x i64> |
| 171 |
// CHECK-NEXT: store <3 x i64> {{%.*}}, ptr [[Alloca]] |
| 172 |
// CHECK-NEXT: [[Val:%.*]] = load <3 x i64>, ptr [[Alloca]] |
| 173 |
// CHECK-NEXT: ret <3 x i64> [[Val]] |
| 174 |
uint64_t3 test_abs_uint64_t3(uint64_t3 p0) { return abs(p0); } |
| 175 |
|
| 176 |
// CHECK-LABEL: define {{.*}}hlsl3abs{{.*}}(<4 x i64 |
| 177 |
// CHECK: [[Alloca:%.*]] = alloca <4 x i64> |
| 178 |
// CHECK-NEXT: store <4 x i64> {{%.*}}, ptr [[Alloca]] |
| 179 |
// CHECK-NEXT: [[Val:%.*]] = load <4 x i64>, ptr [[Alloca]] |
| 180 |
// CHECK-NEXT: ret <4 x i64> [[Val]] |
| 181 |
uint64_t4 test_abs_uint64_t4(uint64_t4 p0) { return abs(p0); } |