]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
* soft-fp/double.h (FP_CMP_UNORD_D): Also define in
authorRoland McGrath <roland@gnu.org>
Mon, 30 Jan 2006 22:27:31 +0000 (22:27 +0000)
committerRoland McGrath <roland@gnu.org>
Mon, 30 Jan 2006 22:27:31 +0000 (22:27 +0000)
[_FP_W_TYPE_SIZE >= 64] case.
* soft-fp/extended.h (FP_CMP_UNORD_E): Likewise.
* soft-fp/quad.h (FP_CMP_UNORD_Q): Likewise.

ChangeLog
math/libm-test.inc
soft-fp/double.h
soft-fp/extended.h
soft-fp/quad.h
sysdeps/powerpc/fpu/libm-test-ulps
sysdeps/powerpc/powerpc64/fpu/s_ceill.S
sysdeps/powerpc/powerpc64/fpu/s_llroundl.S

index bfcdc51a754ccd22ea2f0605a9decfd3ded24842..1b7b074b5ef475d23b48dfd354dd006f562ee9e0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-01-29  Joseph S. Myers  <joseph@codesourcery.com>
+
+       * soft-fp/double.h (FP_CMP_UNORD_D): Also define in
+       [_FP_W_TYPE_SIZE >= 64] case.
+       * soft-fp/extended.h (FP_CMP_UNORD_E): Likewise.
+       * soft-fp/quad.h (FP_CMP_UNORD_Q): Likewise.
+
 2006-01-27  Dwayne Grant McConnell  <decimal@us.ibm.com>
            Jakub Jelinek  <jakub@redhat.com>
            Roland McGrath  <roland@redhat.com>
index 3d72bbfb296b2e3827f0d3ab3c5388a2d9be2350..953459672549c92da45f02b343442bceacb69b72 100644 (file)
@@ -3566,6 +3566,13 @@ llround_test (void)
   TEST_f_L (llround, -72057594037927936.5L, -72057594037927937LL);
   TEST_f_L (llround, -72057594037927936.75L, -72057594037927937LL);
   TEST_f_L (llround, -72057594037927937.5L, -72057594037927938LL);
+
+  TEST_f_L (llround, 9223372036854775806.25L, 9223372036854775806LL);
+  TEST_f_L (llround, -9223372036854775806.25L, -9223372036854775806LL);
+  TEST_f_L (llround, 9223372036854775806.5L, 9223372036854775807LL);
+  TEST_f_L (llround, -9223372036854775806.5L, -9223372036854775807LL);
+  TEST_f_L (llround, 9223372036854775807.0L, 9223372036854775807LL);
+  TEST_f_L (llround, -9223372036854775807.0L, -9223372036854775807LL);
 #endif
 
   END (llround);
index 77d439b4660adaf0cf87157d5524d5151be3845f..4d66c8d4577d21ea96cd26c0829e3d99f21600f6 100644 (file)
@@ -188,6 +188,7 @@ union _FP_UNION_D
 
 #define FP_CMP_D(r,X,Y,un)     _FP_CMP(D,1,r,X,Y,un)
 #define FP_CMP_EQ_D(r,X,Y)     _FP_CMP_EQ(D,1,r,X,Y)
+#define FP_CMP_UNORD_D(r,X,Y)  _FP_CMP_UNORD(D,1,r,X,Y)
 
 #define FP_TO_INT_D(r,X,rsz,rsg)       _FP_TO_INT(D,1,r,X,rsz,rsg)
 #define FP_FROM_INT_D(X,r,rs,rt)       _FP_FROM_INT(D,1,X,r,rs,rt)
index a1f54ccceb0acbb42120204b7e2134bdde5393fe..d34df5d0cef06ba1e3fd68bf10c9721ecc91abc5 100644 (file)
@@ -379,6 +379,7 @@ union _FP_UNION_E
  
 #define FP_CMP_E(r,X,Y,un)     _FP_CMP(E,2,r,X,Y,un)
 #define FP_CMP_EQ_E(r,X,Y)     _FP_CMP_EQ(E,2,r,X,Y)
+#define FP_CMP_UNORD_E(r,X,Y)  _FP_CMP_UNORD(E,2,r,X,Y)
 
 #define FP_TO_INT_E(r,X,rsz,rsg)       _FP_TO_INT(E,2,r,X,rsz,rsg)
 #define FP_FROM_INT_E(X,r,rs,rt)       _FP_FROM_INT(E,2,X,r,rs,rt)
index b03063bc0544824b0998caad68d8261c63a9020e..c1dccc49a157fd650529c55adb027899d70d7adb 100644 (file)
@@ -195,6 +195,7 @@ union _FP_UNION_Q
 
 #define FP_CMP_Q(r,X,Y,un)     _FP_CMP(Q,2,r,X,Y,un)
 #define FP_CMP_EQ_Q(r,X,Y)     _FP_CMP_EQ(Q,2,r,X,Y)
