about summary refs log tree commit diff
path: root/sysdeps/i386/fpu/e_powf.S
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/i386/fpu/e_powf.S')
-rw-r--r--sysdeps/i386/fpu/e_powf.S12
1 files changed, 11 insertions, 1 deletions
diff --git a/sysdeps/i386/fpu/e_powf.S b/sysdeps/i386/fpu/e_powf.S
index 89d30d8187..3735654a4e 100644
--- a/sysdeps/i386/fpu/e_powf.S
+++ b/sysdeps/i386/fpu/e_powf.S
@@ -129,12 +129,22 @@ ENTRY(__ieee754_powf)
 4:	fldl	MO(one)		// 1 : x
 	fxch
 
+	/* If y is even, take the absolute value of x.  Otherwise,
+	   ensure all intermediate values that might overflow have the
+	   sign of x.  */
+	testb	$1, %dl
+	jnz	6f
+	fabs
+
 6:	shrl	$1, %edx
 	jnc	5f
 	fxch
+	fabs
 	fmul	%st(1)		// x : ST*x
 	fxch
-5:	fmul	%st(0), %st	// x*x : ST*x
+5:	fld	%st		// x : x : ST*x
+	fabs			// |x| : x : ST*x
+	fmulp			// |x|*x : ST*x
 	testl	%edx, %edx
 	jnz	6b
 	fstp	%st(0)		// ST*x