This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[ping2][PATCH][ppc] Use intermediate var for exponent in __mul and__sqr
- From: Siddhesh Poyarekar <siddhesh at redhat dot com>
- To: libc-alpha at sourceware dot org
- Cc: rsa at us dot ibm dot com
- Date: Wed, 6 Mar 2013 15:43:18 +0530
- Subject: [ping2][PATCH][ppc] Use intermediate var for exponent in __mul and__sqr
- References: <20130221125721.GA6495@spoyarek.pnq.redhat.com><20130228060536.GE28148@spoyarek.pnq.redhat.com>
Ping!
On Thu, Feb 28, 2013 at 11:35:36AM +0530, Siddhesh Poyarekar wrote:
> Ping!
>
> On Thu, Feb 21, 2013 at 06:27:22PM +0530, Siddhesh Poyarekar wrote:
> > Hi,
> >
> > Attached patch uses an intermediate variable similar to the generic
> > code to calculate the exponent. In __mul the resulting code is a
> > little more compact since the earlier code resulted in two copies of
> > load instructions to load EX and EY. In __sqr the result is better
> > since an additional store is eliminated.
> >
> > OK to commit?
> >
> > Siddhesh
> >
> > * sysdeps/powerpc/powerpc32/power4/fpu/mpa.c (__mul): Use
> > intermediate variable to calculate exponent.
> > (__sqr): Likewise.
> > * sysdeps/powerpc/powerpc64/power4/fpu/mpa.c (__mul):
> > Likewise.
> > (__sqr): Likewise.
> >
> >
> > diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/mpa.c b/sysdeps/powerpc/powerpc32/power4/fpu/mpa.c
> > index ef7ada7..1858c97 100644
> > --- a/sysdeps/powerpc/powerpc32/power4/fpu/mpa.c
> > +++ b/sysdeps/powerpc/powerpc32/power4/fpu/mpa.c
> > @@ -99,16 +99,16 @@ __mul (const mp_no *x, const mp_no *y, mp_no *z, int p)
> > }
> > Z[k] = zk;
> >
> > + int e = EX + EY;
> > /* Is there a carry beyond the most significant digit? */
> > if (Z[1] == ZERO)
> > {
> > for (i = 1; i <= p2; i++)
> > Z[i] = Z[i + 1];
> > - EZ = EX + EY - 1;
> > + e--;
> > }
> > - else
> > - EZ = EX + EY;
> >
> > + EZ = e;
> > Z[0] = X[0] * Y[0];
> > }
> >
> > @@ -202,12 +202,13 @@ __sqr (const mp_no *x, mp_no *y, int p)
> > /* Squares are always positive. */
> > Y[0] = 1.0;
> >
> > - EY = 2 * EX;
> > + int e = EX * 2;
> > /* Is there a carry beyond the most significant digit? */
> > if (__glibc_unlikely (Y[1] == ZERO))
> > {
> > for (i = 1; i <= p; i++)
> > Y[i] = Y[i + 1];
> > - EY--;
> > + e--;
> > }
> > + EY = e;
> > }
> > diff --git a/sysdeps/powerpc/powerpc64/power4/fpu/mpa.c b/sysdeps/powerpc/powerpc64/power4/fpu/mpa.c
> > index ef7ada7..1858c97 100644
> > --- a/sysdeps/powerpc/powerpc64/power4/fpu/mpa.c
> > +++ b/sysdeps/powerpc/powerpc64/power4/fpu/mpa.c
> > @@ -99,16 +99,16 @@ __mul (const mp_no *x, const mp_no *y, mp_no *z, int p)
> > }
> > Z[k] = zk;
> >
> > + int e = EX + EY;
> > /* Is there a carry beyond the most significant digit? */
> > if (Z[1] == ZERO)
> > {
> > for (i = 1; i <= p2; i++)
> > Z[i] = Z[i + 1];
> > - EZ = EX + EY - 1;
> > + e--;
> > }
> > - else
> > - EZ = EX + EY;
> >
> > + EZ = e;
> > Z[0] = X[0] * Y[0];
> > }
> >
> > @@ -202,12 +202,13 @@ __sqr (const mp_no *x, mp_no *y, int p)
> > /* Squares are always positive. */
> > Y[0] = 1.0;
> >
> > - EY = 2 * EX;
> > + int e = EX * 2;
> > /* Is there a carry beyond the most significant digit? */
> > if (__glibc_unlikely (Y[1] == ZERO))
> > {
> > for (i = 1; i <= p; i++)
> > Y[i] = Y[i + 1];
> > - EY--;
> > + e--;
> > }
> > + EY = e;
> > }