This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Use intermediate variable to compute exponent in __mul and__sqr
- From: Siddhesh Poyarekar <siddhesh at redhat dot com>
- To: libc-alpha at sourceware dot org
- Date: Thu, 14 Feb 2013 16:23:56 +0530
- Subject: [PATCH] Use intermediate variable to compute exponent in __mul and__sqr
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;
/* 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: