[libclc] r237155 - Implement sin for double types
Tom Stellard
thomas.stellard at amd.com
Tue May 12 10:18:48 PDT 2015
Author: tstellar
Date: Tue May 12 12:18:47 2015
New Revision: 237155
URL: http://llvm.org/viewvc/llvm-project?rev=237155&view=rev
Log:
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.
Modified:
libclc/trunk/generic/lib/math/sin.cl
Modified: libclc/trunk/generic/lib/math/sin.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/sin.cl?rev=237155&r1=237154&r2=237155&view=diff
==============================================================================
--- libclc/trunk/generic/lib/math/sin.cl (original)
+++ libclc/trunk/generic/lib/math/sin.cl Tue May 12 12:18:47 2015
@@ -55,14 +55,23 @@ _CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_
#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, ®n);
+ else
+ __clc_remainder_piby2_large(y, &r, &rr, ®n);
+
+ 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);
More information about the cfe-commits
mailing list