Update copyright dates with scripts/update-copyrights.
[glibc.git] / sysdeps / i386 / fpu / e_atanhl.S
blob88a970378d8ffd4da50c63212e3c6b48699b81f0
1 /* ix87 specific implementation of arctanh function.
2    Copyright (C) 1996-2015 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
11    The GNU C Library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, see
18    <http://www.gnu.org/licenses/>.  */
20 #include <machine/asm.h>
22         .section .rodata
24         .align ALIGNARG(4)
25         /* Please note that we use double values for 0.5 and 1.0.  These
26            numbers have exact representations and so we don't get accuracy
27            problems.  The advantage is that the code is simpler.  */
28         .type half,@object
29 half:   .double 0.5
30         ASM_SIZE_DIRECTIVE(half)
31         .type one,@object
32 one:    .double 1.0
33         ASM_SIZE_DIRECTIVE(one)
34         /* It is not important that this constant is precise.  It is only
35            a value which is known to be on the safe side for using the
36            fyl2xp1 instruction.  */
37         .type limit,@object
38 limit:  .double 0.29
39         ASM_SIZE_DIRECTIVE(limit)
40         .align ALIGNARG(4)
41         .type ln2_2,@object
42 ln2_2:  .tfloat 0.3465735902799726547086160
43         ASM_SIZE_DIRECTIVE(ln2_2)
45 #ifdef PIC
46 #define MO(op) op##@GOTOFF(%edx)
47 #else
48 #define MO(op) op
49 #endif
51         .text
52 ENTRY(__ieee754_atanhl)
53         movl    12(%esp), %ecx
55         movl    %ecx, %eax
56         andl    $0x7fff, %eax
57         cmpl    $0x7fff, %eax
58         je      5f
61 #ifdef PIC
62         LOAD_PIC_REG (dx)
63 #endif
65         andl    $0x8000, %ecx   // ECX == 0 iff X >= 0
67         fldt    MO(ln2_2)       // 0.5*ln2
68         xorl    %ecx, 12(%esp)
69         fldt    4(%esp)         // |x| : 0.5*ln2
70         fcoml   MO(half)        // |x| : 0.5*ln2
71         fld     %st(0)          // |x| : |x| : 0.5*ln2
72         fnstsw                  // |x| : |x| : 0.5*ln2
73         sahf
74         jae     2f
75         fadd    %st, %st(1)     // |x| : 2*|x| : 0.5*ln2
76         fld     %st             // |x| : |x| : 2*|x| : 0.5*ln2
77         fsubrl  MO(one)         // 1-|x| : |x| : 2*|x| : 0.5*ln2
78         fxch                    // |x| : 1-|x| : 2*|x| : 0.5*ln2
79         fmul    %st(2)          // 2*|x|^2 : 1-|x| : 2*|x| : 0.5*ln2
80         fdivp                   // (2*|x|^2)/(1-|x|) : 2*|x| : 0.5*ln2
81         faddp                   // 2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2
82         fcoml   MO(limit)       // 2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2
83         fnstsw                  // 2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2
84         sahf
85         jae     4f
86         fyl2xp1                 // 0.5*ln2*ld(1+2*|x|+(2*|x|^2)/(1-|x|))
87         jecxz   3f
88         fchs                    // 0.5*ln2*ld(1+2*x+(2*x^2)/(1-x))
89 3:      ret
91         .align ALIGNARG(4)
92 4:      faddl   MO(one)         // 1+2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2
93         fyl2x                   // 0.5*ln2*ld(1+2*|x|+(2*|x|^2)/(1-|x|))
94         jecxz   3f
95         fchs                    // 0.5*ln2*ld(1+2*x+(2*x^2)/(1-x))
96 3:      ret
98         .align ALIGNARG(4)
99 2:      faddl   MO(one)         // 1+|x| : |x| : 0.5*ln2
100         fxch                    // |x| : 1+|x| : 0.5*ln2
101         fsubrl  MO(one)         // 1-|x| : 1+|x| : 0.5*ln2
102         fdivrp                  // (1+|x|)/(1-|x|) : 0.5*ln2
103         fyl2x                   // 0.5*ln2*ld((1+|x|)/(1-|x|))
104         jecxz   3f
105         fchs                    // 0.5*ln2*ld((1+x)/(1-x))
106 3:      ret
108         // x == NaN or ±Inf
109 5:      cmpl    $0x80000000, 8(%esp)
110         ja      6f
111         cmpl    $0, 4(%esp)
112         je      7b
113 6:      fldt    4(%esp)
114         ret
115 END(__ieee754_atanhl)
116 strong_alias (__ieee754_atanhl, __atanhl_finite)