+#define FP_CMP_UNORD_Q(r,X,Y)  _FP_CMP_UNORD(Q,2,r,X,Y)
 
 #define FP_TO_INT_Q(r,X,rsz,rsg)       _FP_TO_INT(Q,2,r,X,rsz,rsg)
 #define FP_FROM_INT_Q(X,r,rs,rt)       _FP_FROM_INT(Q,2,X,r,rs,rt)
index 46c7666250963f43823f5f25fb7ebdebb5316d5b..1005421ec01ac99b8aced3840da406a7c54d066a 100644 (file)
@@ -623,38 +623,6 @@ ifloat: 2
 ildouble: 3
 ldouble: 3
 
-# llround
-Test "llround (4503599627370496.5) == 4503599627370497LL":
-ildouble: -1
-ldouble: -1
-Test "llround (4503599627370497.5) == 4503599627370498LL":
-ildouble: -1
-ldouble: -1
-Test "llround (72057594037927935.5) == 72057594037927936LL":
-ildouble: -1
-ldouble: -1
-Test "llround (72057594037927936.5) == 72057594037927937LL":
-ildouble: -1
-ldouble: -1
-Test "llround (72057594037927936.75) == 72057594037927937LL":
-ildouble: -1
-ldouble: -1
-Test "llround (72057594037927937.5) == 72057594037927938LL":
-ildouble: -1
-ldouble: -1
-Test "llround (9007199254740991.5) == 9007199254740992LL":
-ildouble: -1
-ldouble: -1
-Test "llround (9007199254740992.5) == 9007199254740993LL":
-ildouble: -1
-ldouble: -1
-Test "llround (9007199254740992.75) == 9007199254740993LL":
-ildouble: -1
-ldouble: -1
-Test "llround (9007199254740993.5) == 9007199254740994LL":
-ildouble: -1
-ldouble: -1
-
 # log10
 Test "log10 (0.75) == -0.124938736608299953132449886193870744":
 double: 1
index e164fec62b7953704766304a5cdfe4c02f807829..a8f8a0afc50ab4acf4183fe3334792c0ba327045 100644 (file)
@@ -51,7 +51,7 @@ ENTRY (__ceill)
        fabs    fp9,fp2
        fsub    fp12,fp13,fp13  /* generate 0.0  */
        fcmpu   cr7,fp0,fp13    /* if (fabs(x) > TWO52)  */
-       fcmpo   cr6,fp1,fp12    /* if (x > 0.0)  */
+       fcmpu   cr6,fp1,fp12    /* if (x > 0.0)  */
        bnl-    cr7,.L2
        mtfsfi  7,2             /* Set rounding mode toward +inf.  */
        fneg    fp2,fp12
index b7aeb394f7b53ab90f24119f547d4a724378612d..29eca11093f31165a6c322d3ad98dae7c8199127 100644 (file)
    */
 
 ENTRY (__llroundl)
+       mffs    fp7             /* Save current FPU rounding mode.  */
        fabs    fp0,fp1
        lfd     fp13,.LC2@toc(2)        /* 2**52 */
        lfd     fp12,.LC3@toc(2)        /* 2**63 */
        lfd     fp11,.LC0@toc(2)        /* 0.0 */
        lfd     fp10,.LC1@toc(2)        /* 0.5 */
-       fcmpu   cr0,fp0,fp12            /* if (x < TWO63 */
-       fcmpu   cr7,fp0,fp13            /* if (x < TWO52 */
-       fcmpu   cr6,fp1,fp11            /* if (x > 0.0)  */
-       bge-    cr0,.L2
-       bge-    cr7,.L8
-       ble-    cr6,.L4
-       fadd    fp4,fp2,fp10            /* x+= 0.5;  */
-       fadd    fp5,fp1,fp4             /* x+= 0.5;  */
-.L9:
-       fctidz  fp3,fp5         /* Convert To Integer DW llround toward 0.  */
-       stfd    fp3,-16(r1)
+       fabs    fp9,fp2
+       fcmpu   cr7,fp0,fp13    /* if (fabs(x) > TWO52)  */
+       fcmpu   cr6,fp1,fp11    /* if (x > 0.0)  */
+       bnl-    cr7,.L2
+       mtfsfi  7,1             /* Set rounding mode toward 0.  */
+       ble-    cr6,.L1
+       fadd    fp9,fp1,fp10    /* x+= 0.5;  */
+       b       .L0
+.L1:
+       fsub    fp9,fp1,fp10    /* x-= 0.5;  */
+.L0:
+       fctid   fp0,fp9
+       stfd    fp0,-16(r1)
+       mtfsf   0x01,fp7        /* restore previous rounding mode.  */
        nop     /* Insure the following load is in a different dispatch group */
        nop     /* to avoid pipe stall on POWER4&5.  */
        nop
        ld      r3,-16(r1)
        blr
