[Clang/AMDGPU] Zero sized arrays not allowed in HIP device code. (#113470)
[llvm-project.git] / libclc / amdgcn / lib / math / fmin.cl
blob4d02a47babdabbfb07a090928e5d790686e65174
1 #include <clc/clc.h>
2 #include <clc/clcmacro.h>
4 _CLC_DEF _CLC_OVERLOAD float fmin(float x, float y)
6 /* fcanonicalize removes sNaNs and flushes denormals if not enabled.
7 * Otherwise fmin instruction flushes the values for comparison,
8 * but outputs original denormal */
9 x = __builtin_canonicalizef(x);
10 y = __builtin_canonicalizef(y);
11 return __builtin_fminf(x, y);
13 _CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, fmin, float, float)
15 #ifdef cl_khr_fp64
17 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
19 _CLC_DEF _CLC_OVERLOAD double fmin(double x, double y)
21 x = __builtin_canonicalize(x);
22 y = __builtin_canonicalize(y);
23 return __builtin_fmin(x, y);
25 _CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, fmin, double, double)
27 #endif
28 #ifdef cl_khr_fp16
30 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
32 _CLC_DEF _CLC_OVERLOAD half fmin(half x, half y)
34 if (isnan(x))
35 return y;
36 if (isnan(y))
37 return x;
38 return (y < x) ? y : x;
40 _CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, fmin, half, half)
42 #endif
44 #define __CLC_BODY <../../../generic/lib/math/fmin.inc>
45 #include <clc/math/gentype.inc>