]> sourceware.org Git - newlib-cygwin.git/commitdiff
newlib/libm/common: Don't re-convert float to bits in modf/modff
authorKeith Packard via Newlib <newlib@sourceware.org>
Thu, 26 Mar 2020 00:18:20 +0000 (17:18 -0700)
committerCorinna Vinschen <corinna@vinschen.de>
Thu, 26 Mar 2020 11:21:33 +0000 (12:21 +0100)
These functions shared a pattern of re-converting the argument to bits
when returning +/-0. Skip that as the initial conversion still has the
sign bit.

Signed-off-by: Keith Packard <keithp@keithp.com>
newlib/libm/common/s_modf.c
newlib/libm/common/sf_modf.c

index c826580b436298b44c0d0958825c787c5b7d930e..e552a9460ef9a621c558d7064c3bc8b91cfd1af5 100644 (file)
@@ -81,10 +81,8 @@ QUICKREF
            } else {
                i = (0x000fffff)>>j0;
                if(((i0&i)|i1)==0) {            /* x is integral */
-                   __uint32_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);
@@ -92,19 +90,15 @@ QUICKREF
                }
            }
        } else if (j0>51) {             /* no fraction part */
-           __uint32_t high;
            *iptr = x;
            if (__fpclassifyd(x) == FP_NAN) return *iptr = x+x; /* x is NaN, return NaN */
-           GET_HIGH_WORD(high,x);
-           INSERT_WORDS(x,high&0x80000000,0);  /* return +-0 */
+           INSERT_WORDS(x,i0&0x80000000,0);    /* return +-0 */
            return x;
        } else {                        /* fraction part in low x */
            i = ((__uint32_t)(0xffffffff))>>(j0-20);
            if((i1&i)==0) {             /* x is integral */
-               __uint32_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,i1&(~i));
index e241e46121778f79814ea2b2cd6451edd2c7d626..2994378bb8dc93aac169590d5e1b87a99173b19b 100644 (file)
            } else {
                i = (0x007fffff)>>j0;
                if((i0&i)==0) {                 /* x is integral */
-                   __uint32_t ix;
                    *iptr = x;
-                   GET_FLOAT_WORD(ix,x);
-                   SET_FLOAT_WORD(x,ix&0x80000000);    /* return +-0 */
+                   SET_FLOAT_WORD(x,i0&0x80000000);    /* return +-0 */
                    return x;
                } else {
                    SET_FLOAT_WORD(*iptr,i0&(~i));
                }
            }
        } else {                        /* no fraction part */
-           __uint32_t ix;
            *iptr = x;
            if (__fpclassifyf(x) == FP_NAN) return *iptr = x+x; /* x is NaN, return NaN */
-           GET_FLOAT_WORD(ix,x);
-           SET_FLOAT_WORD(x,ix&0x80000000);    /* return +-0 */
+           SET_FLOAT_WORD(x,i0&0x80000000);    /* return +-0 */
            return x;
        }
 }
This page took 0.032904 seconds and 5 git commands to generate.