]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/i386/fpu/s_expm1f.S
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / i386 / fpu / s_expm1f.S
CommitLineData
6bc31da0 1/* ix87 specific implementation of exp(x)-1.
04277e02 2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
6bc31da0
UD
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>.
5290baf0 6 Corrections by H.J. Lu (hjl@gnu.ai.mit.edu), 1997.
6bc31da0
UD
7
8 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
6bc31da0
UD
12
13 The GNU C Library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 16 Lesser General Public License for more details.
6bc31da0 17
41bdb6e2 18 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
19 License along with the GNU C Library; if not, see
20 <http://www.gnu.org/licenses/>. */
6bc31da0
UD
21
22 /* Using: e^x - 1 = 2^(x * log2(e)) - 1 */
23
b7805d0b 24#include <sysdep.h>
6bc31da0 25#include <machine/asm.h>
37825319 26#include <i386-math-asm.h>
e4602cba 27#include <libm-alias-float.h>
6bc31da0 28
6bc31da0 29 .section .rodata
622c86f4 30
6bc31da0 31 .align ALIGNARG(4)
b67e9372 32 .type minus1,@object
0d8733c4
UD
33minus1: .double -1.0
34 ASM_SIZE_DIRECTIVE(minus1)
b67e9372 35 .type one,@object
6bc31da0
UD
36one: .double 1.0
37 ASM_SIZE_DIRECTIVE(one)
b67e9372 38 .type l2e,@object
6bc31da0
UD
39l2e: .tfloat 1.442695040888963407359924681002
40 ASM_SIZE_DIRECTIVE(l2e)
41
37825319 42DEFINE_FLT_MIN
554edb23 43
6bc31da0
UD
44#ifdef PIC
45#define MO(op) op##@GOTOFF(%edx)
46#else
47#define MO(op) op
48#endif
49
50 .text
51ENTRY(__expm1f)
b7805d0b
AS
52 movzwl 4+2(%esp), %eax
53 xorb $0x80, %ah // invert sign bit (now 1 is "positive")
54 cmpl $0xc2b1, %eax // is num >= 88.5?
55 jae HIDDEN_JUMPTARGET (__expf)
56
6bc31da0 57 flds 4(%esp) // x
f17ac40d
JM
58 fxam // Is NaN, +-Inf or +-0?
59 xorb $0x80, %ah
60 cmpl $0xc190, %eax // is num <= -18.0?
6bc31da0 61 fstsw %ax
c57abfa7 62 movb $0x45, %ch
f17ac40d
JM
63 jb 4f
64
65 // Below -18.0 (may be -NaN or -Inf).
66 andb %ah, %ch
67#ifdef PIC
68 LOAD_PIC_REG (dx)
69#endif
70 cmpb $0x01, %ch
71 je 5f // If -NaN, jump.
72 jmp 2f // -large, possibly -Inf.
73
744: // In range -18.0 to 88.5 (may be +-0 but not NaN or +-Inf).
c57abfa7
UD
75 andb %ah, %ch
76 cmpb $0x40, %ch
77 je 3f // If +-0, jump.
6bc31da0 78#ifdef PIC
fee732e5 79 LOAD_PIC_REG (dx)
6bc31da0 80#endif
6bc31da0 81
f17ac40d 825: fldt MO(l2e) // log2(e) : x
6bc31da0
UD
83 fmulp // log2(e)*x
84 fld %st // log2(e)*x : log2(e)*x
f88acd39
JM
85 // Set round-to-nearest temporarily.
86 subl $8, %esp
87 cfi_adjust_cfa_offset (8)
88 fstcw 4(%esp)
89 movl $0xf3ff, %ecx
90 andl 4(%esp), %ecx
91 movl %ecx, (%esp)
92 fldcw (%esp)
6bc31da0 93 frndint // int(log2(e)*x) : log2(e)*x
f88acd39
JM
94 fldcw 4(%esp)
95 addl $8, %esp
96 cfi_adjust_cfa_offset (-8)
5290baf0 97 fsubr %st, %st(1) // int(log2(e)*x) : fract(log2(e)*x)
6bc31da0
UD
98 fxch // fract(log2(e)*x) : int(log2(e)*x)
99 f2xm1 // 2^fract(log2(e)*x)-1 : int(log2(e)*x)
100 fscale // 2^(log2(e)*x)-2^int(log2(e)*x) : int(log2(e)*x)
101 fxch // int(log2(e)*x) : 2^(log2(e)*x)-2^int(log2(e)*x)
102 fldl MO(one) // 1 : int(log2(e)*x) : 2^(log2(e)*x)-2^int(log2(e)*x)
5290baf0
UD
103 fscale // 2^int(log2(e)*x) : int(log2(e)*x) : 2^(log2(e)*x)-2^int(log2(e)*x)
104 fsubrl MO(one) // 1-2^int(log2(e)*x) : int(log2(e)*x) : 2^(log2(e)*x)-2^int(log2(e)*x)
105 fstp %st(1) // 1-2^int(log2(e)*x) : 2^(log2(e)*x)-2^int(log2(e)*x)
106 fsubrp %st, %st(1) // 2^(log2(e)*x)
37825319 107 FLT_CHECK_FORCE_UFLOW
6bc31da0
UD
108 ret
109
f17ac40d 1102: fstp %st
0d8733c4 111 fldl MO(minus1) // Set result to -1.0.
6bc31da0
UD
1123: ret
113END(__expm1f)
e4602cba 114libm_alias_float (__expm1, expm1)