S390: Optimize wmemset.
[glibc.git] / sysdeps / i386 / fpu / e_atanh.S
blob90d19bc9d62d1cc63a8862b5748116e570365eb0
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         .type half,@object
26 half:   .double 0.5
27         ASM_SIZE_DIRECTIVE(half)
28         .type one,@object
29 one:    .double 1.0
30         ASM_SIZE_DIRECTIVE(one)
31         .type limit,@object
32 limit:  .double 0.29
33         ASM_SIZE_DIRECTIVE(limit)
34         .type ln2_2,@object
35 ln2_2:  .tfloat 0.3465735902799726547086160
36         ASM_SIZE_DIRECTIVE(ln2_2)
38         .section .rodata.cst8,"aM",@progbits,8
40         .p2align 3
41         .type dbl_min,@object
42 dbl_min:        .byte 0, 0, 0, 0, 0, 0, 0x10, 0
43         ASM_SIZE_DIRECTIVE(dbl_min)
45 #ifdef PIC
46 #define MO(op) op##@GOTOFF(%edx)
47 #else
48 #define MO(op) op
49 #endif
51         .text
52 ENTRY(__ieee754_atanh)
53         movl    8(%esp), %ecx
55         movl    %ecx, %eax
56         andl    $0x7fffffff, %eax
57         cmpl    $0x7ff00000, %eax
58         jae     5f
61 #ifdef PIC
62         call    1f
63         cfi_adjust_cfa_offset (4)
64 1:      popl    %edx
65         cfi_adjust_cfa_offset (-4)
66         addl    $_GLOBAL_OFFSET_TABLE_+[.-1b], %edx
67 #endif
69         andl    $0x80000000, %ecx // ECX == 0 iff X >= 0
71         fldt    MO(ln2_2)       // 0.5*ln2
72         xorl    %ecx, 8(%esp)
73         fldl    4(%esp)         // |x| : 0.5*ln2
74         fcoml   MO(half)        // |x| : 0.5*ln2
75         fld     %st             // |x| : |x| : 0.5*ln2
76         fnstsw                  // |x| : |x| : 0.5*ln2
77         sahf
78         jae     2f
79         fadd    %st, %st(1)     // |x| : 2*|x| : 0.5*ln2
80         fld     %st             // |x| : |x| : 2*|x| : 0.5*ln2
81         fsubrl  MO(one)         // 1-|x| : |x| : 2*|x| : 0.5*ln2
82         fxch                    // |x| : 1-|x| : 2*|x| : 0.5*ln2
83         fmul    %st(2)          // 2*|x|^2 : 1-|x| : 2*|x| : 0.5*ln2
84         fdivp                   // (2*|x|^2)/(1-|x|) : 2*|x| : 0.5*ln2
85         faddp                   // 2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2
86         fcoml   MO(limit)       // 2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2
87         fnstsw                  // 2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2
88         sahf
89         jae     4f
90         fyl2xp1                 // 0.5*ln2*ld(1+2*|x|+(2*|x|^2)/(1-|x|))
91         fcoml   MO(dbl_min)
92         fnstsw
93         sahf
94         jae     8f
95         subl    $8, %esp
96         cfi_adjust_cfa_offset (8)
97         fld     %st(0)
98         fmul    %st(0)
99         fstpl   (%esp)
100         addl    $8, %esp
101         cfi_adjust_cfa_offset (-8)
102 8:      jecxz   3f
103         fchs                    // 0.5*ln2*ld(1+2*x+(2*x^2)/(1-x))
104 3:      ret
106         .align ALIGNARG(4)
107 4:      faddl   MO(one)         // 1+2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2
108         fyl2x                   // 0.5*ln2*ld(1+2*|x|+(2*|x|^2)/(1-|x|))
109         jecxz   3f
110         fchs                    // 0.5*ln2*ld(1+2*x+(2*x^2)/(1-x))
111 3:      ret
113         .align ALIGNARG(4)
114 2:      faddl   MO(one)         // 1+|x| : |x| : 0.5*ln2
115         fxch                    // |x| : 1+|x| : 0.5*ln2
116         fsubrl  MO(one)         // 1-|x| : 1+|x| : 0.5*ln2
117         fdivrp                  // (1+|x|)/(1-|x|) : 0.5*ln2
118         fyl2x                   // 0.5*ln2*ld((1+|x|)/(1-|x|))
119         jecxz   3f
120         fchs                    // 0.5*ln2*ld((1+x)/(1-x))
121 3:      ret
123         // x == NaN or ±Inf
124 5:      ja      6f
125         cmpl    $0, 4(%esp)
126         je      7b
127 6:      fldl    4(%esp)
128         ret
129 END(__ieee754_atanh)
130 strong_alias (__ieee754_atanh, __atanh_finite)