-.L4:
-       fsub    fp4,fp2,fp10    /* x-= 0.5;  */
-       fadd    fp5,fp1,fp4             /* x+= 0.5;  */
-       b       .L9
-.L8:
-       ble     cr6,.L6
-       fneg    fp10,fp10
-.L6:
-       fadd    fp2,fp2,fp10
-       fctidz  fp3,fp1         /* Convert To Integer DW llround toward 0.  */
-       fctidz  fp4,fp2         /* Convert To Integer DW llround toward 0.  */
-       stfd    fp3,-16(r1)
-       stfd    fp4,-8(r1)
-       nop     /* Insure the following load is in a different dispatch group */
-       nop     /* to avoid pipe stall on POWER4&5.  */
-       nop
-       ld      r3,-16(r1)
-       ld      r0,-8(r1)
-       add     r3,r3,r0
-       blr
-.L2:
-/* The high double is >= TWO63 so it looks like we are "out of range".
-   But this may be caused by rounding of the high double and the
-   negative low double may bring it back into range. So we need to
-   de-round the high double and invert the low double without changing
-   the effective long double value. To do this we compute a special
-   value (tau) that we can subtract from the high double and add to
-   the low double before conversion. The resulting integers can be
-   summed to get the total value.
 
-   tau = floor(x_high/TWO52);
+/* The high double is > TWO52 so we need to round the low double and
+   perhaps the high double.  In this case we have to round the low
+   double and handle any adjustment to the high double that may be
+   caused by rounding (up).  This is complicated by the fact that the
+   high double may already be rounded and the low double may have the
+   opposite sign to compensate.This gets a bit tricky so we use the
+   following algorithm:
+
+   tau = trunc(x_high/TWO52);
    x0 = x_high - tau;
-   x1 = x_low + tau;  */
+   x1 = x_low + tau;
+   r1 = round(x1);
+   y_high = x0 + r1;
+   y_low = x0 - y_high + r1;
+   return y;  */
 .L2:
+       fcmpu   cr7,fp0,fp12    /* if (|x_high| > TWO63)  */
+       fcmpu   cr0,fp9,fp11    /* || (|x_low| == 0.0)  */
+       fmr     fp9,fp1
+       fcmpu   cr5,fp2,fp11    /* if (x_low > 0.0)  */
+       bgt-    cr7,.L0         /*   return llround(x); */
+       mtfsfi  7,1             /* Set rounding mode toward 0.  */
        fdiv    fp8,fp1,fp13    /* x_high/TWO52  */
-       bgt-    cr0,.L9         /* if x > TWO63  */
+       
+       bng-    cr6,.L6         /* if (x > 0.0)  */
+       fctidz  fp0,fp8
+       fcfid   fp8,fp0         /* tau = trunc(x_high/TWO52);  */
+       bng     cr5,.L4         /* if (x_low > 0.0)  */
+       fmr     fp3,fp1
+       fmr     fp4,fp2
+       b       .L5
+.L4:                           /* if (x_low < 0.0)  */
+       fsub    fp3,fp1,fp8     /* x0 = x_high - tau;  */
+       fadd    fp4,fp2,fp8     /* x1 = x_low + tau;  */
+.L5:
+       fadd    fp5,fp4,fp10    /* r1 = x1 + 0.5;  */
+       b       .L9
+.L6:                           /* if (x < 0.0)  */
        fctidz  fp0,fp8
-       fcfid   fp8,fp0         /* tau = floor(x_high/TWO52);  */
+       fcfid   fp8,fp0         /* tau = trunc(x_high/TWO52);  */       
+       bnl     cr5,.L7         /* if (x_low < 0.0)  */
+       fmr     fp3,fp1
+       fmr     fp4,fp2
+       b       .L8
+.L7:                           /* if (x_low > 0.0)  */
        fsub    fp3,fp1,fp8     /* x0 = x_high - tau;  */
        fadd    fp4,fp2,fp8     /* x1 = x_low + tau;  */
-       fctid   fp11,fp3
-       fctid   fp12,fp4
+.L8:
+       fsub    fp5,fp4,fp10    /* r1 = x1 - 0.5;  */
+.L9:
+       fctid.  fp11,fp3
+       fctid   fp12,fp5
        stfd    fp11,-16(r1)
        stfd    fp12,-8(r1)
+       mtfsf   0x01,fp7        /* restore previous rounding mode.  */
        nop     /* Insure the following load is in a different dispatch group */
        nop     /* to avoid pipe stall on POWER4&5.  */
        nop
        ld      r3,-16(r1)
+       bunlr   cr1             /* if not overflow, return.  */
        ld      r0,-8(r1)
        addo.   r3,r3,r0
-       bnslr+  cr0             /* if the sum does not overflow, return.  */
-       b       .L9             /* Otherwise we want to set "invalid operation".  */
+       bnslr   cr0
+       fmr     fp9,fp12
+       bng     cr6,.L0
+       fneg    fp9,fp12
+       b       .L0
 END (__llroundl)
 
 strong_alias (__llroundl, __lroundl)