Print this page
5261 libm should stop using synonyms.h
5298 fabs is 0-sized, confuses dis(1) and others
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Approved by: Gordon Ross <gwr@nexenta.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/amd64/src/expm1l.s
+++ new/usr/src/lib/libm/amd64/src/expm1l.s
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
↓ open down ↓ |
22 lines elided |
↑ open up ↑ |
23 23 */
24 24 /*
25 25 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
26 26 * Use is subject to license terms.
27 27 */
28 28
29 29 .file "expm1l.s"
30 30
31 31 #include "libm.h"
32 32 LIBM_ANSI_PRAGMA_WEAK(expm1l,function)
33 -#include "libm_synonyms.h"
34 33
35 34 .data
36 35 .align 16
37 36 ln2_hi: .4byte 0xd1d00000, 0xb17217f7, 0x3ffe, 0x0
38 37 ln2_lo: .4byte 0x4c67fc0d, 0x8654361c, 0xbfce, 0x0
39 38
40 39 ENTRY(expm1l)
41 40 movl 16(%rsp),%ecx / cx <--sign&bexp(x)
42 41 movl %ecx,%eax / ax <--sign&bexp(x)
43 42 andl $0x7fff,%ecx / ecx <-- zero_xtnd(bexp(x))
44 43 cmpl $0x3ffe,%ecx / Is |x| < ln(2)?
45 44 jb .shortcut / If so, take a shortcut.
46 45 je .check_tail / |x| may be only slightly < ln(2)
47 46 .general_case: / Here, |x| > ln(2) or x is NaN
48 47 cmpl $0x7fff,%ecx / bexp(|x|) = bexp(INF)?
49 48 je .not_finite / if so, x is not finite
50 49 andl $0xffff,%eax / eax <-- sign&bexp(x)
51 50 cmpl $0xc006,%eax / x <= -128?
52 51 jae 1f / if so, simply return -1
53 52 cmpl $0x400d,%ecx / |x| < 16384 = 2^14?
54 53 jb .finite_non_special / if so, proceed with argument reduction
55 54 fldt 8(%rsp) / x >= 16384; x
56 55 fld1 / 1, x
57 56 fscale / +Inf, x
58 57 fstp %st(1) / +Inf
59 58 ret
60 59
61 60 .finite_non_special: / -128 < x < -ln(2) || ln(2) < x < 2^14
62 61 fldt 8(%rsp) / x
63 62 fld %st(0) / x, x
64 63 fldl2e / log2(e), x, x
65 64 fmulp / z := x*log2(e), x
66 65 frndint / [z], x
67 66 fst %st(2) / [z], x, [z]
68 67 PIC_SETUP(1)
69 68 fldt PIC_L(ln2_hi) / ln2_hi, [z], x, [z]
70 69 fmulp / [z]*ln2_hi, x, [z]
71 70 fsubrp %st,%st(1) / x-[z]*ln2_hi, [z]
72 71 fldt PIC_L(ln2_lo) / ln2_lo, x-[z]*ln2_hi, [z]
73 72 PIC_WRAPUP
74 73 fmul %st(2),%st / [z]*ln2_lo, x-[z]*ln2_hi, [z]
75 74 fsubrp %st,%st(1) / r := x-[z]*ln(2), [z]
76 75 fldl2e / log2(e), r, [z]
77 76 fmulp / f := r*log2(e), [z]
78 77 f2xm1 / 2^f-1,[z]
79 78 fld1 / 1, 2^f-1, [z]
80 79 faddp %st,%st(1) / 2^f, [z]
81 80 fscale / e^x, [z]
82 81 fstp %st(1) / e^x
83 82 fld1 / 1, e^x
84 83 fsubrp %st,%st(1) / e^x-1
85 84 ret
86 85
87 86 .check_tail:
88 87 movl 12(%rsp),%ecx / ecx <-- hi_32(sgnfcnd(x))
89 88 cmpl $0xb17217f7,%ecx / Is |x| < ln(2)?
90 89 ja .finite_non_special
91 90 jb .shortcut
92 91 movl 8(%rsp),%edx / edx <-- lo_32(x)
93 92 cmpl $0xd1cf79ab,%edx / Is |x| slightly < ln(2)?
94 93 ja .finite_non_special / branch if |x| slightly > ln(2)
95 94 .shortcut:
96 95 / Here, |x| < ln(2), so |z| = |x/ln(2)| < 1,
97 96 / whence z is in f2xm1's domain.
98 97 fldt 8(%rsp) / x
99 98 fldl2e / log2(e), x
100 99 fmulp / z := x*log2(e)
101 100 f2xm1 / 2^(x*log2(e))-1 = e^x-1
102 101 ret
103 102
104 103 .not_finite:
105 104 movl 12(%rsp),%ecx / ecx <-- hi_32(sgnfcnd(x))
106 105 cmpl $0x80000000,%ecx / hi_32(|x|) = hi_32(INF)?
107 106 jne .NaN_or_pinf / if not, x is NaN
108 107 movl 8(%rsp),%edx / edx <-- lo_32(x)
109 108 cmpl $0,%edx / lo_32(x) = 0?
110 109 jne .NaN_or_pinf / if not, x is NaN
111 110 movl 16(%rsp),%eax / ax <-- sign&bexp((x))
112 111 andl $0x8000,%eax / here, x is infinite, but +/-?
113 112 jz .NaN_or_pinf / branch if x = +INF
114 113 1:
115 114 fld1 / Here, x = -inf, so return -1
116 115 fchs
117 116 ret
118 117
119 118 .NaN_or_pinf:
120 119 / Here, x = NaN or +inf, so load x and return immediately.
121 120 fldt 8(%rsp)
122 121 ret
123 122 .align 16
124 123 SET_SIZE(expm1l)
↓ open down ↓ |
81 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX