summary refs log tree commit diff
path: root/sysdeps/i386/fpu
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/i386/fpu')
-rw-r--r--sysdeps/i386/fpu/e_log.S11
-rw-r--r--sysdeps/i386/fpu/e_logf.S11
-rw-r--r--sysdeps/i386/fpu/e_logl.S11
-rw-r--r--sysdeps/i386/fpu/e_pow.S18
-rw-r--r--sysdeps/i386/fpu/e_powf.S18
-rw-r--r--sysdeps/i386/fpu/e_powl.S18
-rw-r--r--sysdeps/i386/fpu/math_private.h18
-rw-r--r--sysdeps/i386/fpu/s_nextafterl.c18
-rw-r--r--sysdeps/i386/fpu/s_nexttoward.c25
-rw-r--r--sysdeps/i386/fpu/s_nexttowardf.c25
10 files changed, 60 insertions, 113 deletions
diff --git a/sysdeps/i386/fpu/e_log.S b/sysdeps/i386/fpu/e_log.S
index ce55b72292..5604e638f5 100644
--- a/sysdeps/i386/fpu/e_log.S
+++ b/sysdeps/i386/fpu/e_log.S
@@ -36,15 +36,11 @@ limit:	.double 0.29
 ENTRY(__ieee754_log)
 	fldln2			// log(2)
 	fldl	4(%esp)		// x : log(2)
-	fxam
-	fnstsw
 #ifdef PIC
 	LOAD_PIC_REG (dx)
 #endif
 	fld	%st		// x : x : log(2)
-	sahf
-	jc	3f		// in case x is NaN or +-Inf
-4:	fsubl	MO(one)		// x-1 : x : log(2)
+	fsubl	MO(one)		// x-1 : x : log(2)
 	fld	%st		// x-1 : x-1 : x : log(2)
 	fabs			// |x-1| : x-1 : x : log(2)
 	fcompl	MO(limit)	// x-1 : x : log(2)
@@ -58,9 +54,4 @@ ENTRY(__ieee754_log)
 2:	fstp	%st(0)		// x : log(2)
 	fyl2x			// log(x)
 	ret
-
-3:	jp	4b		// in case x is +-Inf
-	fstp	%st(1)
-	fstp	%st(1)
-	ret
 END (__ieee754_log)
diff --git a/sysdeps/i386/fpu/e_logf.S b/sysdeps/i386/fpu/e_logf.S
index cd4538b594..128bb2754c 100644
--- a/sysdeps/i386/fpu/e_logf.S
+++ b/sysdeps/i386/fpu/e_logf.S
@@ -37,15 +37,11 @@ limit:	.double 0.29
 ENTRY(__ieee754_logf)
 	fldln2			// log(2)
 	flds	4(%esp)		// x : log(2)
-	fxam
-	fnstsw
 #ifdef PIC
 	LOAD_PIC_REG (dx)
 #endif
 	fld	%st		// x : x : log(2)
-	sahf
-	jc	3f		// in case x is NaN or +-Inf
-4:	fsubl	MO(one)		// x-1 : x : log(2)
+	fsubl	MO(one)		// x-1 : x : log(2)
 	fld	%st		// x-1 : x-1 : x : log(2)
 	fabs			// |x-1| : x-1 : x : log(2)
 	fcompl	MO(limit)	// x-1 : x : log(2)
@@ -59,9 +55,4 @@ ENTRY(__ieee754_logf)
 2:	fstp	%st(0)		// x : log(2)
 	fyl2x			// log(x)
 	ret
-
-3:	jp	4b		// in case x is +-Inf
-	fstp	%st(1)
-	fstp	%st(1)
-	ret
 END (__ieee754_logf)
diff --git a/sysdeps/i386/fpu/e_logl.S b/sysdeps/i386/fpu/e_logl.S
index 551dcf1e46..5023d3012f 100644
--- a/sysdeps/i386/fpu/e_logl.S
+++ b/sysdeps/i386/fpu/e_logl.S
@@ -37,15 +37,11 @@ limit:	.double 0.29
 ENTRY(__ieee754_logl)
 	fldln2			// log(2)
 	fldt	4(%esp)		// x : log(2)
-	fxam
-	fnstsw
 #ifdef PIC
 	LOAD_PIC_REG (dx)
 #endif
 	fld	%st		// x : x : log(2)
-	sahf
-	jc	3f		// in case x is NaN or +-Inf
-4:	fsubl	MO(one)		// x-1 : x : log(2)
+	fsubl	MO(one)		// x-1 : x : log(2)
 	fld	%st		// x-1 : x-1 : x : log(2)
 	fabs			// |x-1| : x-1 : x : log(2)
 	fcompl	MO(limit)	// x-1 : x : log(2)
