about summary refs log tree commit diff
path: root/sysdeps/ia64/fpu/s_tan.S
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-01-06 11:32:24 +0000
committerUlrich Drepper <drepper@redhat.com>2005-01-06 11:32:24 +0000
commitbb803bff5cb97b3de94896aba1c4ec0d67227524 (patch)
treefd7dc0ee4cdec5b9846bad73448537efc718f151 /sysdeps/ia64/fpu/s_tan.S
parentef07fd10d992d6af9657dbbd58b2465828bec516 (diff)
downloadglibc-bb803bff5cb97b3de94896aba1c4ec0d67227524.tar.gz
glibc-bb803bff5cb97b3de94896aba1c4ec0d67227524.tar.xz
glibc-bb803bff5cb97b3de94896aba1c4ec0d67227524.zip
2004-12-29  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/ia64/fpu/libm_support.h (__libm_error_support): Use
	libc_hidden_proto instead of HIDDEN_PROTO.
	* sysdeps/ia64/fpu/libm-symbols.h (HIDDEN_PROTO): Remove.
	(__libm_error_support): If ASSEMBLER and in libc, define to
	HIDDEN_JUMPTARGET(__libm_error_support).

2004-12-28  David Mosberger  <davidm@hpl.hp.com>

	* sysdeps/ia64/fpu/Makefile (duplicated-routines): New macro.
	(sysdep_routines): Replace libm_ldexp{,f,l} and libm_scalbn{,f,l}
	with $(duplicated-routines).
	(libm-sysdep_routines): Likewise, but substitute "s_" prefix for
	"m_" prefix.

2004-12-27  David Mosberger  <davidm@hpl.hp.com>

	* sysdeps/ia64/fpu/libm-symbols.h: Add include of <sysdep.h> and
	undefine "ret" macro.  Add __libm_error_support hidden definitions.

	* sysdeps/ia64/fpu/e_lgamma_r.c: Remove CVS-id comment.  Add
	missing portion of copyright statement.
	* sysdeps/ia64/fpu/e_lgammaf_r.c: Likewise.
	* sysdeps/ia64/fpu/e_lgammal_r.c: Likewise.

	* sysdeps/ia64/fpu/w_lgamma.c: Remove CVS-id comment.  Add
	missing portion of copyright statement.
	(__ieee754_lgamma): Rename from lgamma().  Make lgamma() a weak alias.
	(__ieee754_gamma): Likewise.
	* sysdeps/ia64/fpu/w_lgammaf.c: Likewise.
	* sysdeps/ia64/fpu/w_lgammal.c: Likewise.

2004-12-09  H. J. Lu <hjl@lucon.org>

	* sysdeps/ia64/fpu/s_nextafterl.c: Remove.
	* sysdeps/ia64/fpu/s_nexttoward.c: Likewise.
	* sysdeps/ia64/fpu/s_nexttowardf.c: Likewise.
	* sysdeps/ia64/fpu/e_atan2l.S: Remove (duplicate of e_atan2l.c).
	* sysdeps/ia64/fpu/e_expl.S: Likewise.
	* sysdeps/ia64/fpu/e_logl.c: Remove (conflicts with e_logl.S).

