summaryrefslogtreecommitdiffstats
path: root/libclc/generic
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2015-05-12 17:18:47 +0000
committerTom Stellard <thomas.stellard@amd.com>2015-05-12 17:18:47 +0000
commit429454129038d2c65866fc383bf9ac6e3787c48b (patch)
tree8ab9a3eb4193ac693403461e851aad00f9b47c82 /libclc/generic
parent2e6ff0c66e180998425776a27579559dc099732f (diff)
downloadbcm5719-llvm-429454129038d2c65866fc383bf9ac6e3787c48b.tar.gz
bcm5719-llvm-429454129038d2c65866fc383bf9ac6e3787c48b.zip
Implement sin for double types
This implementation was ported from the AMD builtin library and has been tested with piglit, OpenCV, and the ocl conformance tests. llvm-svn: 237155
Diffstat (limited to 'libclc/generic')
-rw-r--r--libclc/generic/lib/math/sin.cl23
1 files changed, 16 insertions, 7 deletions
diff --git a/libclc/generic/lib/math/sin.cl b/libclc/generic/lib/math/sin.cl
index 50684e4b849..3a4074925b8 100644
--- a/libclc/generic/lib/math/sin.cl
+++ b/libclc/generic/lib/math/sin.cl
@@ -55,14 +55,23 @@ _CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, sin, float);
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
-#define __CLC_FUNCTION __clc_sin_intrinsic
-#define __CLC_INTRINSIC "llvm.sin"
-#include <clc/math/unary_intrin.inc>
-#undef __CLC_FUNCTION
-#undef __CLC_INTRINSIC
-
_CLC_OVERLOAD _CLC_DEF double sin(double x) {
- return __clc_sin_intrinsic(x);
+ double y = fabs(x);
+
+ double r, rr;
+ int regn;
+
+ if (y < 0x1.0p+47)
+ __clc_remainder_piby2_medium(y, &r, &rr, &regn);
+ else
+ __clc_remainder_piby2_large(y, &r, &rr, &regn);
+
+ double2 sc = __clc_sincos_piby4(r, rr);
+
+ int2 s = as_int2(regn & 1 ? sc.hi : sc.lo);
+ s.hi ^= ((regn > 1) << 31) ^ ((x < 0.0) << 31);
+
+ return isinf(x) | isnan(x) ? as_double(QNANBITPATT_DP64) : as_double(s);
}
_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, sin, double);
OpenPOWER on IntegriCloud