@@ -59,9 +55,4 @@ ENTRY(__ieee754_logl)
 2:	fstp	%st(0)		// x : log(2)
 	fyl2x			// log(x)
 	ret
-
-3:	jp	4b		// in case x is +-Inf
-	fstp	%st(1)
-	fstp	%st(1)
-	ret
 END (__ieee754_logl)
diff --git a/sysdeps/i386/fpu/e_pow.S b/sysdeps/i386/fpu/e_pow.S
index 792f926902..c554ca4ecb 100644
--- a/sysdeps/i386/fpu/e_pow.S
+++ b/sysdeps/i386/fpu/e_pow.S
@@ -1,5 +1,5 @@
 /* ix87 specific implementation of pow function.
-   Copyright (C) 1996, 1997, 1998, 1999, 2001, 2004, 2005, 2007
+   Copyright (C) 1996, 1997, 1998, 1999, 2001, 2004, 2005
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -161,11 +161,10 @@ ENTRY(__ieee754_pow)
 2:	/* y is a real number.  */
 	fxch			// x : y
 	fldl	MO(one)		// 1.0 : x : y
-	fldl	MO(limit)	// 0.29 : 1.0 : x : y
-	fld	%st(2)		// x : 0.29 : 1.0 : x : y
-	fsub	%st(2)		// x-1 : 0.29 : 1.0 : x : y
-	fabs			// |x-1| : 0.29 : 1.0 : x : y
-	fucompp			// 1.0 : x : y
+	fld	%st(1)		// x : 1.0 : x : y
+	fsub	%st(1)		// x-1 : 1.0 : x : y
+	fabs			// |x-1| : 1.0 : x : y
+	fcompl	MO(limit)	// 1.0 : x : y
 	fnstsw
 	fxch			// x : 1.0 : y
 	sahf
@@ -198,10 +197,9 @@ ENTRY(__ieee754_pow)
 	// y == ħinf
 	.align ALIGNARG(4)
 12:	fstp	%st(0)		// pop y
-	fldl	MO(one)		// 1
-	fldl	4(%esp)		// x : 1
-	fabs			// abs(x) : 1
-	fucompp			// < 1, == 1, or > 1
+	fldl	4(%esp)		// x
+	fabs
+	fcompl	MO(one)		// < 1, == 1, or > 1
 	fnstsw
 	andb	$0x45, %ah
 	cmpb	$0x45, %ah
diff --git a/sysdeps/i386/fpu/e_powf.S b/sysdeps/i386/fpu/e_powf.S
index c91545418d..c835b978b9 100644
--- a/sysdeps/i386/fpu/e_powf.S
+++ b/sysdeps/i386/fpu/e_powf.S
@@ -1,5 +1,5 @@
 /* ix87 specific implementation of pow function.
-   Copyright (C) 1996, 1997, 1999, 2001, 2004, 2005, 2007
+   Copyright (C) 1996, 1997, 1999, 2001, 2004, 2005
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -155,11 +155,10 @@ ENTRY(__ieee754_powf)
 2:	/* y is a real number.  */
 	fxch			// x : y
 	fldl	MO(one)		// 1.0 : x : y
-	fldl	MO(limit)	// 0.29 : 1.0 : x : y
-	fld	%st(2)		// x : 0.29 : 1.0 : x : y
-	fsub	%st(2)		// x-1 : 0.29 : 1.0 : x : y
-	fabs			// |x-1| : 0.29 : 1.0 : x : y
-	fucompp			// 1.0 : x : y
+	fld	%st(1)		// x : 1.0 : x : y
+	fsub	%st(1)		// x-1 : 1.0 : x : y
+	fabs			// |x-1| : 1.0 : x : y
+	fcompl	MO(limit)	// 1.0 : x : y
 	fnstsw
 	fxch			// x : 1.0 : y
 	sahf
@@ -192,10 +191,9 @@ ENTRY(__ieee754_powf)
 	// y == ħinf
 	.align ALIGNARG(4)
 12:	fstp	%st(0)		// pop y
-	fldl	MO(one)		// 1
-	flds	4(%esp)		// x : 1
-	fabs			// abs(x) : 1
-	fucompp			// < 1, == 1, or > 1
+	flds	4(%esp)		// x
+	fabs
+	fcompl	MO(one)		// < 1, == 1, or > 1
 	fnstsw
 	andb	$0x45, %ah
 	cmpb	$0x45, %ah