2004-11-18  David Mosberger  <davidm@hpl.hp.com>

	* sysdeps/ia64/fpu/README: New file.
	* sysdeps/ia64/fpu/gen_import_file_list: New file.
	* sysdeps/ia64/fpu/import_check: Likewise.
	* sysdeps/ia64/fpu/import_diffs: Likewise.
	* sysdeps/ia64/fpu/import_file.awk: Likewise.
	* sysdeps/ia64/fpu/import_intel_libm: Likewise.
	* sysdeps/ia64/fpu/libm-symbols.h: Likewise.

	* sysdeps/ia64/fpu/e_acos.S: Update from Intel libm v2.1+.
	* sysdeps/ia64/fpu/e_acosf.S: Likewise.
	* sysdeps/ia64/fpu/e_acosl.S: Likewise.
	* sysdeps/ia64/fpu/e_asin.S: Likewise.
	* sysdeps/ia64/fpu/e_asinf.S: Likewise.
	* sysdeps/ia64/fpu/e_asinl.S: Likewise.
	* sysdeps/ia64/fpu/e_atan2.S: Likewise.
	* sysdeps/ia64/fpu/e_atan2f.S: Likewise.
	* sysdeps/ia64/fpu/e_cosh.S: Likewise.
	* sysdeps/ia64/fpu/e_coshf.S: Likewise.
	* sysdeps/ia64/fpu/e_coshl.S: Likewise.
	* sysdeps/ia64/fpu/e_exp.S: Likewise.
	* sysdeps/ia64/fpu/e_expf.S: Likewise.
	* sysdeps/ia64/fpu/e_fmod.S: Likewise.
	* sysdeps/ia64/fpu/e_fmodf.S: Likewise.
	* sysdeps/ia64/fpu/e_fmodl.S: Likewise.
	* sysdeps/ia64/fpu/e_hypot.S: Likewise.
	* sysdeps/ia64/fpu/e_hypotf.S: Likewise.
	* sysdeps/ia64/fpu/e_hypotl.S: Likewise.
	* sysdeps/ia64/fpu/e_log.S: Likewise.
	* sysdeps/ia64/fpu/e_log2.S: Likewise.
	* sysdeps/ia64/fpu/e_log2f.S: Likewise.
	* sysdeps/ia64/fpu/e_log2l.S: Likewise.
	* sysdeps/ia64/fpu/e_logf.S: Likewise.
	* sysdeps/ia64/fpu/e_pow.S: Likewise.
	* sysdeps/ia64/fpu/e_powf.S: Likewise.
	* sysdeps/ia64/fpu/e_powl.S: Likewise.
	* sysdeps/ia64/fpu/e_remainder.S: Likewise.
	* sysdeps/ia64/fpu/e_remainderf.S: Likewise.
	* sysdeps/ia64/fpu/e_remainderl.S: Likewise.
	* sysdeps/ia64/fpu/e_scalb.S: Likewise.
	* sysdeps/ia64/fpu/e_scalbf.S: Likewise.
	* sysdeps/ia64/fpu/e_scalbl.S: Likewise.
	* sysdeps/ia64/fpu/e_sinh.S: Likewise.
	* sysdeps/ia64/fpu/e_sinhf.S: Likewise.
	* sysdeps/ia64/fpu/e_sinhl.S: Likewise.
	* sysdeps/ia64/fpu/e_sqrt.S: Likewise.
	* sysdeps/ia64/fpu/e_sqrtf.S: Likewise.
	* sysdeps/ia64/fpu/e_sqrtl.S: Likewise.
	* sysdeps/ia64/fpu/libm_error.c: Likewise.
	* sysdeps/ia64/fpu/libm_reduce.c: Likewise.
	* sysdeps/ia64/fpu/libm_support.h: Likewise.
	* sysdeps/ia64/fpu/s_atan.S: Likewise.
	* sysdeps/ia64/fpu/s_atanf.S: Likewise.
	* sysdeps/ia64/fpu/s_atanl.S: Likewise.
	* sysdeps/ia64/fpu/s_cbrt.S: Likewise.
	* sysdeps/ia64/fpu/s_cbrtf.S: Likewise.
	* sysdeps/ia64/fpu/s_cbrtl.S: Likewise.
	* sysdeps/ia64/fpu/s_ceil.S: Likewise.
	* sysdeps/ia64/fpu/s_ceilf.S: Likewise.
	* sysdeps/ia64/fpu/s_ceill.S: Likewise.
	* sysdeps/ia64/fpu/s_cos.S: Likewise.
	* sysdeps/ia64/fpu/s_cosf.S: Likewise.
	* sysdeps/ia64/fpu/s_cosl.S: Likewise.
	* sysdeps/ia64/fpu/s_expm1.S: Likewise.
	* sysdeps/ia64/fpu/s_expm1f.S: Likewise.
	* sysdeps/ia64/fpu/s_expm1l.S: Likewise.
	* sysdeps/ia64/fpu/s_fabs.S: Likewise.
	* sysdeps/ia64/fpu/s_fabsf.S: Likewise.
	* sysdeps/ia64/fpu/s_fabsl.S: Likewise.
	* sysdeps/ia64/fpu/s_floor.S: Likewise.
	* sysdeps/ia64/fpu/s_floorf.S: Likewise.
	* sysdeps/ia64/fpu/s_floorl.S: Likewise.
	* sysdeps/ia64/fpu/s_frexp.c: Likewise.
	* sysdeps/ia64/fpu/s_frexpf.c: Likewise.
	* sysdeps/ia64/fpu/s_frexpl.c: Likewise.
	* sysdeps/ia64/fpu/s_ilogb.S: Likewise.
	* sysdeps/ia64/fpu/s_ilogbf.S: Likewise.
	* sysdeps/ia64/fpu/s_ilogbl.S: Likewise.
	* sysdeps/ia64/fpu/s_log1p.S: Likewise.
	* sysdeps/ia64/fpu/s_log1pf.S: Likewise.
	* sysdeps/ia64/fpu/s_log1pl.S: Likewise.
	* sysdeps/ia64/fpu/s_logb.S: Likewise.
	* sysdeps/ia64/fpu/s_logbf.S: Likewise.
	* sysdeps/ia64/fpu/s_logbl.S: Likewise.
	* sysdeps/ia64/fpu/s_modf.S: Likewise.
	* sysdeps/ia64/fpu/s_modff.S: Likewise.
	* sysdeps/ia64/fpu/s_modfl.S: Likewise.
	* sysdeps/ia64/fpu/s_nearbyint.S: Likewise.
	* sysdeps/ia64/fpu/s_nearbyintf.S: Likewise.
	* sysdeps/ia64/fpu/s_nearbyintl.S: Likewise.
	* sysdeps/ia64/fpu/s_rint.S: Likewise.
	* sysdeps/ia64/fpu/s_rintf.S: Likewise.
	* sysdeps/ia64/fpu/s_rintl.S: Likewise.
	* sysdeps/ia64/fpu/s_round.S: Likewise.
	* sysdeps/ia64/fpu/s_roundf.S: Likewise.
	* sysdeps/ia64/fpu/s_roundl.S: Likewise.
	* sysdeps/ia64/fpu/s_significand.S: Likewise.
	* sysdeps/ia64/fpu/s_significandf.S: Likewise.
	* sysdeps/ia64/fpu/s_significandl.S: Likewise.
	* sysdeps/ia64/fpu/s_tan.S: Likewise.
	* sysdeps/ia64/fpu/s_tanf.S: Likewise.
	* sysdeps/ia64/fpu/s_tanl.S: Likewise.
	* sysdeps/ia64/fpu/s_trunc.S: Likewise.
	* sysdeps/ia64/fpu/s_truncf.S: Likewise.
	* sysdeps/ia64/fpu/s_truncl.S: Likewise.

	* sysdeps/ia64/fpu/e_acosh.S: New file from Intel libm v2.1+.
	* sysdeps/ia64/fpu/e_acoshf.S: Likewise.
	* sysdeps/ia64/fpu/e_acoshl.S: Likewise.
	* sysdeps/ia64/fpu/e_atanh.S: Likewise.
	* sysdeps/ia64/fpu/e_atanhf.S: Likewise.
	* sysdeps/ia64/fpu/e_atanhl.S: Likewise.
	* sysdeps/ia64/fpu/e_exp10.S: Likewise.
	* sysdeps/ia64/fpu/e_exp10f.S: Likewise.
	* sysdeps/ia64/fpu/e_exp10l.S: Likewise.
	* sysdeps/ia64/fpu/e_exp2.S: Likewise.
	* sysdeps/ia64/fpu/e_exp2f.S: Likewise.
	* sysdeps/ia64/fpu/e_exp2l.S: Likewise.
	* sysdeps/ia64/fpu/e_lgamma_r.S: Likewise.
	* sysdeps/ia64/fpu/e_lgammaf_r.S: Likewise.
	* sysdeps/ia64/fpu/e_lgammal_r.S: Likewise.
	* sysdeps/ia64/fpu/e_logl.S: Likewise.
	* sysdeps/ia64/fpu/libm_frexp.S: Likewise.
	* sysdeps/ia64/fpu/libm_frexpf.S: Likewise.
	* sysdeps/ia64/fpu/libm_frexpl.S: Likewise.
	* sysdeps/ia64/fpu/s_libm_ldexp.S: Likewise.
	* sysdeps/ia64/fpu/s_libm_ldexpf.S: Likewise.
	* sysdeps/ia64/fpu/s_libm_ldexpl.S: Likewise.
	* sysdeps/ia64/fpu/s_libm_scalbn.S: Likewise.
	* sysdeps/ia64/fpu/s_libm_scalbnf.S: Likewise.
	* sysdeps/ia64/fpu/s_libm_scalbnl.S: Likewise.
	* sysdeps/ia64/fpu/libm_lgamma.S: Likewise.
	* sysdeps/ia64/fpu/libm_lgammaf.S: Likewise.
	* sysdeps/ia64/fpu/libm_lgammal.S: Likewise.
	* sysdeps/ia64/fpu/libm_sincos.S: Likewise.
	* sysdeps/ia64/fpu/libm_sincos_large.S: Likewise.
	* sysdeps/ia64/fpu/libm_sincosf.S: Likewise.
	* sysdeps/ia64/fpu/libm_sincosl.S: Likewise.
	* sysdeps/ia64/fpu/libm_scalblnf.S: Likewise.
	* sysdeps/ia64/fpu/s_asinh.S: Likewise.
	* sysdeps/ia64/fpu/s_asinhf.S: Likewise.
	* sysdeps/ia64/fpu/s_asinhl.S: Likewise.
	* sysdeps/ia64/fpu/s_erf.S: Likewise.
	* sysdeps/ia64/fpu/s_erfc.S: Likewise.
	* sysdeps/ia64/fpu/s_erfcf.S: Likewise.
	* sysdeps/ia64/fpu/s_erfcl.S: Likewise.
	* sysdeps/ia64/fpu/s_erff.S: Likewise.
	* sysdeps/ia64/fpu/s_erfl.S: Likewise.
	* sysdeps/ia64/fpu/s_fdim.S: Likewise.
	* sysdeps/ia64/fpu/s_fdimf.S: Likewise.
	* sysdeps/ia64/fpu/s_fdiml.S: Likewise.
	* sysdeps/ia64/fpu/s_fma.S: Likewise.
	* sysdeps/ia64/fpu/s_fmaf.S: Likewise.
	* sysdeps/ia64/fpu/s_fmal.S: Likewise.
	* sysdeps/ia64/fpu/s_fmax.S: Likewise.
	* sysdeps/ia64/fpu/s_fmaxf.S: Likewise.
	* sysdeps/ia64/fpu/s_fmaxl.S: Likewise.
	* sysdeps/ia64/fpu/s_ldexp.c: Likewise.
	* sysdeps/ia64/fpu/s_ldexpf.c: Likewise.
	* sysdeps/ia64/fpu/s_ldexpl.c: Likewise.
	* sysdeps/ia64/fpu/s_nextafter.S: Likewise.
	* sysdeps/ia64/fpu/s_nextafterf.S: Likewise.
	* sysdeps/ia64/fpu/s_nextafterl.S: Likewise.
	* sysdeps/ia64/fpu/s_nexttoward.S: Likewise.
	* sysdeps/ia64/fpu/s_nexttowardf.S: Likewise.
	* sysdeps/ia64/fpu/s_nexttowardl.S: Likewise.
	* sysdeps/ia64/fpu/s_tanh.S: Likewise.
	* sysdeps/ia64/fpu/s_tanhf.S: Likewise.
	* sysdeps/ia64/fpu/s_tanhl.S: Likewise.
	* sysdeps/ia64/fpu/s_scalblnf.c: Likewise.
	* sysdeps/ia64/fpu/w_lgamma.c: Likewise.
	* sysdeps/ia64/fpu/w_lgammaf.c: Likewise.
	* sysdeps/ia64/fpu/w_lgammal.c: Likewise.
	* sysdeps/ia64/fpu/w_tgamma.S: Likewise.
	* sysdeps/ia64/fpu/w_tgammaf.S: Likewise.
	* sysdeps/ia64/fpu/w_tgammal.S: Likewise.

	* sysdeps/ia64/fpu/e_gamma_r.c: New empty dummy-file.
	* sysdeps/ia64/fpu/e_gammaf_r.c: Likewise.
	* sysdeps/ia64/fpu/e_gammal_r.c: Likewise.
	* sysdeps/ia64/fpu/w_acosh.c: Likewise.
	* sysdeps/ia64/fpu/w_acoshf.c: Likewise.
	* sysdeps/ia64/fpu/w_acoshl.c: Likewise.
	* sysdeps/ia64/fpu/w_atanh.c: Likewise.
	* sysdeps/ia64/fpu/w_atanhf.c: Likewise.
	* sysdeps/ia64/fpu/w_atanhl.c: Likewise.
	* sysdeps/ia64/fpu/w_exp10.c: Likewise.
	* sysdeps/ia64/fpu/w_exp10f.c: Likewise.
	* sysdeps/ia64/fpu/w_exp10l.c: Likewise.
	* sysdeps/ia64/fpu/w_exp2.c: Likewise.
	* sysdeps/ia64/fpu/w_exp2f.c: Likewise.
	* sysdeps/ia64/fpu/w_exp2l.c: Likewise.
	* sysdeps/ia64/fpu/w_expl.c: Likewise.
	* sysdeps/ia64/fpu/e_expl.S: Likewise.
	* sysdeps/ia64/fpu/w_lgamma_r.c: Likewise.
	* sysdeps/ia64/fpu/w_lgammaf_r.c: Likewise.
	* sysdeps/ia64/fpu/w_lgammal_r.c: Likewise.
	* sysdeps/ia64/fpu/w_log2.c: Likewise.
	* sysdeps/ia64/fpu/w_log2f.c: Likewise.
	* sysdeps/ia64/fpu/w_log2l.c: Likewise.
	* sysdeps/ia64/fpu/w_sinh.c: Likewise.
	* sysdeps/ia64/fpu/w_sinhf.c: Likewise.
	* sysdeps/ia64/fpu/w_sinhl.c: Likewise.

	* sysdeps/ia64/fpu/libm_atan2_reg.S: Remove.
	* sysdeps/ia64/fpu/s_ldexp.S: Likewise.
	* sysdeps/ia64/fpu/s_ldexpf.S: Likewise.
	* sysdeps/ia64/fpu/s_ldexpl.S: Likewise.
	* sysdeps/ia64/fpu/s_scalbn.S: Likewise.
	* sysdeps/ia64/fpu/s_scalbnf.S: Likewise.
	* sysdeps/ia64/fpu/s_scalbnl.S: Likewise.

	* sysdeps/ia64/fpu/s_sincos.c: Make it an empty dummy-file.
	* sysdeps/ia64/fpu/s_sincosf.c: Likewise.
	* sysdeps/ia64/fpu/s_sincosl.c: Likewise.

	* sysdeps/ia64/fpu/e_atan2l.S: Add "Not needed" comment.

	* sysdeps/ia64/fpu/s_copysign.S: Add __libm_copysign{,f,l}
	alias for use by libm_error.c

	* sysdeps/ia64/fpu/Makefile (libm-sysdep_routines): Remove
	libm_atan2_reg, libm_tan, libm_frexp4{f,l}.
	Mention s_erfc{,f,l}, libm_frexp{,f,l}, libm_ldexp{,f,l},
	libm_sincos{,f,l}, libm_sincos_large, libm_lgamma{,f,l},
	libm_scalbn{,f,l}, libm_scalblnf.
	(sysdep_routines): Remove libm_frexp4{,f,l}.
	Mention libm_frexp{,f,l}, libm_ldexp{,f,l}, and libm_scalbn{,f,l}.
	(sysdep-CPPFLAGS): Add -include libm-symbols.h, -D__POSIX__,
	_D_LIB_VERSIONIMF=_LIB_VERSION, -DSIZE_LONG_INT_64, and
	-DSIZE_LONG_LONG_INT_64.
