This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Use intermediate variable to compute exponent in __muland __sqr
- From: Andreas Jaeger <aj at suse dot com>
- To: Siddhesh Poyarekar <siddhesh at redhat dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Fri, 15 Feb 2013 16:42:32 +0100
- Subject: Re: [PATCH] Use intermediate variable to compute exponent in __muland __sqr
- References: <20130214105356.GE11884@spoyarek.pnq.redhat.com>
On 02/14/2013 11:53 AM, Siddhesh Poyarekar wrote:
Hi,
Here's a tiny bit of optimization for __mul and __sqr that keeps the
values in a register during computation and then writes the result out
to EZ only once. This gives about a 1% boost in performance.
Verified that it does not cause regressions on x86_64. I've not
changed the ppc bits since I intend to post a separate patch to sync
up this part of code once this is in (and provided that the result is
positive for ppc as well).
OK to commit?
Siddhesh
* sysdeps/ieee754/dbl-64/mpa.c (__mul): Use intermediate
variable to calculate EZ.
(__sqr): Likewise.
diff --git a/sysdeps/ieee754/dbl-64/mpa.c b/sysdeps/ieee754/dbl-64/mpa.c
index a5aace7..bbe9648 100644
--- a/sysdeps/ieee754/dbl-64/mpa.c
+++ b/sysdeps/ieee754/dbl-64/mpa.c
@@ -737,15 +737,16 @@ __mul (const mp_no *x, const mp_no *y, mp_no *z, int p)
}
Z[k] = zk;
- EZ = EX + EY;
+ int e = EX + EY;
I think this kind of optimization needs a comment. Could you add one,
please?
The code itself is fine, thanks,
Andreas
/* Is there a carry beyond the most significant digit? */
if (__glibc_unlikely (Z[1] == ZERO))
{
for (i = 1; i <= p; i++)
Z[i] = Z[i + 1];
- EZ--;
+ e--;
}
+ EZ = e;
Z[0] = X[0] * Y[0];
}
@@ -830,14 +831,16 @@ __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;
}
/* Invert *X and store in *Y. Relative error bound:
--
Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126