diff --git a/sysdeps/i386/fpu/e_powl.S b/sysdeps/i386/fpu/e_powl.S
index 6215496207..74f422816a 100644
--- a/sysdeps/i386/fpu/e_powl.S
+++ b/sysdeps/i386/fpu/e_powl.S
@@ -1,5 +1,5 @@
 /* ix87 specific implementation of pow function.
-   Copyright (C) 1996, 1997, 1998, 1999, 2001, 2004, 2005, 2007
+   Copyright (C) 1996, 1997, 1998, 1999, 2001, 2004, 2005
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -161,11 +161,10 @@ ENTRY(__ieee754_powl)
 2:	/* y is a real number.  */
 	fxch			// x : y
 	fldl	MO(one)		// 1.0 : x : y
-	fldl	MO(limit)	// 0.29 : 1.0 : x : y
-	fld	%st(2)		// x : 0.29 : 1.0 : x : y
-	fsub	%st(2)		// x-1 : 0.29 : 1.0 : x : y
-	fabs			// |x-1| : 0.29 : 1.0 : x : y
-	fucompp			// 1.0 : x : y
+	fld	%st(1)		// x : 1.0 : x : y
+	fsub	%st(1)		// x-1 : 1.0 : x : y
+	fabs			// |x-1| : 1.0 : x : y
+	fcompl	MO(limit)	// 1.0 : x : y
 	fnstsw
 	fxch			// x : 1.0 : y
 	sahf
@@ -211,10 +210,9 @@ ENTRY(__ieee754_powl)
 	// y == ħinf
 	.align ALIGNARG(4)
 12:	fstp	%st(0)		// pop y
-	fldl	MO(one)		// 1
-	fldt	4(%esp)		// x : 1
-	fabs			// abs(x) : 1
-	fucompp			// < 1, == 1, or > 1
+	fldt	4(%esp)		// x
+	fabs
+	fcompl	MO(one)		// < 1, == 1, or > 1
 	fnstsw
 	andb	$0x45, %ah
 	cmpb	$0x45, %ah
diff --git a/sysdeps/i386/fpu/math_private.h b/sysdeps/i386/fpu/math_private.h
deleted file mode 100644
index a426788ef1..0000000000
--- a/sysdeps/i386/fpu/math_private.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef _MATH_PRIVATE_H
-
-#define math_opt_barrier(x) \
-({ __typeof(x) __x;					\
-   __asm ("" : "=t" (__x) : "0" (x));			\
-   __x; })
-#define math_force_eval(x) \
-do							\
-  {							\
-    if (sizeof (x) <= sizeof (double))			\
-      __asm __volatile ("" : : "m" (x));		\
-    else						\
-      __asm __volatile ("" : : "f" (x));		\
-  }							\
-while (0)
-
-#include <math/math_private.h>
-#endif
diff --git a/sysdeps/i386/fpu/s_nextafterl.c b/sysdeps/i386/fpu/s_nextafterl.c
index aef0a144e5..5b617cb4e7 100644
--- a/sysdeps/i386/fpu/s_nextafterl.c
+++ b/sysdeps/i386/fpu/s_nextafterl.c
@@ -27,7 +27,7 @@ static char rcsid[] = "$NetBSD: $";
  */
 
 #include "math.h"
-#include <math_private.h>
+#include "math_private.h"
 
 #ifdef __STDC__
 	long double __nextafterl(long double x, long double y)