Diffstat (limited to 'sysdeps/ia64/fpu/s_tan.S')
-rw-r--r--sysdeps/ia64/fpu/s_tan.S554
1 files changed, 330 insertions, 224 deletions
diff --git a/sysdeps/ia64/fpu/s_tan.S b/sysdeps/ia64/fpu/s_tan.S
index 3a497fcf4c..3000f5ee06 100644
--- a/sysdeps/ia64/fpu/s_tan.S
+++ b/sysdeps/ia64/fpu/s_tan.S
@@ -1,10 +1,10 @@
-.file "tan.s"
+.file "tancot.s"
 
-// Copyright (C) 2000, 2001, Intel Corporation
+
+// Copyright (c) 2000 - 2003, Intel Corporation
 // All rights reserved.
-// 
-// Contributed 2/2/2000 by John Harrison, Ted Kubaska, Bob Norin, Shane Story,
-// and Ping Tak Peter Tang of the Computational Software Lab, Intel Corporation.
+//
+// Contributed 2000 by the Intel Numerics Group, Intel Corporation
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -20,7 +20,7 @@
 // * The name of Intel Corporation may not be used to endorse or promote
 // products derived from this software without specific prior written
 // permission.
-//
+
 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -32,20 +32,24 @@
 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING
 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
-// 
+//
 // Intel Corporation is the author of this code, and requests that all
 // problem reports or change requests be submitted to it directly at 
