From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 7A0EC385E025; Thu, 26 Mar 2020 11:42:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7A0EC385E025 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] newlib/libm/common: Don't re-convert float to bits in modf/modff X-Act-Checkin: newlib-cygwin X-Git-Author: Keith Packard via Newlib X-Git-Refname: refs/heads/master X-Git-Oldrev: 61cd34c1bfab626c084fd4289657b8f1ac43a138 X-Git-Newrev: 3439f3b0e998fd59f4ed277bb0c05bf24d7dc831 Message-Id: <20200326114242.7A0EC385E025@sourceware.org> Date: Thu, 26 Mar 2020 11:42:42 +0000 (GMT) X-BeenThere: newlib-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib GIT logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Mar 2020 11:42:42 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=3439f3b0e998fd59f4ed277bb0c05bf24d7dc831 commit 3439f3b0e998fd59f4ed277bb0c05bf24d7dc831 Author: Keith Packard via Newlib Date: Wed Mar 25 17:18:20 2020 -0700 newlib/libm/common: Don't re-convert float to bits in modf/modff 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 Diff: --- newlib/libm/common/s_modf.c | 12 +++--------- newlib/libm/common/sf_modf.c | 8 ++------ 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/newlib/libm/common/s_modf.c b/newlib/libm/common/s_modf.c index c826580b4..e552a9460 100644 --- a/newlib/libm/common/s_modf.c +++ b/newlib/libm/common/s_modf.c @@ -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)); diff --git a/newlib/libm/common/sf_modf.c b/newlib/libm/common/sf_modf.c index e241e4612..2994378bb 100644 --- a/newlib/libm/common/sf_modf.c +++ b/newlib/libm/common/sf_modf.c @@ -33,10 +33,8 @@ } 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)); @@ -44,11 +42,9 @@ } } } 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; } }