[PATCH] Fix up __kernel_rem_pio2 for FLT_EVAL_METHOD != 0 architectures
Jakub Jelinek
jakub@redhat.com
Mon Aug 1 15:50:00 GMT 2011
Hi!
As mentioned in http://gcc.gnu.org/ml/gcc-patches/2011-08/msg00014.html
the loops for fq -> y conversion in __kernel_rem_pio2 rely on
FLT_EVAL_METHOD 0, so they may compute wrong values if architecture uses
excess precision. While prec 3 is only for IEEE quad and glibc doesn't use
that code in that case on i?86 as an example of FLT_EVAL_METHOD != 0
architecture, I think it doesn't hurt if the sources stay in sync.
2011-08-01 Jakub Jelinek <jakub@redhat.com>
* sysdeps/ieee754/dbl-64/k_rem_pio2.c (__kernel_rem_pio2): Fix up fq
to y conversion for prec 3 and __FLT_EVAL_METHOD__ != 0.
--- libc/sysdeps/ieee754/dbl-64/k_rem_pio2.c.jj 2009-05-16 19:23:38.000000000 +0200
+++ libc/sysdeps/ieee754/dbl-64/k_rem_pio2.c 2011-08-01 11:04:44.000000000 +0200
@@ -300,14 +300,20 @@ recompute:
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
+ double fv = (double)(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
+ double fv = (double)(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) {
Jakub
More information about the Libc-alpha
mailing list