about summary refs log tree commit diff
path: root/sysdeps/i386/fpu/e_exp2l.S
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/i386/fpu/e_exp2l.S')
-rw-r--r--sysdeps/i386/fpu/e_exp2l.S29
1 files changed, 28 insertions, 1 deletions
diff --git a/sysdeps/i386/fpu/e_exp2l.S b/sysdeps/i386/fpu/e_exp2l.S
index 2bf9a25727..9a5ff95a6c 100644
--- a/sysdeps/i386/fpu/e_exp2l.S
+++ b/sysdeps/i386/fpu/e_exp2l.S
@@ -6,7 +6,24 @@
 
 #include <machine/asm.h>
 
+	.section .rodata.cst16,"aM",@progbits,16
+	.p2align 4
+	.type ldbl_min,@object
+ldbl_min:	.byte 0, 0, 0, 0, 0, 0, 0, 0x80, 0x1, 0
+	.byte 0, 0, 0, 0, 0, 0
+	ASM_SIZE_DIRECTIVE(ldbl_min)
+
+#ifdef PIC
+# define MO(op) op##@GOTOFF(%ecx)
+#else
+# define MO(op) op
+#endif
+
+	.text
 ENTRY(__ieee754_exp2l)
+#ifdef PIC
+	LOAD_PIC_REG (cx)
+#endif
 	fldt	4(%esp)
 /* I added the following ugly construct because exp(+-Inf) resulted
    in NaN.  The ugliness results from the bright minds at Intel.
@@ -35,7 +52,17 @@ ENTRY(__ieee754_exp2l)
 	faddp				/* 2^(fract(x)) */
 	fscale				/* e^x */
 	fstp	%st(1)
-	ret
+	/* Ensure underflow for tiny result.  */
+	fldt	MO(ldbl_min)
+	fld	%st(1)
+	fucompp
+	fnstsw
+	sahf
+	jnc	4f
+	fld	%st
+	fmul	%st
+	fstp	%st
+4:	ret
 
 1:	testl	$0x200, %eax		/* Test sign.  */
 	jz	2f			/* If positive, jump.  */