mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-25 22:40:05 +00:00
Minor tweak to mp multiplication
Add a local variable to remove extra copies to/from memory in the Z array.
This commit is contained in:
parent
1066a53440
commit
2a91b5735a
@ -1,5 +1,8 @@
|
||||
2013-01-14 Siddhesh Poyarekar <siddhesh@redhat.com>
|
||||
|
||||
* sysdeps/ieee754/dbl-64/mpa.c (__mul): Add a local variable
|
||||
to optimize copies.
|
||||
|
||||
* sysdeps/ieee754/dbl-64/mpa.c: Fix formatting.
|
||||
* sysdeps/powerpc/powerpc32/power4/fpu/mpa.c: Likewise.
|
||||
* sysdeps/powerpc/powerpc64/power4/fpu/mpa.c: Likewise.
|
||||
|
@ -606,7 +606,7 @@ SECTION
|
||||
__mul (const mp_no *x, const mp_no *y, mp_no *z, int p)
|
||||
{
|
||||
int i, j, k, k2;
|
||||
double u;
|
||||
double u, zk;
|
||||
|
||||
/* Is z=0? */
|
||||
if (__glibc_unlikely (X[0] * Y[0] == ZERO))
|
||||
@ -617,31 +617,33 @@ __mul (const mp_no *x, const mp_no *y, mp_no *z, int p)
|
||||
|
||||
/* Multiply, add and carry. */
|
||||
k2 = (__glibc_unlikely (p < 3)) ? p + p : p + 3;
|
||||
Z[k2] = ZERO;
|
||||
zk = Z[k2] = ZERO;
|
||||
|
||||
for (k = k2; k > p;)
|
||||
for (k = k2; k > p; k--)
|
||||
{
|
||||
for (i = k - p, j = p; i < p + 1; i++, j--)
|
||||
Z[k] += X[i] * Y[j];
|
||||
zk += X[i] * Y[j];
|
||||
|
||||
u = (Z[k] + CUTTER) - CUTTER;
|
||||
if (u > Z[k])
|
||||
u = (zk + CUTTER) - CUTTER;
|
||||
if (u > zk)
|
||||
u -= RADIX;
|
||||
Z[k] -= u;
|
||||
Z[--k] = u * RADIXI;
|
||||
Z[k] = zk - u;
|
||||
zk = u * RADIXI;
|
||||
}
|
||||
|
||||
while (k > 1)
|
||||
{
|
||||
for (i = 1, j = k - 1; i < k; i++, j--)
|
||||
Z[k] += X[i] * Y[j];
|
||||
zk += X[i] * Y[j];
|
||||
|
||||
u = (Z[k] + CUTTER) - CUTTER;
|
||||
if (u > Z[k])
|
||||
u = (zk + CUTTER) - CUTTER;
|
||||
if (u > zk)
|
||||
u -= RADIX;
|
||||
Z[k] -= u;
|
||||
Z[--k] = u * RADIXI;
|
||||
Z[k] = zk - u;
|
||||
zk = u * RADIXI;
|
||||
k--;
|
||||
}
|
||||
Z[k] = zk;
|
||||
|
||||
EZ = EX + EY;
|
||||
/* Is there a carry beyond the most significant digit? */
|
||||
|
Loading…
Reference in New Issue
Block a user