This is the mail archive of the
libc-ports@sources.redhat.com
mailing list for the libc-ports project.
Re: [PATCH] Speed up libm on MIPS
- From: Steve Ellcey <sellcey at mips dot com>
- To: "Joseph S. Myers" <joseph at codesourcery dot com>, Carlos O'Donell <carlos at redhat dot com>
- Cc: <libc-ports at sourceware dot org>
- Date: Fri, 20 Sep 2013 09:51:25 -0700
- Subject: Re: [PATCH] Speed up libm on MIPS
- Authentication-results: sourceware.org; auth=none
- References: <1379631395 dot 5770 dot 445 dot camel at ubuntu-sellcey> <523BC1B8 dot 4040102 at redhat dot 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. */