From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from elaine.keithp.com (home.keithp.com [63.227.221.253]) by sourceware.org (Postfix) with ESMTPS id E15FC385E00C for ; Thu, 26 Mar 2020 00:18:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E15FC385E00C Received: from localhost (localhost [127.0.0.1]) by elaine.keithp.com (Postfix) with ESMTP id 010D13F2B6C7 for ; Wed, 25 Mar 2020 17:18:25 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at keithp.com Received: from elaine.keithp.com ([127.0.0.1]) by localhost (elaine.keithp.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id MO1FjRTT8c4V; Wed, 25 Mar 2020 17:18:24 -0700 (PDT) Received: from keithp.com (koto.keithp.com [10.0.0.2]) by elaine.keithp.com (Postfix) with ESMTPSA id 601833F2B63F; Wed, 25 Mar 2020 17:18:24 -0700 (PDT) Received: by keithp.com (Postfix, from userid 1000) id BCDCE158212B; Wed, 25 Mar 2020 17:18:23 -0700 (PDT) From: Keith Packard To: newlib@sourceware.org Subject: [PATCH 2/3] newlib/libm/common: Don't re-convert float to bits in modf/modff Date: Wed, 25 Mar 2020 17:18:20 -0700 Message-Id: <20200326001821.174426-3-keithp@keithp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200326001821.174426-1-keithp@keithp.com> References: <20200326001821.174426-1-keithp@keithp.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-26.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Mar 2020 00:18:27 -0000 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 --- 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; } } -- 2.25.1