-// http://developer.intel.com/opensource.
+// http://www.intel.com/software/products/opensource/libraries/num.htm.
 //
 // History
 //==============================================================
-// 2/02/00: Initial version
-// 4/04/00  Unwind support added
+// 02/02/00 Initial version
+// 04/04/00 Unwind support added
 // 12/27/00 Improved speed
+// 02/21/01 Updated to call tanl
+// 05/30/02 Added cot
+// 02/10/03 Reordered header: .section, .global, .proc, .align
 //
 // API
 //==============================================================
-// double tan( double x);
+// double tan(double x);
+// double cot(double x);
 //
 // Overview of operation
 //==============================================================
@@ -61,11 +65,14 @@
 //     Nfloat = round_int(tan_W)
 //
 //     tan_r  = x - Nfloat * (pi/2)_hi
-//     tan_r  = tan_r - Nfloat * (pi/2)_lo
+//  a) tan_r  = tan_r - Nfloat * (pi/2)_lo (for tan)
+//  b) tan_r  = Nfloat * (pi/2)_lo - tan_r (for cot)
 //
 // We have two paths: p8, when Nfloat is even and p9. when Nfloat is odd.
-// p8: tan(X) =  tan(r)
-// p9: tan(X) = -cot(r)
+//  a) for tan:  p8: tan(X) =  tan(r)
+//               p9: tan(X) = -cot(r)
+//  b) for cot:  p9: cot(X) =  cot(r)
+//               p8: cot(X) = -tan(r)
 //
 // Each is evaluated as a series. The p9 path requires 1/r.
 //
@@ -75,19 +82,16 @@
 // Registers used
 //==============================================================
 //
-// predicate registers used:  
-// p6-10
+// predicate registers used:
+// p6-12
 //
-// floating-point registers used:  
-// f10-15, f32-105
+// floating-point registers used:
+// f10-15, f32-106
 // f8, input
 //
 // general registers used
-// r14-18, r32-43
+// r14-26, r32-39
 //
-
-#include "libm_support.h"
-
 // Assembly macros
 //==============================================================
 TAN_INV_PI_BY_2_2TO64        = f10
@@ -105,28 +109,28 @@ tan_Pi_by_2_lo               = f34
 tan_P0                       = f35
 tan_P1                       = f36
 tan_P2                       = f37
-tan_P3                       = f38 
-tan_P4                       = f39 
-tan_P5                       = f40 
+tan_P3                       = f38
+tan_P4                       = f39
+tan_P5                       = f40
 tan_P6                       = f41
 tan_P7                       = f42
-tan_P8                       = f43 
-tan_P9                       = f44 
-tan_P10                      = f45 
+tan_P8                       = f43
+tan_P9                       = f44
+tan_P10                      = f45
 tan_P11                      = f46
-tan_P12                      = f47 
+tan_P12                      = f47
 tan_P13                      = f48
 tan_P14                      = f49
 tan_P15                      = f50
 
-tan_Q0                       = f51 
-tan_Q1                       = f52 
-tan_Q2                       = f53 
-tan_Q3                       = f54 
-tan_Q4                       = f55 
-tan_Q5                       = f56 
-tan_Q6                       = f57 
-tan_Q7                       = f58 
+tan_Q0                       = f51
+tan_Q1                       = f52
+tan_Q2                       = f53
+tan_Q3                       = f54
+tan_Q4                       = f55
+tan_Q5                       = f56
+tan_Q6                       = f57
+tan_Q7                       = f58
 tan_Q8                       = f59
 tan_Q9                       = f60
 tan_Q10                      = f61
@@ -153,19 +157,19 @@ tan_v10                      = f79
 tan_v2                       = f80
 tan_v9                       = f81
 tan_v1                       = f82
-tan_int_Nfloat               = f83 
-tan_Nfloat                   = f84 
+tan_int_Nfloat               = f83
+tan_Nfloat                   = f84
 
-tan_NORM_f8                  = f85 
+tan_NORM_f8                  = f85
 tan_W                        = f86
 
 tan_y0                       = f87
-tan_d                        = f88 
-tan_y1                       = f89 
-tan_dsq                      = f90 
-tan_y2                       = f91 
-tan_d4                       = f92 
-tan_inv_r                    = f93 
+tan_d                        = f88
+tan_y1                       = f89
+tan_dsq                      = f90
+tan_y2                       = f91
+tan_d4                       = f92
+tan_inv_r                    = f93
 
 tan_z1                       = f94
 tan_z2                       = f95
@@ -180,6 +184,7 @@ tan_z10                      = f103
 tan_z11                      = f104
 tan_z12                      = f105
 
+arg_copy                     = f106
 
 /////////////////////////////////////////////////////////////
 
@@ -188,37 +193,33 @@ tan_GR_rshf_2to64            = r15
 tan_GR_exp_2tom64            = r16
 tan_GR_n                     = r17
 tan_GR_rshf                  = r18
-
-tan_AD                       = r33
-tan_GR_10009                 = r34 
-tan_GR_17_ones               = r35 
-tan_GR_N_odd_even            = r36 
-tan_GR_N                     = r37 
-tan_signexp                  = r38
-tan_exp                      = r39
-tan_ADQ                      = r40
-
-GR_SAVE_PFS                  = r41 
-GR_SAVE_B0                   = r42       
-GR_SAVE_GP                   = r43      
-
-
-#ifdef _LIBC
-.rodata
-#else
-.data
-#endif
+tan_AD                       = r19
+tan_GR_10009                 = r20
+tan_GR_17_ones               = r21
+tan_GR_N_odd_even            = r22
+tan_GR_N                     = r23
+tan_signexp                  = r24
+tan_exp                      = r25
+tan_ADQ                      = r26
+
+GR_SAVE_B0                   = r33
+GR_SAVE_PFS                  = r34
+GR_SAVE_GP                   = r35
+GR_Parameter_X               = r36
+GR_Parameter_Y               = r37
+GR_Parameter_RESULT          = r38
+GR_Parameter_Tag             = r39
+
+
+RODATA
 
 .align 16
 
-double_tan_constants:
-ASM_TYPE_DIRECTIVE(double_tan_constants,@object)
-//   data8 0xA2F9836E4E44152A, 0x00003FFE // 2/pi
+LOCAL_OBJECT_START(double_tan_constants)
    data8 0xC90FDAA22168C234, 0x00003FFF // pi/2 hi
-
-   data8 0xBEEA54580DDEA0E1 // P14 
+   data8 0xBEEA54580DDEA0E1 // P14
    data8 0x3ED3021ACE749A59 // P15
-   data8 0xBEF312BD91DC8DA1 // P12 
+   data8 0xBEF312BD91DC8DA1 // P12
    data8 0x3EFAE9AFC14C5119 // P13
    data8 0x3F2F342BF411E769 // P8
    data8 0x3F1A60FC9F3B0227 // P9
@@ -232,10 +233,9 @@ ASM_TYPE_DIRECTIVE(double_tan_constants,@object)
    data8 0x3FC11111111111C2 // P1
    data8 0x3FABA1BA1BA0E850 // P2
    data8 0x3F9664F4886725A7 // P3
-ASM_SIZE_DIRECTIVE(double_tan_constants)
+LOCAL_OBJECT_END(double_tan_constants)
 
