[PATCH] general soft-fp fixes for PPC32 long-double

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] general soft-fp fixes for PPC32 long-double

Steven Munroe
The attached patch fixes generic soft-fp bugs found during the long
double testing (bugz 2749).

This fix is a pre-req for the gcc-4.2 powerpc soft-fp support but common
to all soft-fp implementations.

As I understand it we need the soft-fp into the glibc upstream before we
can propagate the fixes to gcc, before David can submit the rest of the
gcc soft-fp fixes for gcc-4.2. We are running out of time for gcc-4.2.

Thanks.



2006-08-30  Steven Munroe  <[hidden email]>
            Joe Kerian  <[hidden email]>

        [BZ #2749]
        * soft-fp/op-common.h (_FP_OVERFLOW_SEMIRAW): Always set inexact
        and overflow for infinity.
        (_FP_PACK_SEMIRAW): Update comment.  Do not round if NaN.
        * soft-fp/op-4.h (__FP_FRAC_SUB_3, __FP_FRAC_SUB_4): Correct borrow
        handling for high words.

diff -urN libc24-cvstip-20060830/soft-fp/op-4.h libc24-ppc64-20060830/soft-fp/op-4.h
--- libc24-cvstip-20060830/soft-fp/op-4.h 2006-04-04 03:24:47.000000000 -0500
+++ libc24-ppc64-20060830/soft-fp/op-4.h 2006-09-14 14:55:09.000000000 -0500
@@ -564,7 +564,7 @@
     r1 = x1 - y1; \
     _c2 = r1 > x1; \
     r1 -= _c1; \
-    _c2 |= r1 > _c1; \
+    _c2 |= _c1 && (y1 == x1); \
     r2 = x2 - y2 - _c2; \
   } while (0)
 #endif
@@ -578,11 +578,11 @@
     r1 = x1 - y1; \
     _c2 = r1 > x1; \
     r1 -= _c1; \
-    _c2 |= r1 > _c1; \
+    _c2 |= _c1 && (y1 == x1); \
     r2 = x2 - y2; \
     _c3 = r2 > x2; \
     r2 -= _c2; \
-    _c3 |= r2 > _c2; \
+    _c3 |= _c2 && (y2 == x2); \
     r3 = x3 - y3 - _c3; \
   } while (0)
 #endif
diff -urN libc24-cvstip-20060830/soft-fp/op-common.h libc24-ppc64-20060830/soft-fp/op-common.h
--- libc24-cvstip-20060830/soft-fp/op-common.h 2006-04-04 03:24:47.000000000 -0500
+++ libc24-ppc64-20060830/soft-fp/op-common.h 2006-09-06 10:02:49.000000000 -0500
@@ -99,10 +99,10 @@
   else \
     { \
       X##_e = _FP_EXPMAX_##fs - 1; \
-      FP_SET_EXCEPTION(FP_EX_OVERFLOW); \
-      FP_SET_EXCEPTION(FP_EX_INEXACT); \
       _FP_FRAC_SET_##wc(X, _FP_MAXFRAC_##wc); \
     } \
+    FP_SET_EXCEPTION(FP_EX_INEXACT); \
+    FP_SET_EXCEPTION(FP_EX_OVERFLOW); \
 } while (0)
 
 /* Check for a semi-raw value being a signaling NaN and raise the
@@ -131,10 +131,12 @@
 
 /* Prepare to pack an fp value in semi-raw mode: the mantissa is
    rounded and shifted right, with the rounding possibly increasing
-   the exponent (including changing a finite value to infinity).  */
+   the exponent (including changing a finite value to infinity).
+   Be sure not to round NaNs.  */
 #define _FP_PACK_SEMIRAW(fs, wc, X) \
 do { \
-  _FP_ROUND(wc, X); \
+  if(X##_e != _FP_EXPMAX_##fs) \
+    _FP_ROUND(wc, X); \
   if (_FP_FRAC_HIGH_##fs(X) \
       & (_FP_OVERFLOW_##fs >> 1)) \
     { \