xref: /third_party/musl/src/math/x86_64/exp2l.s (revision 570af302)
1570af302Sopenharmony_ci.global expm1l
2570af302Sopenharmony_ci.type expm1l,@function
3570af302Sopenharmony_ciexpm1l:
4570af302Sopenharmony_ci	fldt 8(%rsp)
5570af302Sopenharmony_ci	fldl2e
6570af302Sopenharmony_ci	fmulp
7570af302Sopenharmony_ci	movl $0xc2820000,-4(%rsp)
8570af302Sopenharmony_ci	flds -4(%rsp)
9570af302Sopenharmony_ci	fucomip %st(1),%st
10570af302Sopenharmony_ci	fld1
11570af302Sopenharmony_ci	jb 1f
12570af302Sopenharmony_ci		# x*log2e <= -65, return -1 without underflow
13570af302Sopenharmony_ci	fstp %st(1)
14570af302Sopenharmony_ci	fchs
15570af302Sopenharmony_ci	ret
16570af302Sopenharmony_ci1:	fld %st(1)
17570af302Sopenharmony_ci	fabs
18570af302Sopenharmony_ci	fucomip %st(1),%st
19570af302Sopenharmony_ci	fstp %st(0)
20570af302Sopenharmony_ci	ja 1f
21570af302Sopenharmony_ci	f2xm1
22570af302Sopenharmony_ci	ret
23570af302Sopenharmony_ci1:	push %rax
24570af302Sopenharmony_ci	call 1f
25570af302Sopenharmony_ci	pop %rax
26570af302Sopenharmony_ci	fld1
27570af302Sopenharmony_ci	fsubrp
28570af302Sopenharmony_ci	ret
29570af302Sopenharmony_ci
30570af302Sopenharmony_ci.global exp2l
31570af302Sopenharmony_ci.type exp2l,@function
32570af302Sopenharmony_ciexp2l:
33570af302Sopenharmony_ci	fldt 8(%rsp)
34570af302Sopenharmony_ci1:	fld %st(0)
35570af302Sopenharmony_ci	sub $16,%rsp
36570af302Sopenharmony_ci	fstpt (%rsp)
37570af302Sopenharmony_ci	mov 8(%rsp),%ax
38570af302Sopenharmony_ci	and $0x7fff,%ax
39570af302Sopenharmony_ci	cmp $0x3fff+13,%ax
40570af302Sopenharmony_ci	jb 4f             # |x| < 8192
41570af302Sopenharmony_ci	cmp $0x3fff+15,%ax
42570af302Sopenharmony_ci	jae 3f            # |x| >= 32768
43570af302Sopenharmony_ci	fsts (%rsp)
44570af302Sopenharmony_ci	cmpl $0xc67ff800,(%rsp)
45570af302Sopenharmony_ci	jb 2f             # x > -16382
46570af302Sopenharmony_ci	movl $0x5f000000,(%rsp)
47570af302Sopenharmony_ci	flds (%rsp)       # 0x1p63
48570af302Sopenharmony_ci	fld %st(1)
49570af302Sopenharmony_ci	fsub %st(1)
50570af302Sopenharmony_ci	faddp
51570af302Sopenharmony_ci	fucomip %st(1),%st
52570af302Sopenharmony_ci	je 2f             # x - 0x1p63 + 0x1p63 == x
53570af302Sopenharmony_ci	movl $1,(%rsp)
54570af302Sopenharmony_ci	flds (%rsp)       # 0x1p-149
55570af302Sopenharmony_ci	fdiv %st(1)
56570af302Sopenharmony_ci	fstps (%rsp)      # raise underflow
57570af302Sopenharmony_ci2:	fld1
58570af302Sopenharmony_ci	fld %st(1)
59570af302Sopenharmony_ci	frndint
60570af302Sopenharmony_ci	fxch %st(2)
61570af302Sopenharmony_ci	fsub %st(2)       # st(0)=x-rint(x), st(1)=1, st(2)=rint(x)
62570af302Sopenharmony_ci	f2xm1
63570af302Sopenharmony_ci	faddp             # 2^(x-rint(x))
64570af302Sopenharmony_ci1:	fscale
65570af302Sopenharmony_ci	fstp %st(1)
66570af302Sopenharmony_ci	add $16,%rsp
67570af302Sopenharmony_ci	ret
68570af302Sopenharmony_ci3:	xor %eax,%eax
69570af302Sopenharmony_ci4:	cmp $0x3fff-64,%ax
70570af302Sopenharmony_ci	fld1
71570af302Sopenharmony_ci	jb 1b             # |x| < 0x1p-64
72570af302Sopenharmony_ci	fstpt (%rsp)
73570af302Sopenharmony_ci	fistl 8(%rsp)
74570af302Sopenharmony_ci	fildl 8(%rsp)
75570af302Sopenharmony_ci	fsubrp %st(1)
76570af302Sopenharmony_ci	addl $0x3fff,8(%rsp)
77570af302Sopenharmony_ci	f2xm1
78570af302Sopenharmony_ci	fld1
79570af302Sopenharmony_ci	faddp             # 2^(x-rint(x))
80570af302Sopenharmony_ci	fldt (%rsp)       # 2^rint(x)
81570af302Sopenharmony_ci	fmulp
82570af302Sopenharmony_ci	add $16,%rsp
83570af302Sopenharmony_ci	ret
84