-double_Q_tan_constants:
-ASM_TYPE_DIRECTIVE(double_Q_tan_constants,@object)
+LOCAL_OBJECT_START(double_Q_tan_constants)
    data8 0xC4C6628B80DC1CD1, 0x00003FBF // pi/2 lo
    data8 0x3E223A73BA576E48 // Q8
    data8 0x3DF54AD8D1F2CA43 // Q9
@@ -248,35 +248,19 @@ ASM_TYPE_DIRECTIVE(double_Q_tan_constants,@object)
    data8 0x3F61566ABBFFB489 // Q2
    data8 0x3F2BBD77945C1733 // Q3
    data8 0x3D927FB33E2B0E04 // Q10
-ASM_SIZE_DIRECTIVE(double_Q_tan_constants)
+LOCAL_OBJECT_END(double_Q_tan_constants)
 
 
-   
-.align 32
-.global tan#
-#ifdef _LIBC
-.global __tan#
-#endif
+.section .text
 
 ////////////////////////////////////////////////////////
 
-
-
-.section .text
-.proc  tan#
-#ifdef _LIBC
-.proc  __tan#
-#endif
-.align 32
-tan: 
-#ifdef _LIBC
-__tan: 
-#endif
+LOCAL_LIBM_ENTRY(cot)
 // The initial fnorm will take any unmasked faults and
 // normalize any single/double unorms
 
 { .mlx
-      alloc          r32=ar.pfs,1,11,0,0               
+      cmp.eq    p12, p11 = r0, r0 // set p12=1, p11=0 for cot
       movl tan_GR_sig_inv_pi_by_2 = 0xA2F9836E4E44152A // significand of 2/pi
 }
 { .mlx
@@ -285,18 +269,47 @@ __tan:
 }
 ;;
 
