remove LFS64 symbol aliases; replace with dynamic linker remapping
[musl] / src / math / x86_64 / exp2l.s
1 .global expm1l
2 .type expm1l,@function
3 expm1l:
4         fldt 8(%rsp)
5         fldl2e
6         fmulp
7         movl $0xc2820000,-4(%rsp)
8         flds -4(%rsp)
9         fucomip %st(1),%st
10         fld1
11         jb 1f
12                 # x*log2e <= -65, return -1 without underflow
13         fstp %st(1)
14         fchs
15         ret
16 1:      fld %st(1)
17         fabs
18         fucomip %st(1),%st
19         fstp %st(0)
20         ja 1f
21         f2xm1
22         ret
23 1:      push %rax
24         call 1f
25         pop %rax
26         fld1
27         fsubrp
28         ret
29
30 .global exp2l
31 .type exp2l,@function
32 exp2l:
33         fldt 8(%rsp)
34 1:      fld %st(0)
35         sub $16,%rsp
36         fstpt (%rsp)
37         mov 8(%rsp),%ax
38         and $0x7fff,%ax
39         cmp $0x3fff+13,%ax
40         jb 4f             # |x| < 8192
41         cmp $0x3fff+15,%ax
42         jae 3f            # |x| >= 32768
43         fsts (%rsp)
44         cmpl $0xc67ff800,(%rsp)
45         jb 2f             # x > -16382
46         movl $0x5f000000,(%rsp)
47         flds (%rsp)       # 0x1p63
48         fld %st(1)
49         fsub %st(1)
50         faddp
51         fucomip %st(1),%st
52         je 2f             # x - 0x1p63 + 0x1p63 == x
53         movl $1,(%rsp)
54         flds (%rsp)       # 0x1p-149
55         fdiv %st(1)
56         fstps (%rsp)      # raise underflow
57 2:      fld1
58         fld %st(1)
59         frndint
60         fxch %st(2)
61         fsub %st(2)       # st(0)=x-rint(x), st(1)=1, st(2)=rint(x)
62         f2xm1
63         faddp             # 2^(x-rint(x))
64 1:      fscale
65         fstp %st(1)
66         add $16,%rsp
67         ret
68 3:      xor %eax,%eax
69 4:      cmp $0x3fff-64,%ax
70         fld1
71         jb 1b             # |x| < 0x1p-64
72         fstpt (%rsp)
73         fistl 8(%rsp)
74         fildl 8(%rsp)
75         fsubrp %st(1)
76         addl $0x3fff,8(%rsp)
77         f2xm1
78         fld1
79         faddp             # 2^(x-rint(x))
80         fldt (%rsp)       # 2^rint(x)
81         fmulp
82         add $16,%rsp
83         ret