diff options
author | Siddhesh Poyarekar <siddhesh@redhat.com> | 2013-01-14 21:36:58 +0530 |
---|---|---|
committer | Siddhesh Poyarekar <siddhesh@redhat.com> | 2013-01-14 21:53:48 +0530 |
commit | 2a91b5735ac1bc65ce5c2a3646d75ba7208e26e9 (patch) | |
tree | ad53b95348dcd3e65fbcd9176cddfdb07e6ec2e1 /sysdeps/ieee754/dbl-64/mpa.c | |
parent | 1066a53440d2744566e97c59bcd0d422186b3e90 (diff) | |
download | glibc-2a91b5735ac1bc65ce5c2a3646d75ba7208e26e9.tar glibc-2a91b5735ac1bc65ce5c2a3646d75ba7208e26e9.tar.gz glibc-2a91b5735ac1bc65ce5c2a3646d75ba7208e26e9.tar.bz2 glibc-2a91b5735ac1bc65ce5c2a3646d75ba7208e26e9.zip |
Minor tweak to mp multiplication
Add a local variable to remove extra copies to/from memory in the Z
array.
Diffstat (limited to 'sysdeps/ieee754/dbl-64/mpa.c')
-rw-r--r-- | sysdeps/ieee754/dbl-64/mpa.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/sysdeps/ieee754/dbl-64/mpa.c b/sysdeps/ieee754/dbl-64/mpa.c index b3bfa6c0fe..c882c8bc2c 100644 --- a/sysdeps/ieee754/dbl-64/mpa.c +++ b/sysdeps/ieee754/dbl-64/mpa.c @@ -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? */ |