Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
//
//===----------------------------------------------------------------------===//

#define __CLC_FUNCTION __clc_tan
#ifndef __CLC_MATH_CLC_TAN_H__
#define __CLC_MATH_CLC_TAN_H__

#define __CLC_BODY <clc/math/unary_decl.inc>
#define __CLC_FUNCTION __clc_tan

#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION

#endif // __CLC_MATH_CLC_TAN_H__
1 change: 1 addition & 0 deletions libclc/clc/lib/generic/SOURCES
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ math/clc_sinpi.cl
math/clc_sqrt.cl
math/clc_sw_fma.cl
math/clc_tables.cl
math/clc_tan.cl
math/clc_tanh.cl
math/clc_tanpi.cl
math/clc_tgamma.cl
Expand Down
2 changes: 1 addition & 1 deletion libclc/clc/lib/generic/math/clc_sincos_helpers.inc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ _CLC_DECL _CLC_OVERLOAD __CLC_FLOATN __clc_tanf_piby4(__CLC_FLOATN x,
__CLC_FLOATN t = __clc_mad(x * r, __clc_native_divide(a, b), x);
__CLC_FLOATN tr = -MATH_RECIP(t);

return regn & 1 ? tr : t;
return (regn & 1) != 0 ? tr : t;
}

_CLC_DEF _CLC_OVERLOAD void __clc_fullMulS(private __CLC_FLOATN *hi,
Expand Down
22 changes: 22 additions & 0 deletions libclc/clc/lib/generic/math/clc_tan.cl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include <clc/clc_convert.h>
#include <clc/float/definitions.h>
#include <clc/internal/clc.h>
#include <clc/math/clc_fabs.h>
#include <clc/math/clc_sincos_helpers.h>
#include <clc/math/clc_sincos_piby4.h>
#include <clc/math/math.h>
#include <clc/math/tables.h>
#include <clc/relational/clc_isinf.h>
#include <clc/relational/clc_isnan.h>
#include <clc/relational/clc_select.h>

#define __CLC_BODY <clc_tan.inc>
#include <clc/math/gentype.inc>
61 changes: 61 additions & 0 deletions libclc/clc/lib/generic/math/clc_tan.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#if __CLC_FPSIZE == 32

_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_tan(__CLC_GENTYPE x) {
__CLC_GENTYPE absx = __clc_fabs(x);
__CLC_UINTN x_signbit = __CLC_AS_UINTN(x) & SIGNBIT_SP32;

__CLC_GENTYPE r0, r1;
__CLC_INTN regn = __clc_argReductionS(&r0, &r1, absx);

__CLC_GENTYPE t = __clc_tanf_piby4(r0 + r1, regn);
t = __CLC_AS_GENTYPE(__CLC_AS_UINTN(t) ^ x_signbit);

t = __clc_select(t, __CLC_GENTYPE_NAN, __clc_isnan(x) || __clc_isinf(x));
// Take care of subnormals
t = (x == 0.0f) ? x : t;
return t;
}

#elif __CLC_FPSIZE == 64

_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_tan(__CLC_GENTYPE x) {
__CLC_GENTYPE y = __clc_fabs(x);

__CLC_BIT_INTN is_medium = y < 0x1.0p+30;

__CLC_INTN regn_m, regn_l;
__CLC_GENTYPE r_m, r_l, rr_m, rr_l;

__clc_remainder_piby2_medium(y, &r_m, &rr_m, &regn_m);
__clc_remainder_piby2_large(y, &r_l, &rr_l, &regn_l);

__CLC_GENTYPE r = is_medium ? r_m : r_l;
__CLC_GENTYPE rr = is_medium ? rr_m : rr_l;
__CLC_INTN regn = __CLC_CONVERT_INTN(is_medium) ? regn_m : regn_l;

__CLC_GENTYPE lead, tail;
__clc_tan_piby4(r, rr, &lead, &tail);

__CLC_LONGN t =
__CLC_AS_LONGN(__CLC_CONVERT_BIT_INTN((regn & 1) != 0) ? tail : lead);
t ^= __CLC_CONVERT_BIT_INTN(x < 0.0) << 63;

return __clc_isnan(x) || __clc_isinf(x) ? __CLC_GENTYPE_NAN
: __CLC_AS_GENTYPE(t);
}

#elif __CLC_FPSIZE == 16

_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_tan(__CLC_GENTYPE x) {
return __CLC_CONVERT_GENTYPE(__clc_tan(__CLC_CONVERT_FLOATN(x)));
}

#endif
1 change: 0 additions & 1 deletion libclc/clspv/lib/SOURCES
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ subnormal_config.cl
../../generic/lib/math/atanh.cl
../../generic/lib/math/atanpi.cl
../../generic/lib/math/cbrt.cl
../../generic/lib/math/clc_tan.cl
../../generic/lib/math/cos.cl
../../generic/lib/math/cosh.cl
../../generic/lib/math/cospi.cl
Expand Down
1 change: 0 additions & 1 deletion libclc/generic/lib/SOURCES
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ math/sincos.cl
math/sinh.cl
math/sinpi.cl
math/sqrt.cl
math/clc_tan.cl
math/tan.cl
math/tanh.cl
math/tanpi.cl
Expand Down
30 changes: 0 additions & 30 deletions libclc/generic/lib/math/clc_sw_unary.inc

This file was deleted.

61 changes: 0 additions & 61 deletions libclc/generic/lib/math/clc_tan.cl

This file was deleted.

7 changes: 3 additions & 4 deletions libclc/generic/lib/math/tan.cl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
//===----------------------------------------------------------------------===//

#include <clc/clc.h>
#include <clc/math/clc_tan.h>

#include <math/clc_tan.h>

#define __CLC_FUNC tan
#define __CLC_BODY <clc_sw_unary.inc>
#define FUNCTION tan
#define __CLC_BODY <clc/shared/unary_def.inc>
#include <clc/math/gentype.inc>
1 change: 0 additions & 1 deletion libclc/spirv/lib/SOURCES
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ math/fma.cl
../../generic/lib/math/sincos.cl
../../generic/lib/math/sinh.cl
../../generic/lib/math/sinpi.cl
../../generic/lib/math/clc_tan.cl
../../generic/lib/math/tan.cl
../../generic/lib/math/tanh.cl
../../generic/lib/math/tanpi.cl
Expand Down
Loading