public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
From: Steve Ellcey <sellcey@mips.com>
To: "Joseph S. Myers" <joseph@codesourcery.com>,
	Carlos O'Donell	<carlos@redhat.com>
Cc: <libc-ports@sourceware.org>
Subject: Re: [PATCH] Speed up libm on MIPS
Date: Fri, 20 Sep 2013 16:51:00 -0000	[thread overview]
Message-ID: <1379695885.5770.463.camel@ubuntu-sellcey> (raw)
In-Reply-To: <523BC1B8.4040102@redhat.com>

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  <sellcey@mips.com>

	* 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.  */
 



  reply	other threads:[~2013-09-20 16:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-19 22:58 Steve Ellcey
2013-09-20  3:32 ` Carlos O'Donell
2013-09-20 16:51   ` Steve Ellcey [this message]
2013-09-20 17:06     ` Carlos O'Donell
2013-09-21 18:47       ` Maciej W. Rozycki
2013-09-22 17:40         ` Carlos O'Donell
2013-09-23 16:42           ` Steve Ellcey
2013-09-20 15:01 ` Richard Henderson
2013-09-20 15:35 ` Joseph S. Myers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1379695885.5770.463.camel@ubuntu-sellcey \
    --to=sellcey@mips.com \
    --cc=carlos@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=libc-ports@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).