@@ -52,12 +52,9 @@ static char rcsid[] = "$NetBSD: $";
 	   return x+y;
 	if(x==y) return y;		/* x=y, return y */
 	if((ix|hx|lx)==0) {			/* x == 0 */
-	    long double u;
 	    SET_LDOUBLE_WORDS(x,esy&0x8000,0,1);/* return +-minsubnormal */
-	    u = math_opt_barrier (x);
-	    u = u * u;
-	    math_force_eval (u);		/* raise underflow flag */
-	    return x;
+	    y = x*x;
+	    if(y==x) return y; else return x;	/* raise underflow flag */
 	}
 	if(esx>=0) {			/* x > 0 */
 	    if(esx>esy||((esx==esy) && (hx>hy||((hx==hy)&&(lx>ly))))) {
@@ -112,9 +109,12 @@ static char rcsid[] = "$NetBSD: $";
 	}
 	esy = esx&0x7fff;
 	if(esy==0x7fff) return x+x;	/* overflow  */
-	if(esy==0) {
-	    long double u = x*x;		/* underflow */
-	    math_force_eval (u);		/* raise underflow flag */
+	if(esy==0) {			/* underflow */
+	    y = x*x;
+	    if(y!=x) {		/* raise underflow flag */
+	        SET_LDOUBLE_WORDS(y,esx,hx,lx);
+		return y;
+	    }
 	}
 	SET_LDOUBLE_WORDS(x,esx,hx,lx);
 	return x;
diff --git a/sysdeps/i386/fpu/s_nexttoward.c b/sysdeps/i386/fpu/s_nexttoward.c
index 9bd86a3724..2bd768e448 100644
--- a/sysdeps/i386/fpu/s_nexttoward.c
+++ b/sysdeps/i386/fpu/s_nexttoward.c
@@ -27,8 +27,7 @@ static char rcsid[] = "$NetBSD: $";
  */
 
 #include "math.h"
-#include <math_private.h>
-#include <float.h>
+#include "math_private.h"
 
 #ifdef __STDC__
 	double __nexttoward(double x, long double y)
@@ -53,12 +52,10 @@ static char rcsid[] = "$NetBSD: $";
 	   return x+y;
 	if((long double) x==y) return y;	/* x=y, return y */
 	if((ix|lx)==0) {			/* x == 0 */
-	    double u;
+	    double x2;
 	    INSERT_WORDS(x,(esy&0x8000)<<16,1); /* return +-minsub */
-	    u = math_opt_barrier (x);
-	    u = u * u;
-	    math_force_eval (u);		/* raise underflow flag */
-	    return x;
+	    x2 = x*x;
+	    if(x2==x) return x2; else return x;	/* raise underflow flag */
 	}
 	if(hx>=0) {				/* x > 0 */
 	    if (esy>=0x8000||((ix>>20)&0x7ff)>iy-0x3c00
@@ -88,14 +85,16 @@ static char rcsid[] = "$NetBSD: $";
 	hy = hx&0x7ff00000;
 	if(hy>=0x7ff00000) {
 	  x = x+x;	/* overflow  */
-	  if (FLT_EVAL_METHOD != 0 && FLT_EVAL_METHOD != 1)
-	    /* Force conversion to double.  */
-	    asm ("" : "+m"(x));
+	  /* Force conversion to double.  */
+	  asm ("" : "=m"(x) : "m"(x));
 	  return x;
 	}
-	if(hy<0x00100000) {
-	    double u = x*x;			/* underflow */
-	    math_force_eval (u);		/* raise underflow flag */
+	if(hy<0x00100000) {		/* underflow */
+	    double x2 = x*x;
+	    if(x2!=x) {		/* raise underflow flag */
+	        INSERT_WORDS(x2,hx,lx);
+		return x2;
+	    }
 	}
 	INSERT_WORDS(x,hx,lx);
 	return x;
diff --git a/sysdeps/i386/fpu/s_nexttowardf.c b/sysdeps/i386/fpu/s_nexttowardf.c
index 25f70e4f4d..3fbe53c338 100644
--- a/sysdeps/i386/fpu/s_nexttowardf.c
+++ b/sysdeps/i386/fpu/s_nexttowardf.c
@@ -19,8 +19,7 @@ static char rcsid[] = "$NetBSD: $";
 #endif
 
 #include "math.h"
-#include <math_private.h>
-#include <float.h>
+#include "math_private.h"
 
 #ifdef __STDC__
 	float __nexttowardf(float x, long double y)
@@ -45,12 +44,10 @@ static char rcsid[] = "$NetBSD: $";
 	   return x+y;
 	if((long double) x==y) return y;	/* x=y, return y */
 	if(ix==0) {				/* x == 0 */
-	    float u;
+	    float x2;
 	    SET_FLOAT_WORD(x,((esy&0x8000)<<16)|1);/* return +-minsub*/
-	    u = math_opt_barrier (x);
-	    u = u * u;
-	    math_force_eval (u);		/* raise underflow flag */
-	    return x;
+	    x2 = x*x;
+	    if(x2==x) return x2; else return x;	/* raise underflow flag */
 	}
 	if(hx>=0) {				/* x > 0 */
 	    if(esy>=0x8000||((ix>>23)&0xff)>iy-0x3f80
@@ -72,14 +69,16 @@ static char rcsid[] = "$NetBSD: $";
 	hy = hx&0x7f800000;
 	if(hy>=0x7f800000) {
 	  x = x+x;	/* overflow  */
-	  if (FLT_EVAL_METHOD != 0)
-	    /* Force conversion to float.  */
-	    asm ("" : "+m"(x));
+	  /* Force conversion to float.  */
+	  asm ("" : "=m"(x) : "m"(x));
 	  return x;
 	}
-	if(hy<0x00800000) {
-	    float u = x*x;			/* underflow */
-	    math_force_eval (u);		/* raise underflow flag */
+	if(hy<0x00800000) {		/* underflow */
+	    float x2 = x*x;
+	    if(x2!=x) {		/* raise underflow flag */
+	        SET_FLOAT_WORD(x2,hx);
+		return x2;
+	    }
 	}
 	SET_FLOAT_WORD(x,hx);
 	return x;