mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-22 10:50:07 +00:00
Split mantissa calculation loop and add branch prediction
This commit is contained in:
parent
4d55b4e596
commit
44e0d4c20c
@ -1,5 +1,8 @@
|
|||||||
2013-01-02 Siddhesh Poyarekar <siddhesh@redhat.com>
|
2013-01-02 Siddhesh Poyarekar <siddhesh@redhat.com>
|
||||||
|
|
||||||
|
* sysdeps/ieee754/dbl-64/mpa.c (__mul): Split mantissa
|
||||||
|
calculation loop and add branch prediction.
|
||||||
|
|
||||||
* sysdeps/ieee754/dbl-64/mpexp.c (__mpexp): Add assert to
|
* sysdeps/ieee754/dbl-64/mpexp.c (__mpexp): Add assert to
|
||||||
check access beyond bounds of m1np.
|
check access beyond bounds of m1np.
|
||||||
|
|
||||||
|
@ -447,33 +447,52 @@ void
|
|||||||
SECTION
|
SECTION
|
||||||
__mul(const mp_no *x, const mp_no *y, mp_no *z, int p) {
|
__mul(const mp_no *x, const mp_no *y, mp_no *z, int p) {
|
||||||
|
|
||||||
int i, i1, i2, j, k, k2;
|
int i, j, k, k2;
|
||||||
double u;
|
double u;
|
||||||
|
|
||||||
/* Is z=0? */
|
/* Is z=0? */
|
||||||
if (X[0]*Y[0]==ZERO)
|
if (__glibc_unlikely (X[0] * Y[0] == ZERO))
|
||||||
{ Z[0]=ZERO; return; }
|
{
|
||||||
|
Z[0]=ZERO;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Multiply, add and carry */
|
/* Multiply, add and carry */
|
||||||
k2 = (p<3) ? p+p : p+3;
|
k2 = (__glibc_unlikely (p < 3)) ? p + p : p + 3;
|
||||||
Z[k2]=ZERO;
|
Z[k2] = ZERO;
|
||||||
for (k=k2; k>1; ) {
|
|
||||||
if (k > p) {i1=k-p; i2=p+1; }
|
|
||||||
else {i1=1; i2=k; }
|
|
||||||
for (i=i1,j=i2-1; i<i2; i++,j--) Z[k] += X[i]*Y[j];
|
|
||||||
|
|
||||||
u = (Z[k] + CUTTER)-CUTTER;
|
for (k = k2; k > p; )
|
||||||
if (u > Z[k]) u -= RADIX;
|
{
|
||||||
Z[k] -= u;
|
for (i = k - p, j = p; i < p + 1; i++, j--)
|
||||||
Z[--k] = u*RADIXI;
|
Z[k] += X[i] * Y[j];
|
||||||
}
|
|
||||||
|
|
||||||
/* Is there a carry beyond the most significant digit? */
|
u = (Z[k] + CUTTER) - CUTTER;
|
||||||
if (Z[1] == ZERO) {
|
if (u > Z[k])
|
||||||
for (i=1; i<=p; i++) Z[i]=Z[i+1];
|
u -= RADIX;
|
||||||
EZ = EX + EY - 1; }
|
Z[k] -= u;
|
||||||
else
|
Z[--k] = u * RADIXI;
|
||||||
EZ = EX + EY;
|
}
|
||||||
|
|
||||||
|
while (k > 1)
|
||||||
|
{
|
||||||
|
for (i = 1,j = k - 1; i < k; i++, j--)
|
||||||
|
Z[k] += X[i] * Y[j];
|
||||||
|
|
||||||
|
u = (Z[k] + CUTTER) - CUTTER;
|
||||||
|
if (u > Z[k])
|
||||||
|
u -= RADIX;
|
||||||
|
Z[k] -= u;
|
||||||
|
Z[--k] = u * RADIXI;
|
||||||
|
}
|
||||||
|
|
||||||
|
EZ = 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--;
|
||||||
|
}
|
||||||
|
|
||||||
Z[0] = X[0] * Y[0];
|
Z[0] = X[0] * Y[0];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user