about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2012-07-03 17:10:42 +0000
committerJoseph Myers <joseph@codesourcery.com>2012-07-03 17:11:41 +0000
commit7a845b2c237434d4aad790aaba3a973e24ea802f (patch)
tree16a6f0e49ff1b9b6a28f61fd16bb39821e2f54cf /sysdeps
parente2283f38febb8f1721f896680bed251ceef58a6b (diff)
downloadglibc-7a845b2c237434d4aad790aaba3a973e24ea802f.tar.gz
glibc-7a845b2c237434d4aad790aaba3a973e24ea802f.tar.xz
glibc-7a845b2c237434d4aad790aaba3a973e24ea802f.zip
Fix float range reduction problems (bug 14283).
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/i386/fpu/libm-test-ulps16
-rw-r--r--sysdeps/ieee754/flt-32/k_rem_pio2f.c37
2 files changed, 31 insertions, 22 deletions
diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps
index 38a69e670f..4661aea4ac 100644
--- a/sysdeps/i386/fpu/libm-test-ulps
+++ b/sysdeps/i386/fpu/libm-test-ulps
@@ -1656,8 +1656,8 @@ Test "j1 (0.75) == 0.349243602174862192523281016426251335":
 double: 1
 idouble: 1
 Test "j1 (0x1.3ffp+74) == 1.818984347516051243459364437186082741567e-12":
-float: 1
-ifloat: 1
+float: 2
+ifloat: 2
 ildouble: 1
 ldouble: 1
 Test "j1 (0x1.ff00000000002p+840) == 1.846591691699331493194965158699937660696e-127":
@@ -2359,8 +2359,8 @@ float: 1
 idouble: 1
 ifloat: 1
 Test "y0 (0x1.3ffp+74) == 1.818984347516051243459467456433028748678e-12":
-float: 1
-ifloat: 1
+float: 2
+ifloat: 2
 ildouble: 1
 ldouble: 1
 Test "y0 (0x1.ff00000000002p+840) == 1.846591691699331493194965158699937660696e-127":
@@ -2956,9 +2956,9 @@ ldouble: 2
 
 Function: "j1":
 double: 2
-float: 1
+float: 2
 idouble: 2
-ifloat: 1
+ifloat: 2
 ildouble: 1
 ldouble: 1
 
@@ -3128,9 +3128,9 @@ ldouble: 1
 
 Function: "y0":
 double: 2
-float: 1
+float: 2
 idouble: 2
-ifloat: 1
+ifloat: 2
 ildouble: 1
 ldouble: 1
 
diff --git a/sysdeps/ieee754/flt-32/k_rem_pio2f.c b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
index 06c2f378dc..e54a0677e4 100644
--- a/sysdeps/ieee754/flt-32/k_rem_pio2f.c
+++ b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
@@ -88,7 +88,7 @@ recompute:
 	    iq[jz-1] -= i<<(8-q0);
 	    ih = iq[jz-1]>>(7-q0);
 	} 
-	else if(q0==0) ih = iq[jz-1]>>8;
+	else if(q0==0) ih = iq[jz-1]>>7;
 	else if(z>=(float)0.5) ih=2;
 
 	if(ih>0) {	/* q > 0.5 */
@@ -166,24 +166,33 @@ recompute:
 		y[0] = (ih==0)? fw: -fw; 
 		break;
 	    case 1:
-	    case 2:
-		fw = 0.0;
-		for (i=jz;i>=0;i--) fw += fq[i]; 
-		y[0] = (ih==0)? fw: -fw; 
-		fw = fq[0]-fw;
-		for (i=1;i<=jz;i++) fw += fq[i];
-		y[1] = (ih==0)? fw: -fw; 
+	    case 2:;
+#if __FLT_EVAL_METHOD__ != 0
+		volatile
+#endif
+		float fv = 0.0;
+		for (i=jz;i>=0;i--) fv += fq[i];
+		y[0] = (ih==0)? fv: -fv;
+		fv = fq[0]-fv;
+		for (i=1;i<=jz;i++) fv += fq[i];
+		y[1] = (ih==0)? fv: -fv;
 		break;
 	    case 3:	/* painful */
 		for (i=jz;i>0;i--) {
-		    fw      = fq[i-1]+fq[i]; 
-		    fq[i]  += fq[i-1]-fw;
-		    fq[i-1] = fw;
+#if __FLT_EVAL_METHOD__ != 0
+		    volatile
+#endif
+		    float fv = fq[i-1]+fq[i];
+		    fq[i]  += fq[i-1]-fv;
+		    fq[i-1] = fv;
 		}
 		for (i=jz;i>1;i--) {
-		    fw      = fq[i-1]+fq[i]; 
-		    fq[i]  += fq[i-1]-fw;
-		    fq[i-1] = fw;
+#if __FLT_EVAL_METHOD__ != 0
+		    volatile
+#endif
+		    float fv = fq[i-1]+fq[i];
+		    fq[i]  += fq[i-1]-fv;
+		    fq[i-1] = fv;
 		}
 		for (fw=0.0,i=jz;i>=2;i--) fw += fq[i]; 
 		if(ih==0) {