Files
clang-p2996/libclc/generic/lib/math/tan.inc
Aaron Watry 947bdd059a math: Add tan implementation
Uses the algorithm:
tan(x) = sin(x) / sqrt(1-sin^2(x))

An alternative is:
tan(x) = sin(x) / cos(x)

Which produces more verbose bitcode and longer assembly.

Either way, the generated bitcode seems pretty nasty and a more optimized
but still precise-enough solution is welcome.

Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 217511
2014-09-10 15:43:35 +00:00

9 lines
294 B
C++

/*
* Note: tan(x) = sin(x)/cos(x) also, but the final assembly ends up being
* twice as long for R600 (maybe for others as well).
*/
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE tan(__CLC_GENTYPE x) {
__CLC_GENTYPE sinx = sin(x);
return sinx / sqrt( (__CLC_GENTYPE) 1.0 - (sinx*sinx) );
}