-{ .mfi
-      ld8 tan_AD = [tan_AD]
-      fnorm     tan_NORM_f8  = f8                      
+{ .mlx
       mov tan_GR_exp_2tom64 = 0xffff-64 // exponent of scaling factor 2^-64
+      movl tan_GR_rshf = 0x43e8000000000000 // 1.1000 2^63 for right shift
 }
+{ .mfb
+      ld8 tan_AD = [tan_AD]
+      fnorm.s0  tan_NORM_f8  = f8
+      br.cond.sptk COMMON_PATH
+}
+;;
+
+LOCAL_LIBM_END(cot)
+
+GLOBAL_IEEE754_ENTRY(tan)
+// The initial fnorm will take any unmasked faults and
+// normalize any single/double unorms
+
 { .mlx
-      nop.m 999
+      cmp.eq    p11, p12 = r0, r0 // set p11=1, p12=0 for tan
+      movl tan_GR_sig_inv_pi_by_2 = 0xA2F9836E4E44152A // significand of 2/pi
+}
+{ .mlx
+      addl           tan_AD   = @ltoff(double_tan_constants), gp
+      movl tan_GR_rshf_2to64 = 0x47e8000000000000 // 1.1000 2^(63+63+1)
+}
+;;
+
+{ .mlx
+      mov tan_GR_exp_2tom64 = 0xffff-64 // exponent of scaling factor 2^-64
       movl tan_GR_rshf = 0x43e8000000000000 // 1.1000 2^63 for right shift
 }
+{ .mfi
+      ld8 tan_AD = [tan_AD]
+      fnorm.s0  tan_NORM_f8  = f8
+      nop.i     0
+}
 ;;
 
 
+// Common path for both tan and cot
+COMMON_PATH:
 // Form two constants we need
 //   2/pi * 2^1 * 2^63, scaled by 2^64 since we just loaded the significand
 //   1.1000...000 * 2^(63+63+1) to right shift int(W) into the significand
@@ -313,7 +326,7 @@ __tan:
 { .mmf
       setf.exp TAN_2TOM64 = tan_GR_exp_2tom64
       adds tan_ADQ = double_Q_tan_constants - double_tan_constants, tan_AD
-      fclass.m.unc  p6,p0 = f8, 0x07  // Test for x=0
+(p11) fclass.m.unc  p6,p0 = f8, 0x07  // Test for x=0 (tan)
 }
 ;;
 
@@ -323,79 +336,79 @@ __tan:
 //   1.1000...000 * 2^63, the right shift constant
 { .mmf
       setf.d TAN_RSHF = tan_GR_rshf
-      ldfe      tan_Pi_by_2_hi = [tan_AD],16 
+      ldfe      tan_Pi_by_2_hi = [tan_AD],16
       fclass.m.unc  p7,p0 = f8, 0x23  // Test for x=inf
 }
 ;;
 
 { .mfb
-      ldfe      tan_Pi_by_2_lo = [tan_ADQ],16           
+      ldfe      tan_Pi_by_2_lo = [tan_ADQ],16
       fclass.m.unc  p8,p0 = f8, 0xc3  // Test for x=nan
-(p6)  br.ret.spnt    b0    ;;         // Exit for x=0
+(p6)  br.ret.spnt    b0    ;;         // Exit for x=0 (tan only)
 }
 
 { .mfi
-      ldfpd     tan_P14,tan_P15 = [tan_AD],16                         
+      ldfpd     tan_P14,tan_P15 = [tan_AD],16
 (p7)  frcpa.s0  f8,p9=f0,f0           // Set qnan indef if x=inf
       mov       tan_GR_10009 = 0x10009
 }
 { .mib
-      ldfpd      tan_Q8,tan_Q9  = [tan_ADQ],16                        
+      ldfpd      tan_Q8,tan_Q9  = [tan_ADQ],16
       nop.i 999
 (p7)  br.ret.spnt    b0    ;;         // Exit for x=inf
 }
 
 { .mfi
-      ldfpd      tan_P12,tan_P13 = [tan_AD],16                         
-(p8)  fma.d f8=f8,f1,f8               // Set qnan if x=nan
+      ldfpd      tan_P12,tan_P13 = [tan_AD],16
+(p12) fclass.m.unc  p6,p0 = f8, 0x07  // Test for x=0 (cot)
       nop.i 999
 }
-{ .mib
-      ldfpd      tan_Q4,tan_Q5  = [tan_ADQ],16                        
-      nop.i 999
+{ .mfb
+      ldfpd      tan_Q4,tan_Q5  = [tan_ADQ],16
+(p8)  fma.d.s0   f8=f8,f1,f8          // Set qnan if x=nan
 (p8)  br.ret.spnt    b0    ;;         // Exit for x=nan
 }
 
-{ .mmi
-      getf.exp  tan_signexp    = tan_NORM_f8                 
-      ldfpd      tan_P8,tan_P9  = [tan_AD],16                         
-      nop.i 999 ;;
+{ .mmf
+      getf.exp  tan_signexp    = tan_NORM_f8
+      ldfpd     tan_P8,tan_P9  = [tan_AD],16
+      fmerge.s  arg_copy       = f8, f8 ;; // Save input for error call
 }
 
-// Multiply x by scaled 2/pi and add large const to shift integer part of W to 
+// Multiply x by scaled 2/pi and add large const to shift integer part of W to
 //   rightmost bits of significand
-{ .mfi
+{ .mmf
+      alloc      r32=ar.pfs,0,4,4,0
       ldfpd      tan_Q6,tan_Q7  = [tan_ADQ],16
       fma.s1 TAN_W_2TO64_RSH = tan_NORM_f8,TAN_INV_PI_BY_2_2TO64,TAN_RSHF_2TO64
-      nop.i 999 ;;
-}
+};;
 
-{ .mmi
-      ldfpd      tan_P10,tan_P11 = [tan_AD],16                         
-      nop.m 999
-      and       tan_exp = tan_GR_17_ones, tan_signexp         ;;
+{ .mmf
+      ldfpd      tan_P10,tan_P11 = [tan_AD],16
+      and       tan_exp = tan_GR_17_ones, tan_signexp
+(p6)  frcpa.s0  f8, p0 = f1, f8 ;;        // cot(+-0) = +-Inf
 }
 
 
 // p7 is true if we must call DBX TAN
 // p7 is true if f8 exp is > 0x10009 (which includes all ones
 //    NAN or inf)
-{ .mmi
-      ldfpd      tan_Q0,tan_Q1  = [tan_ADQ],16                         
-      cmp.ge.unc  p7,p0 = tan_exp,tan_GR_10009               
-      nop.i 999 ;;
+{ .mmb
+      ldfpd      tan_Q0,tan_Q1  = [tan_ADQ],16
+      cmp.ge.unc  p7,p0 = tan_exp,tan_GR_10009
+(p7)  br.cond.spnt   TAN_DBX ;;
 }
 
 
 { .mmb
-      ldfpd      tan_P4,tan_P5  = [tan_AD],16                         
-      nop.m 999
-(p7)  br.cond.spnt   L(TAN_DBX) ;;                                  
+      ldfpd      tan_P4,tan_P5  = [tan_AD],16
+(p6)  mov GR_Parameter_Tag = 226          // (cot)
+(p6)  br.cond.spnt __libm_error_region ;; // call error support if cot(+-0)
 }
 
 
 { .mmi
-      ldfpd      tan_Q2,tan_Q3  = [tan_ADQ],16                         
+      ldfpd      tan_Q2,tan_Q3  = [tan_ADQ],16
       nop.m 999
       nop.i 999 ;;
 }
@@ -404,8 +417,8 @@ __tan:
 
 // TAN_NFLOAT = Round_Int_Nearest(tan_W)
 { .mfi
-      ldfpd      tan_P6,tan_P7  = [tan_AD],16                         
-      fms.s1 TAN_NFLOAT = TAN_W_2TO64_RSH,TAN_2TOM64,TAN_RSHF      
+      ldfpd      tan_P6,tan_P7  = [tan_AD],16
+      fms.s1 TAN_NFLOAT = TAN_W_2TO64_RSH,TAN_2TOM64,TAN_RSHF
       nop.i 999 ;;
 }
 
@@ -418,22 +431,22 @@ __tan:
 
 
 { .mfi
-      ldfpd      tan_P0,tan_P1  = [tan_AD],16                         
+      ldfpd      tan_P0,tan_P1  = [tan_AD],16
       nop.f 999
       nop.i 999 ;;
 }
 
 
-{ .mfi
+{ .mmi
       getf.sig    tan_GR_n = TAN_W_2TO64_RSH
-      nop.f 999
+      ldfpd      tan_P2,tan_P3  = [tan_AD]
       nop.i 999 ;;
 }
 
 // tan_r          = -tan_Nfloat * tan_Pi_by_2_hi + x
 { .mfi
-      ldfpd      tan_P2,tan_P3  = [tan_AD]
-      fnma.s1  tan_r      = TAN_NFLOAT, tan_Pi_by_2_hi,  tan_NORM_f8         
+(p12) add        tan_GR_n = 0x1, tan_GR_n // N = N + 1 (for cot)
+      fnma.s1  tan_r      = TAN_NFLOAT, tan_Pi_by_2_hi,  tan_NORM_f8
       nop.i 999 ;;
 }
 
@@ -441,42 +454,49 @@ __tan:
 // p8 ==> even
 // p9 ==> odd
 { .mmi
-      and         tan_GR_N_odd_even = 0x1, tan_GR_n ;;          
+      and         tan_GR_N_odd_even = 0x1, tan_GR_n ;;
       nop.m 999
       cmp.eq.unc  p8,p9          = tan_GR_N_odd_even, r0      ;;
 }
 
 
-// tan_r          = tan_r -tan_Nfloat * tan_Pi_by_2_lo 
+.pred.rel "mutex", p11, p12
+// tan_r          = tan_r -tan_Nfloat * tan_Pi_by_2_lo (tan)
 { .mfi
       nop.m 999
-      fnma.s1  tan_r      = TAN_NFLOAT, tan_Pi_by_2_lo,  tan_r      
+(p11) fnma.s1  tan_r      = TAN_NFLOAT, tan_Pi_by_2_lo,  tan_r
+      nop.i 999
+}
+// tan_r          = -(tan_r -tan_Nfloat * tan_Pi_by_2_lo) (cot)
+{ .mfi
+      nop.m 999
+(p12) fms.s1   tan_r      = TAN_NFLOAT, tan_Pi_by_2_lo,  tan_r
       nop.i 999 ;;
 }
 
 
 { .mfi
       nop.m 999
-      fma.s1   tan_rsq    = tan_r, tan_r,   f0                      
+      fma.s1   tan_rsq    = tan_r, tan_r,   f0
       nop.i 999 ;;
 }
 
 
 { .mfi
       nop.m 999
-(p9)  frcpa.s1   tan_y0, p10 = f1,tan_r                  
+(p9)  frcpa.s1   tan_y0, p0 = f1,tan_r
       nop.i 999  ;;
 }
 
 
 { .mfi
       nop.m 999
-(p8)  fma.s1  tan_v18 = tan_rsq, tan_P15, tan_P14        
+(p8)  fma.s1  tan_v18 = tan_rsq, tan_P15, tan_P14
       nop.i 999
 }
 { .mfi
       nop.m 999
-(p8)  fma.s1  tan_v4  = tan_rsq, tan_P1, tan_P0          
+(p8)  fma.s1  tan_v4  = tan_rsq, tan_P1, tan_P0
       nop.i 999  ;;
 }
 
@@ -484,12 +504,12 @@ __tan:
 
 { .mfi
       nop.m 999
-(p8)  fma.s1  tan_v16 = tan_rsq, tan_P13, tan_P12        
-      nop.i 999 
+(p8)  fma.s1  tan_v16 = tan_rsq, tan_P13, tan_P12
+      nop.i 999
 }
 { .mfi
       nop.m 999
-(p8)  fma.s1  tan_v17 = tan_rsq, tan_rsq, f0             
+(p8)  fma.s1  tan_v17 = tan_rsq, tan_rsq, f0
       nop.i 999 ;;
 }
 
@@ -497,12 +517,12 @@ __tan:
 
 { .mfi
       nop.m 999
-(p8)  fma.s1  tan_v12 = tan_rsq, tan_P9, tan_P8          
-      nop.i 999 
+(p8)  fma.s1  tan_v12 = tan_rsq, tan_P9, tan_P8
+      nop.i 999
 }
 { .mfi
       nop.m 999
-(p8)  fma.s1  tan_v13 = tan_rsq, tan_P11, tan_P10        
+(p8)  fma.s1  tan_v13 = tan_rsq, tan_P11, tan_P10
       nop.i 999 ;;
 }
 
@@ -510,12 +530,12 @@ __tan:
 
 { .mfi
       nop.m 999
-(p8)  fma.s1  tan_v7  = tan_rsq, tan_P5, tan_P4          
-      nop.i 999 
+(p8)  fma.s1  tan_v7  = tan_rsq, tan_P5, tan_P4
+      nop.i 999
 }
 { .mfi
       nop.m 999
-(p8)  fma.s1  tan_v8  = tan_rsq, tan_P7, tan_P6          
+(p8)  fma.s1  tan_v8  = tan_rsq, tan_P7, tan_P6
       nop.i 999 ;;
 }
 
@@ -523,12 +543,12 @@ __tan:
 
 { .mfi
       nop.m 999
-(p9)  fnma.s1    tan_d   = tan_r, tan_y0, f1   
-      nop.i 999 
+(p9)  fnma.s1    tan_d   = tan_r, tan_y0, f1
+      nop.i 999
 }
 { .mfi
       nop.m 999
-(p8)  fma.s1  tan_v5  = tan_rsq, tan_P3, tan_P2          
+(p8)  fma.s1  tan_v5  = tan_rsq, tan_P3, tan_P2
       nop.i 999 ;;
 }
 
@@ -536,36 +556,36 @@ __tan:
 
 { .mfi
       nop.m 999
-(p9)  fma.s1  tan_z11 = tan_rsq, tan_Q9, tan_Q8         
+(p9)  fma.s1  tan_z11 = tan_rsq, tan_Q9, tan_Q8
       nop.i 999
 }
 { .mfi
       nop.m 999
-(p9)  fma.s1  tan_z12 = tan_rsq, tan_rsq, f0            
+(p9)  fma.s1  tan_z12 = tan_rsq, tan_rsq, f0
       nop.i 999 ;;
 }
 
 
 { .mfi
       nop.m 999
-(p8)  fma.s1  tan_v15 = tan_v17, tan_v18, tan_v16        
-      nop.i 999 
+(p8)  fma.s1  tan_v15 = tan_v17, tan_v18, tan_v16
+      nop.i 999
 }
 { .mfi
       nop.m 999
-(p9)  fma.s1  tan_z7 = tan_rsq, tan_Q5, tan_Q4          
+(p9)  fma.s1  tan_z7 = tan_rsq, tan_Q5, tan_Q4
       nop.i 999 ;;
 }
 
 
 { .mfi
       nop.m 999
-(p8)  fma.s1  tan_v11 = tan_v17, tan_v13, tan_v12        
+(p8)  fma.s1  tan_v11 = tan_v17, tan_v13, tan_v12
       nop.i 999
 }
 { .mfi
       nop.m 999
-(p9)  fma.s1  tan_z8 = tan_rsq, tan_Q7, tan_Q6          
+(p9)  fma.s1  tan_z8 = tan_rsq, tan_Q7, tan_Q6
       nop.i 999 ;;
 }
 
@@ -573,13 +593,13 @@ __tan:
 
 { .mfi
       nop.m 999
-(p8)  fma.s1  tan_v14 = tan_v17, tan_v17, f0             
-      nop.i 999 
+(p8)  fma.s1  tan_v14 = tan_v17, tan_v17, f0
+      nop.i 999
 }
 { .mfi
       nop.m 999
-(p9)  fma.s1  tan_z3 = tan_rsq, tan_Q1, tan_Q0          
-      nop.i 999 ;; 
+(p9)  fma.s1  tan_z3 = tan_rsq, tan_Q1, tan_Q0
+      nop.i 999 ;;
 }
 
 
@@ -587,12 +607,12 @@ __tan:
 
 { .mfi
       nop.m 999
-(p8)  fma.s1  tan_v3 = tan_v17, tan_v5, tan_v4           
+(p8)  fma.s1  tan_v3 = tan_v17, tan_v5, tan_v4
       nop.i 999
 }
 { .mfi
       nop.m 999
-(p8)  fma.s1  tan_v6 = tan_v17, tan_v8, tan_v7           
+(p8)  fma.s1  tan_v6 = tan_v17, tan_v8, tan_v7
       nop.i 999 ;;
 }
 
@@ -600,89 +620,89 @@ __tan:
 
 { .mfi
       nop.m 999
-(p9)  fma.s1     tan_y1  = tan_y0, tan_d, tan_y0    
-      nop.i 999 
+(p9)  fma.s1     tan_y1  = tan_y0, tan_d, tan_y0
+      nop.i 999
 }
 { .mfi
       nop.m 999
-(p9)  fma.s1     tan_dsq = tan_d, tan_d, f0        
-      nop.i 999 ;; 
+(p9)  fma.s1     tan_dsq = tan_d, tan_d, f0
+      nop.i 999 ;;
 }
 
 
 { .mfi
       nop.m 999
-(p9)  fma.s1  tan_z10 = tan_z12, tan_Q10, tan_z11       
-      nop.i 999 
+(p9)  fma.s1  tan_z10 = tan_z12, tan_Q10, tan_z11
+      nop.i 999
 }
 { .mfi
       nop.m 999
-(p9)  fma.s1  tan_z9  = tan_z12, tan_z12,f0             
+(p9)  fma.s1  tan_z9  = tan_z12, tan_z12,f0
       nop.i 999 ;;
 }
 
 
 { .mfi
       nop.m 999
-(p9)  fma.s1  tan_z4 = tan_rsq, tan_Q3, tan_Q2          
-      nop.i 999 
+(p9)  fma.s1  tan_z4 = tan_rsq, tan_Q3, tan_Q2
+      nop.i 999
 }
 { .mfi
       nop.m 999
-(p9)  fma.s1  tan_z6  = tan_z12, tan_z8, tan_z7         
-      nop.i 999 ;; 
+(p9)  fma.s1  tan_z6  = tan_z12, tan_z8, tan_z7
+      nop.i 999 ;;
 }
 
 
 
 { .mfi
       nop.m 999
-(p8)  fma.s1  tan_v10 = tan_v14, tan_v15, tan_v11        
-      nop.i 999 ;; 
+(p8)  fma.s1  tan_v10 = tan_v14, tan_v15, tan_v11
+      nop.i 999 ;;
 }
 
 
 
 { .mfi
       nop.m 999
-(p9)  fma.s1     tan_y2  = tan_y1, tan_d, tan_y0         
-      nop.i 999 
+(p9)  fma.s1     tan_y2  = tan_y1, tan_d, tan_y0
+      nop.i 999
 }
 { .mfi
       nop.m 999
-(p9)  fma.s1     tan_d4  = tan_dsq, tan_dsq, tan_d       
+(p9)  fma.s1     tan_d4  = tan_dsq, tan_dsq, tan_d
       nop.i 999  ;;
 }
 
 
 { .mfi
       nop.m 999
-(p8)  fma.s1  tan_v2 = tan_v14, tan_v6, tan_v3           
+(p8)  fma.s1  tan_v2 = tan_v14, tan_v6, tan_v3
       nop.i 999
 }
 { .mfi
       nop.m 999
-(p8)  fma.s1  tan_v9 = tan_v14, tan_v14, f0              
+(p8)  fma.s1  tan_v9 = tan_v14, tan_v14, f0
       nop.i 999 ;;
 }
 
 
 { .mfi
       nop.m 999
-(p9)  fma.s1  tan_z2  = tan_z12, tan_z4, tan_z3         
-      nop.i 999 
+(p9)  fma.s1  tan_z2  = tan_z12, tan_z4, tan_z3
+      nop.i 999
 }
 { .mfi
       nop.m 999
-(p9)  fma.s1  tan_z5  = tan_z9, tan_z10, tan_z6         
+(p9)  fma.s1  tan_z5  = tan_z9, tan_z10, tan_z6
       nop.i 999  ;;
 }
 
 
 { .mfi
       nop.m 999
-(p9)  fma.s1     tan_inv_r = tan_d4, tan_y2, tan_y0      
-      nop.i 999 
+(p9)  fma.s1     tan_inv_r = tan_d4, tan_y2, tan_y0
+      nop.i 999
 }
 { .mfi
       nop.m 999
@@ -694,12 +714,12 @@ __tan:
 
 { .mfi
       nop.m 999
-(p8)  fma.s1  tan_v1 = tan_v9, tan_v10, tan_v2           
-      nop.i 999 
+(p8)  fma.s1  tan_v1 = tan_v9, tan_v10, tan_v2
+      nop.i 999
 }
 { .mfi
       nop.m 999
-(p9)  fma.s1  tan_z1  = tan_z9, tan_z5, tan_z2          
+(p9)  fma.s1  tan_z1  = tan_z9, tan_z5, tan_z2
       nop.i 999   ;;
 }
 
@@ -707,64 +727,150 @@ __tan:
 
 { .mfi
       nop.m 999
-(p8)  fma.d.s0  f8  = tan_v1, tan_rcube, tan_r             
-      nop.i 999  
+(p8)  fma.d.s0  f8  = tan_v1, tan_rcube, tan_r
+      nop.i 999
 }
 { .mfb
       nop.m 999
-(p9)  fms.d.s0  f8  = tan_r, tan_z1, tan_inv_r        
-      br.ret.sptk    b0 ;;    
+(p9)  fms.d.s0  f8  = tan_r, tan_z1, tan_inv_r
+      br.ret.sptk    b0 ;;
 }
-.endp tan#
-ASM_SIZE_DIRECTIVE(tan)
-
+GLOBAL_IEEE754_END(tan)
 
-.proc __libm_callout
-__libm_callout:
-L(TAN_DBX): 
+LOCAL_LIBM_ENTRY(__libm_callout)
+TAN_DBX:
 .prologue
 
 { .mfi
-        nop.m 0
-     fmerge.s f9 = f0,f0 
-.save   ar.pfs,GR_SAVE_PFS
-        mov  GR_SAVE_PFS=ar.pfs
+      nop.m 0
+      fmerge.s f9 = f0,f0
+.save ar.pfs,GR_SAVE_PFS
+      mov  GR_SAVE_PFS=ar.pfs
 }
 ;;
 
 { .mfi
-        mov GR_SAVE_GP=gp
-        nop.f 0
-.save   b0, GR_SAVE_B0
-        mov GR_SAVE_B0=b0
+      mov GR_SAVE_GP=gp
+      nop.f 0
+.save b0, GR_SAVE_B0
+      mov GR_SAVE_B0=b0
 }
 
 .body
-{ .mfb
+{ .mmb
       nop.m 999
-      nop.f 999
-       br.call.sptk.many  b0=__libm_tan# ;;
+      nop.m 999
+(p11) br.cond.sptk.many  call_tanl ;;
 }
 
+// Here if we should call cotl
+{ .mmb
+      nop.m 999
+      nop.m 999
+      br.call.sptk.many  b0=__libm_cotl# ;;
+}
 
 { .mfi
-       mov gp        = GR_SAVE_GP
-      fnorm.d     f8 = f8
-       mov b0        = GR_SAVE_B0 
+      mov gp        = GR_SAVE_GP
+      fnorm.d.s0 f8 = f8
+      mov b0        = GR_SAVE_B0
 }
 ;;
 
+{ .mib
+      nop.m 999
+      mov ar.pfs    = GR_SAVE_PFS
+      br.ret.sptk     b0
+;;
+}
+
+// Here if we should call tanl
+call_tanl:
+{ .mmb
+      nop.m 999
+      nop.m 999
+      br.call.sptk.many  b0=__libm_tanl# ;;
+}
+
+{ .mfi
+      mov gp        = GR_SAVE_GP
+      fnorm.d.s0 f8 = f8
+      mov b0        = GR_SAVE_B0
+}
+;;
 
 { .mib
-         nop.m 999
+      nop.m 999
       mov ar.pfs    = GR_SAVE_PFS
       br.ret.sptk     b0
 ;;
 }
 
+LOCAL_LIBM_END(__libm_callout)
+
+.type __libm_tanl#,@function
+.global __libm_tanl#
+.type __libm_cotl#,@function
+.global __libm_cotl#
+
+LOCAL_LIBM_ENTRY(__libm_error_region)
+.prologue
+
+// (1)
+{ .mfi
+      add           GR_Parameter_Y=-32,sp        // Parameter 2 value
+      nop.f 0
+.save   ar.pfs,GR_SAVE_PFS
+      mov           GR_SAVE_PFS=ar.pfs           // Save ar.pfs
+}
+{ .mfi
+.fframe 64
+      add sp=-64,sp                              // Create new stack
+      nop.f 0
+      mov GR_SAVE_GP=gp                          // Save gp
+};;
+
+// (2)
+{ .mmi
+      stfd [GR_Parameter_Y] = f1,16              // STORE Parameter 2 on stack
+      add GR_Parameter_X = 16,sp                 // Parameter 1 address
+.save   b0, GR_SAVE_B0
+      mov GR_SAVE_B0=b0                          // Save b0
+};;
+
+.body
+// (3)
+{ .mib
+      stfd [GR_Parameter_X] = arg_copy           // STORE Parameter 1 on stack
+      add   GR_Parameter_RESULT = 0,GR_Parameter_Y  // Parameter 3 address
+      nop.b 0
+}
+{ .mib
+      stfd [GR_Parameter_Y] = f8                 // STORE Parameter 3 on stack
+      add   GR_Parameter_Y = -16,GR_Parameter_Y
+      br.call.sptk b0=__libm_error_support#      // Call error handling function
+};;
+{ .mmi
+      nop.m 0
+      nop.m 0
+      add   GR_Parameter_RESULT = 48,sp
+};;
+
+// (4)
+{ .mmi
+      ldfd  f8 = [GR_Parameter_RESULT]           // Get return result off stack
+.restore sp
+      add   sp = 64,sp                           // Restore stack pointer
+      mov   b0 = GR_SAVE_B0                      // Restore return address
+};;
+{ .mib
+      mov   gp = GR_SAVE_GP                      // Restore gp
+      mov   ar.pfs = GR_SAVE_PFS                 // Restore ar.pfs
+      br.ret.sptk     b0                         // Return
+};;
+
+LOCAL_LIBM_END(__libm_error_region)
 
-.endp  __libm_callout
-ASM_SIZE_DIRECTIVE(__libm_callout)
+.type   __libm_error_support#,@function
+.global __libm_error_support#
 
-.type __libm_tan#,@function
-.global __libm_tan#