optimize exponential asm for i386
[musl] / src / math / i386 / exp.s
1 .global expm1f
2 .type expm1f,@function
3 expm1f:
4         flds 4(%esp)
5         jmp 1f
6
7 .global expm1l
8 .type expm1l,@function
9 expm1l:
10         fldt 4(%esp)
11         jmp 1f
12
13 .global expm1
14 .type expm1,@function
15 expm1:
16         fldl 4(%esp)
17 1:      fldl2e
18         fmulp
19         fld1
20         fld %st(1)
21         fabs
22         fucom %st(1)
23         fnstsw %ax
24         fstp %st(0)
25         fstp %st(0)
26         sahf
27         ja 1f
28         f2xm1
29         ret
30 1:      call 1f
31         fld1
32         fsubrp
33         ret
34
35 .global exp2f
36 .type exp2f,@function
37 exp2f:
38         flds 4(%esp)
39         jmp 1f
40
41 .global exp2l
42 .type exp2l,@function
43 exp2l:
44         fldt 4(%esp)
45         jmp 1f
46
47 .global expf
48 .type expf,@function
49 expf:
50         flds 4(%esp)
51         jmp 2f
52
53 .global expl
54 .type expl,@function
55 expl:
56         fldt 4(%esp)
57         jmp 2f
58
59 .global exp
60 .type exp,@function
61 exp:
62         fldl 4(%esp)
63 2:      fldl2e
64         fmulp
65         jmp 1f
66
67 .global exp2
68 .type exp2,@function
69 exp2:
70         fldl 4(%esp)
71 1:      mov $0x47000000,%eax
72         push %eax
73         flds (%esp)
74         shl $7,%eax
75         push %eax
76         add %eax,%eax
77         push %eax
78         fld %st(1)
79         fabs
80         fucom %st(1)
81         fnstsw
82         sahf
83         ja 2f
84         fstp %st(0)
85         fstp %st(0)
86         fld %st(0)
87         fistpl 8(%esp)
88         fildl 8(%esp)
89         fxch %st(1)
90         fsub %st(1)
91         mov $0x3fff,%eax
92         add %eax,8(%esp)
93         f2xm1
94         fld1
95         faddp
96         fldt (%esp)
97         fmulp
98         fstp %st(1)
99         add $12,%esp
100         ret
101
102 2:      fstp %st(0)
103         fstp %st(0)
104         fsts 8(%esp)
105         mov 8(%esp),%eax
106         lea (%eax,%eax),%ecx
107         cmp $0xff000000,%ecx
108         ja 2f
109         fstp %st(0)
110         xor %ecx,%ecx
111         inc %ecx
112         add %eax,%eax
113         jc 1f
114         mov $0x7ffe,%ecx
115 1:      mov %ecx,8(%esp)
116         fldt (%esp)
117         fld %st(0)
118         fmulp
119 2:      add $12,%esp
120         ret