]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/i386/fpu/e_atanhf.S
Optimize libm
[thirdparty/glibc.git] / sysdeps / i386 / fpu / e_atanhf.S
CommitLineData
d38cd08c 1/* ix87 specific implementation of arctanh function.
0ac5ae23 2 Copyright (C) 1996, 1999, 2005, 2011 Free Software Foundation, Inc.
d38cd08c
UD
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
5
6 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
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.
d38cd08c
UD
10
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
41bdb6e2 14 Lesser General Public License for more details.
d38cd08c 15
41bdb6e2
AJ
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA. */
d38cd08c
UD
20
21#include <machine/asm.h>
22
23#ifdef __ELF__
24 .section .rodata
25#else
26 .text
27#endif
28
29 .align ALIGNARG(4)
30 ASM_TYPE_DIRECTIVE(half,@object)
31half: .double 0.5
32 ASM_SIZE_DIRECTIVE(half)
33 ASM_TYPE_DIRECTIVE(one,@object)
34one: .double 1.0
35 ASM_SIZE_DIRECTIVE(one)
36 ASM_TYPE_DIRECTIVE(limit,@object)
37limit: .double 0.29
38 ASM_SIZE_DIRECTIVE(limit)
39 .align ALIGNARG(4)
40 ASM_TYPE_DIRECTIVE(ln2_2,@object)
41ln2_2: .tfloat 0.3465735902799726547086160
42 ASM_SIZE_DIRECTIVE(ln2_2)
43
44#ifdef PIC
45#define MO(op) op##@GOTOFF(%edx)
46#else
47#define MO(op) op
48#endif
49
50 .text
51ENTRY(__ieee754_atanhf)
52 movl 4(%esp), %ecx
53
15daa639
UD
54 movl %ecx, %eax
55 andl $0x7fffffff, %eax
56 cmpl $0x7f800000, %eax
57 ja 5f
58
d38cd08c 59#ifdef PIC
fee732e5 60 LOAD_PIC_REG (dx)
d38cd08c
UD
61#endif
62
63 andl $0x80000000, %ecx // ECX == 0 iff X >= 0
64
65 fldt MO(ln2_2) // 0.5*ln2
66 xorl %ecx, 4(%esp)
67 flds 4(%esp) // |x| : 0.5*ln2
68 fcoml MO(half) // |x| : 0.5*ln2
69 fld %st(0) // |x| : |x| : 0.5*ln2
70 fnstsw // |x| : |x| : 0.5*ln2
71 sahf
72 jae 2f
73 fadd %st, %st(1) // |x| : 2*|x| : 0.5*ln2
74 fld %st // |x| : |x| : 2*|x| : 0.5*ln2
75 fsubrl MO(one) // 1-|x| : |x| : 2*|x| : 0.5*ln2
76 fxch // |x| : 1-|x| : 2*|x| : 0.5*ln2
77 fmul %st(2) // 2*|x|^2 : 1-|x| : 2*|x| : 0.5*ln2
78 fdivp // (2*|x|^2)/(1-|x|) : 2*|x| : 0.5*ln2
79 faddp // 2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2
80 fcoml MO(limit) // 2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2
81 fnstsw // 2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2
82 sahf
83 jae 4f
84 fyl2xp1 // 0.5*ln2*ld(1+2*|x|+(2*|x|^2)/(1-|x|))
85 jecxz 3f
86 fchs // 0.5*ln2*ld(1+2*x+(2*x^2)/(1-x))
873: ret
88
89 .align ALIGNARG(4)
904: faddl MO(one) // 1+2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2
91 fyl2x // 0.5*ln2*ld(1+2*|x|+(2*|x|^2)/(1-|x|))
92 jecxz 3f
93 fchs // 0.5*ln2*ld(1+2*x+(2*x^2)/(1-x))
943: ret
95
96 .align ALIGNARG(4)
972: faddl MO(one) // 1+|x| : |x| : 0.5*ln2
98 fxch // |x| : 1+|x| : 0.5*ln2
99 fsubrl MO(one) // 1-|x| : 1+|x| : 0.5*ln2
100 fdivrp // (1+|x|)/(1-|x|) : 0.5*ln2
101 fyl2x // 0.5*ln2*ld((1+|x|)/(1-|x|))
102 jecxz 3f
103 fchs // 0.5*ln2*ld((1+x)/(1-x))
1043: ret
15daa639
UD
105
106 // x == NaN
1075: flds 4(%esp)
108 ret
d38cd08c 109END(__ieee754_atanhf)
0ac5ae23 110strong_alias (__ieee754_atanhf, __atanhf_finite)