1 /* ix87 specific implementation of exp(x)-1.
2 Copyright (C) 1996 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
5 Based on code by John C. Bowman <bowman@ipp-garching.mpg.de>.
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public License as
9 published by the Free Software Foundation; either version 2 of the
10 License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public
18 License along with the GNU C Library; see the file COPYING.LIB. If not,
19 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* Using: e^x - 1 = 2^(x * log2(e)) - 1 */
24 #include <machine/asm.h>
32 ASM_TYPE_DIRECTIVE(zero,@object)
34 ASM_SIZE_DIRECTIVE(zero)
35 ASM_TYPE_DIRECTIVE(one,@object)
37 ASM_SIZE_DIRECTIVE(one)
38 ASM_TYPE_DIRECTIVE(l2e,@object)
39 l2e: .tfloat 1.442695040888963407359924681002
40 ASM_SIZE_DIRECTIVE(l2e)
43 #define MO(op) op##@GOTOFF(%edx)
51 fxam // Is NaN or +-Inf?
56 addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %edx
61 je 2f // Is +-Inf, jump.
63 fldt MO(l2e) // log2(e) : x
65 fld %st // log2(e)*x : log2(e)*x
66 frndint // int(log2(e)*x) : log2(e)*x
67 fsub %st, %st(1) // int(log2(e)*x) : fract(log2(e)*x)
68 fxch // fract(log2(e)*x) : int(log2(e)*x)
69 f2xm1 // 2^fract(log2(e)*x)-1 : int(log2(e)*x)
70 fscale // 2^(log2(e)*x)-2^int(log2(e)*x) : int(log2(e)*x)
71 fxch // int(log2(e)*x) : 2^(log2(e)*x)-2^int(log2(e)*x)
72 fldl MO(one) // 1 : int(log2(e)*x) : 2^(log2(e)*x)-2^int(log2(e)*x)
73 fscale // 2^int(log2(e)*x) : 2^(log2(e)*x)-2^int(log2(e)*x)
74 faddp // 2^(log2(e)*x)
78 2: testl $0x200, %eax // Test sign.
79 jz 3f // If positive, jump.
80 fldl MO(zero) // Set result to 0.
83 weak_alias (__expm1l, expm1l)