From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2695 invoked by alias); 20 Sep 2013 16:51:32 -0000 Mailing-List: contact libc-ports-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: libc-ports-owner@sourceware.org Received: (qmail 2684 invoked by uid 89); 20 Sep 2013 16:51:32 -0000 Received: from multi.imgtec.com (HELO multi.imgtec.com) (194.200.65.239) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 20 Sep 2013 16:51:32 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,NO_RECEIVED,NO_RELAYS autolearn=ham version=3.3.2 X-HELO: multi.imgtec.com Message-ID: <1379695885.5770.463.camel@ubuntu-sellcey> Subject: Re: [PATCH] Speed up libm on MIPS From: Steve Ellcey To: "Joseph S. Myers" , Carlos O'Donell CC: Date: Fri, 20 Sep 2013 16:51:00 -0000 In-Reply-To: <523BC1B8.4040102@redhat.com> References: <1379631395.5770.445.camel@ubuntu-sellcey> <523BC1B8.4040102@redhat.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-SEF-Processed: 7_3_0_01192__2013_09_20_17_51_28 X-SW-Source: 2013-09/txt/msg00117.txt.bz2 On Thu, 2013-09-19 at 23:32 -0400, Carlos O'Donell wrote: > > + > > + /* Set rounding bits. */ > > + cw &= ~0x3; > > What's the magic ~0x3? Should it be a new macro? 0x3 is a mask to access the two bits in the FPU control register that define the rounding mode. It probably should be a macro and it seems like it should go into fpu_control.h where it could be used by the 'real' fegetround and fesetround as well these new routines. What do you think of this patch as a precursor to my original patch so that I can change all the code to use _FPU_RC_MASK instead of 0x3? Steve Ellcey sellcey@mips.com 2013-09-19 Steve Ellcey * sysdeps/mips/fpu_control.h (_FPU_RC_MASK): New. * sysdeps/mips/fpu/fegetround.c (fegetround): Use _FPU_RC_MASK. * sysdeps/mips/fpu/fesetround.c (fesetround): Use _FPU_RC_MASK. diff --git a/ports/sysdeps/mips/fpu/fegetround.c b/ports/sysdeps/mips/fpu/fegetround.c index 61217a7..17cd3e9 100644 --- a/ports/sysdeps/mips/fpu/fegetround.c +++ b/ports/sysdeps/mips/fpu/fegetround.c @@ -28,5 +28,5 @@ fegetround (void) /* Get control word. */ _FPU_GETCW (cw); - return cw & 0x3; + return cw & _FPU_RC_MASK; } diff --git a/ports/sysdeps/mips/fpu/fesetround.c b/ports/sysdeps/mips/fpu/fesetround.c index 7c25f43..c6fdd66 100644 --- a/ports/sysdeps/mips/fpu/fesetround.c +++ b/ports/sysdeps/mips/fpu/fesetround.c @@ -25,7 +25,7 @@ fesetround (int round) { fpu_control_t cw; - if ((round & ~0x3) != 0) + if ((round & ~_FPU_RC_MASK) != 0) /* ROUND is no valid rounding mode. */ return 1; @@ -33,7 +33,7 @@ fesetround (int round) _FPU_GETCW (cw); /* Set rounding bits. */ - cw &= ~0x3; + cw &= ~_FPU_RC_MASK; cw |= round; /* Set new state. */ _FPU_SETCW (cw); diff --git a/ports/sysdeps/mips/fpu_control.h b/ports/sysdeps/mips/fpu_control.h index 4046962..f26b736 100644 --- a/ports/sysdeps/mips/fpu_control.h +++ b/ports/sysdeps/mips/fpu_control.h @@ -90,6 +90,8 @@ extern fpu_control_t __fpu_control; #define _FPU_RC_ZERO 0x1 #define _FPU_RC_UP 0x2 #define _FPU_RC_DOWN 0x3 +/* mask for rounding control */ +#define _FPU_RC_MASK 0x3 #define _FPU_RESERVED 0xfe840000 /* Reserved bits in cw, incl NAN2008. */