]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Optimize code by avoiding unneeded access to FP number.
authorUlrich Drepper <drepper@redhat.com>
Thu, 20 Mar 1997 03:21:26 +0000 (03:21 +0000)
committerUlrich Drepper <drepper@redhat.com>
Thu, 20 Mar 1997 03:21:26 +0000 (03:21 +0000)
sysdeps/libm-ieee754/s_modf.c
sysdeps/libm-ieee754/s_modff.c

index 8075c5f81336d6de383d16da8e7879248af4586d..888d4f416db954598c9a2fc46b19677ca3d92f26 100644 (file)
@@ -51,10 +51,8 @@ static double one = 1.0;
            } else {
                i = (0x000fffff)>>j0;
                if(((i0&i)|i1)==0) {            /* x is integral */
-                   u_int32_t high;
                    *iptr = x;
-                   GET_HIGH_WORD(high,x);
-                   INSERT_WORDS(x,high&0x80000000,0);  /* return +-0 */
+                   INSERT_WORDS(x,i0&0x80000000,0);    /* return +-0 */
                    return x;
                } else {
                    INSERT_WORDS(*iptr,i0&(~i),0);
@@ -64,8 +62,10 @@ static double one = 1.0;
        } else if (j0>51) {             /* no fraction part */
            u_int32_t high;
            *iptr = x*one;
-           GET_HIGH_WORD(high,x);
-           INSERT_WORDS(x,high&0x80000000,0);  /* return +-0 */
+           /* We must handle NaNs separately.  */
+           if (j0 == 0x400 && ((i0 & 0xfffff) | i1))
+             return x*one;
+           INSERT_WORDS(x,i0&0x80000000,0);    /* return +-0 */
            return x;
        } else {                        /* fraction part in low x */
            i = ((u_int32_t)(0xffffffff))>>(j0-20);
index 85f22c10e59b2f0da65b7f3f04430ce707e98172..60f7f1ec29601633526ce29d400da8c998951b37 100644 (file)
@@ -8,7 +8,7 @@
  *
  * Developed at SunPro, a Sun Microsystems, Inc. business.
  * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
+ * software is freely granted, provided that this notice
  * is preserved.
  * ====================================================
  */
@@ -57,8 +57,10 @@ static float one = 1.0;
        } else {                        /* no fraction part */
            u_int32_t ix;
            *iptr = x*one;
-           GET_FLOAT_WORD(ix,x);
-           SET_FLOAT_WORD(x,ix&0x80000000);    /* return +-0 */
+           /* We must handle NaNs separately.  */
+           if (j0 == 0x80 && (i0 & 0x7fffff))
+             return x*one;
+           SET_FLOAT_WORD(x,i0&0x80000000);    /* return +-0 */
            return x;
        }
 }