29e444
From 66bf22e129f0b8621903a8b0489b2684e70fad65 Mon Sep 17 00:00:00 2001
29e444
From: Siddhesh Poyarekar <siddhesh@redhat.com>
29e444
Date: Fri, 8 Mar 2013 11:38:41 +0530
29e444
Subject: [PATCH 17/42] Consolidate copies of mp code in powerpc
29e444
29e444
Retain a single copy of the mp code in power4 instead of the two
29e444
identical copies in powerpc32 and powerpc64.
29e444
(backported from commit 6d9145d817e570cd986bb088cf2af0bf51ac7dde)
29e444
---
29e444
 sysdeps/powerpc/power4/fpu/Makefile           |   5 +
29e444
 sysdeps/powerpc/power4/fpu/mpa.c              | 548 ++++++++++++++++++++++++++
29e444
 sysdeps/powerpc/powerpc32/power4/Implies      |   2 +
29e444
 sysdeps/powerpc/powerpc32/power4/fpu/Makefile |   5 -
29e444
 sysdeps/powerpc/powerpc32/power4/fpu/mpa.c    | 548 --------------------------
29e444
 sysdeps/powerpc/powerpc64/power4/Implies      |   2 +
29e444
 sysdeps/powerpc/powerpc64/power4/fpu/Makefile |   5 -
29e444
 sysdeps/powerpc/powerpc64/power4/fpu/mpa.c    | 548 --------------------------
29e444
 9 files changed, 568 insertions(+), 1106 deletions(-)
29e444
 create mode 100644 sysdeps/powerpc/power4/fpu/Makefile
29e444
 create mode 100644 sysdeps/powerpc/power4/fpu/mpa.c
29e444
 create mode 100644 sysdeps/powerpc/powerpc32/power4/Implies
29e444
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/Makefile
29e444
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/mpa.c
29e444
 create mode 100644 sysdeps/powerpc/powerpc64/power4/Implies
29e444
 delete mode 100644 sysdeps/powerpc/powerpc64/power4/fpu/Makefile
29e444
 delete mode 100644 sysdeps/powerpc/powerpc64/power4/fpu/mpa.c
29e444
29e444
diff --git a/sysdeps/powerpc/power4/fpu/Makefile b/sysdeps/powerpc/power4/fpu/Makefile
29e444
new file mode 100644
29e444
index 0000000..f487ed6
29e444
--- /dev/null
29e444
+++ b/sysdeps/powerpc/power4/fpu/Makefile
29e444
@@ -0,0 +1,5 @@
29e444
+# Makefile fragment for POWER4/5/5+ with FPU.
29e444
+
29e444
+ifeq ($(subdir),math)
29e444
+CFLAGS-mpa.c += --param max-unroll-times=4 -funroll-loops -fpeel-loops
29e444
+endif
29e444
diff --git a/sysdeps/powerpc/power4/fpu/mpa.c b/sysdeps/powerpc/power4/fpu/mpa.c
29e444
new file mode 100644
29e444
index 0000000..d15680e
29e444
--- /dev/null
29e444
+++ b/sysdeps/powerpc/power4/fpu/mpa.c
29e444
@@ -0,0 +1,548 @@
29e444
+
29e444
+/*
29e444
+ * IBM Accurate Mathematical Library
29e444
+ * written by International Business Machines Corp.
29e444
+ * Copyright (C) 2001, 2006 Free Software Foundation
29e444
+ *
29e444
+ * This program is free software; you can redistribute it and/or modify
29e444
+ * it under the terms of the GNU Lesser General Public License as published by
29e444
+ * the Free Software Foundation; either version 2.1 of the License, or
29e444
+ * (at your option) any later version.
29e444
+ *
29e444
+ * This program is distributed in the hope that it will be useful,
29e444
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
29e444
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29e444
+ * GNU Lesser General Public License for more details.
29e444
+ *
29e444
+ * You should have received a copy of the GNU Lesser General Public License
29e444
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
29e444
+ */
29e444
+/************************************************************************/
29e444
+/*  MODULE_NAME: mpa.c                                                  */
29e444
+/*                                                                      */
29e444
+/*  FUNCTIONS:                                                          */
29e444
+/*               mcr                                                    */
29e444
+/*               acr                                                    */
29e444
+/*               cr                                                     */
29e444
+/*               cpy                                                    */
29e444
+/*               cpymn                                                  */
29e444
+/*               norm                                                   */
29e444
+/*               denorm                                                 */
29e444
+/*               mp_dbl                                                 */
29e444
+/*               dbl_mp                                                 */
29e444
+/*               add_magnitudes                                         */
29e444
+/*               sub_magnitudes                                         */
29e444
+/*               add                                                    */
29e444
+/*               sub                                                    */
29e444
+/*               mul                                                    */
29e444
+/*               inv                                                    */
29e444
+/*               dvd                                                    */
29e444
+/*                                                                      */
29e444
+/* Arithmetic functions for multiple precision numbers.                 */
29e444
+/* Relative errors are bounded                                          */
29e444
+/************************************************************************/
29e444
+
29e444
+
29e444
+#include "endian.h"
29e444
+#include "mpa.h"
29e444
+#include "mpa2.h"
29e444
+#include <sys/param.h>	/* For MIN() */
29e444
+/* mcr() compares the sizes of the mantissas of two multiple precision  */
29e444
+/* numbers. Mantissas are compared regardless of the signs of the       */
29e444
+/* numbers, even if x->d[0] or y->d[0] are zero. Exponents are also     */
29e444
+/* disregarded.                                                         */
29e444
+static int mcr(const mp_no *x, const mp_no *y, int p) {
29e444
+  long i;
29e444
+  long p2 = p;
29e444
+  for (i=1; i<=p2; i++) {
29e444
+    if      (X[i] == Y[i])  continue;
29e444
+    else if (X[i] >  Y[i])  return  1;
29e444
+    else                    return -1; }
29e444
+  return 0;
29e444
+}
29e444
+
29e444
+
29e444
+
29e444
+/* acr() compares the absolute values of two multiple precision numbers */
29e444
+int __acr(const mp_no *x, const mp_no *y, int p) {
29e444
+  long i;
29e444
+
29e444
+  if      (X[0] == ZERO) {
29e444
+    if    (Y[0] == ZERO) i= 0;
29e444
+    else                 i=-1;
29e444
+  }
29e444
+  else if (Y[0] == ZERO) i= 1;
29e444
+  else {
29e444
+    if      (EX >  EY)   i= 1;
29e444
+    else if (EX <  EY)   i=-1;
29e444
+    else                 i= mcr(x,y,p);
29e444
+  }
29e444
+
29e444
+  return i;
29e444
+}
29e444
+
29e444
+
29e444
+/* cr90 compares the values of two multiple precision numbers           */
29e444
+int  __cr(const mp_no *x, const mp_no *y, int p) {
29e444
+  int i;
29e444
+
29e444
+  if      (X[0] > Y[0])  i= 1;
29e444
+  else if (X[0] < Y[0])  i=-1;
29e444
+  else if (X[0] < ZERO ) i= __acr(y,x,p);
29e444
+  else                   i= __acr(x,y,p);
29e444
+
29e444
+  return i;
29e444
+}
29e444
+
29e444
+
29e444
+/* Copy a multiple precision number. Set *y=*x. x=y is permissible.      */
29e444
+void __cpy(const mp_no *x, mp_no *y, int p) {
29e444
+  long i;
29e444
+
29e444
+  EY = EX;
29e444
+  for (i=0; i <= p; i++)    Y[i] = X[i];
29e444
+
29e444
+  return;
29e444
+}
29e444
+
29e444
+
29e444
+/* Copy a multiple precision number x of precision m into a */
29e444
+/* multiple precision number y of precision n. In case n>m, */
29e444
+/* the digits of y beyond the m'th are set to zero. In case */
29e444
+/* n
29e444
+/* x=y is permissible.                                      */
29e444
+
29e444
+void __cpymn(const mp_no *x, int m, mp_no *y, int n) {
29e444
+
29e444
+  long i,k;
29e444
+  long n2 = n;
29e444
+  long m2 = m;
29e444
+
29e444
+  EY = EX;     k=MIN(m2,n2);
29e444
+  for (i=0; i <= k; i++)    Y[i] = X[i];
29e444
+  for (   ; i <= n2; i++)    Y[i] = ZERO;
29e444
+
29e444
+  return;
29e444
+}
29e444
+
29e444
+/* Convert a multiple precision number *x into a double precision */
29e444
+/* number *y, normalized case  (|x| >= 2**(-1022))) */
29e444
+static void norm(const mp_no *x, double *y, int p)
29e444
+{
29e444
+  #define R  radixi.d
29e444
+  long i;
29e444
+#if 0
29e444
+  int k;
29e444
+#endif
29e444
+  double a,c,u,v,z[5];
29e444
+  if (p<5) {
29e444
+    if      (p==1) c = X[1];
29e444
+    else if (p==2) c = X[1] + R* X[2];
29e444
+    else if (p==3) c = X[1] + R*(X[2]  +   R* X[3]);
29e444
+    else if (p==4) c =(X[1] + R* X[2]) + R*R*(X[3] + R*X[4]);
29e444
+  }
29e444
+  else {
29e444
+    for (a=ONE, z[1]=X[1]; z[1] < TWO23; )
29e444
+        {a *= TWO;   z[1] *= TWO; }
29e444
+
29e444
+    for (i=2; i<5; i++) {
29e444
+      z[i] = X[i]*a;
29e444
+      u = (z[i] + CUTTER)-CUTTER;
29e444
+      if  (u > z[i])  u -= RADIX;
29e444
+      z[i] -= u;
29e444
+      z[i-1] += u*RADIXI;
29e444
+    }
29e444
+
29e444
+    u = (z[3] + TWO71) - TWO71;
29e444
+    if (u > z[3])   u -= TWO19;
29e444
+    v = z[3]-u;
29e444
+
29e444
+    if (v == TWO18) {
29e444
+      if (z[4] == ZERO) {
29e444
+        for (i=5; i <= p; i++) {
29e444
+          if (X[i] == ZERO)   continue;
29e444
+          else                {z[3] += ONE;   break; }
29e444
+        }
29e444
+      }
29e444
+      else              z[3] += ONE;
29e444
+    }
29e444
+
29e444
+    c = (z[1] + R *(z[2] + R * z[3]))/a;
29e444
+  }
29e444
+
29e444
+  c *= X[0];
29e444
+
29e444
+  for (i=1; i
29e444
+  for (i=1; i>EX; i--)   c *= RADIXI;
29e444
+
29e444
+  *y = c;
29e444
+  return;
29e444
+#undef R
29e444
+}
29e444
+
29e444
+/* Convert a multiple precision number *x into a double precision */
29e444
+/* number *y, denormalized case  (|x| < 2**(-1022))) */
29e444
+static void denorm(const mp_no *x, double *y, int p)
29e444
+{
29e444
+  long i,k;
29e444
+  long p2 = p;
29e444
+  double c,u,z[5];
29e444
+#if 0
29e444
+  double a,v;
29e444
+#endif
29e444
+
29e444
+#define R  radixi.d
29e444
+  if (EX<-44 || (EX==-44 && X[1]
29e444
+     { *y=ZERO; return; }
29e444
+
29e444
+  if      (p2==1) {
29e444
+    if      (EX==-42) {z[1]=X[1]+TWO10;  z[2]=ZERO;  z[3]=ZERO;  k=3;}
29e444
+    else if (EX==-43) {z[1]=     TWO10;  z[2]=X[1];  z[3]=ZERO;  k=2;}
29e444
+    else              {z[1]=     TWO10;  z[2]=ZERO;  z[3]=X[1];  k=1;}
29e444
+  }
29e444
+  else if (p2==2) {
29e444
+    if      (EX==-42) {z[1]=X[1]+TWO10;  z[2]=X[2];  z[3]=ZERO;  k=3;}
29e444
+    else if (EX==-43) {z[1]=     TWO10;  z[2]=X[1];  z[3]=X[2];  k=2;}
29e444
+    else              {z[1]=     TWO10;  z[2]=ZERO;  z[3]=X[1];  k=1;}
29e444
+  }
29e444
+  else {
29e444
+    if      (EX==-42) {z[1]=X[1]+TWO10;  z[2]=X[2];  k=3;}
29e444
+    else if (EX==-43) {z[1]=     TWO10;  z[2]=X[1];  k=2;}
29e444
+    else              {z[1]=     TWO10;  z[2]=ZERO;  k=1;}
29e444
+    z[3] = X[k];
29e444
+  }
29e444
+
29e444
+  u = (z[3] + TWO57) - TWO57;
29e444
+  if  (u > z[3])   u -= TWO5;
29e444
+
29e444
+  if (u==z[3]) {
29e444
+    for (i=k+1; i <= p2; i++) {
29e444
+      if (X[i] == ZERO)   continue;
29e444
+      else {z[3] += ONE;   break; }
29e444
+    }
29e444
+  }
29e444
+
29e444
+  c = X[0]*((z[1] + R*(z[2] + R*z[3])) - TWO10);
29e444
+
29e444
+  *y = c*TWOM1032;
29e444
+  return;
29e444
+
29e444
+#undef R
29e444
+}
29e444
+
29e444
+/* Convert a multiple precision number *x into a double precision number *y. */
29e444
+/* The result is correctly rounded to the nearest/even. *x is left unchanged */
29e444
+
29e444
+void __mp_dbl(const mp_no *x, double *y, int p) {
29e444
+#if 0
29e444
+  int i,k;
29e444
+  double a,c,u,v,z[5];
29e444
+#endif
29e444
+
29e444
+  if (X[0] == ZERO)  {*y = ZERO;  return; }
29e444
+
29e444
+  if      (EX> -42)                 norm(x,y,p);
29e444
+  else if (EX==-42 && X[1]>=TWO10)  norm(x,y,p);
29e444
+  else                              denorm(x,y,p);
29e444
+}
29e444
+
29e444
+
29e444
+/* dbl_mp() converts a double precision number x into a multiple precision  */
29e444
+/* number *y. If the precision p is too small the result is truncated. x is */
29e444
+/* left unchanged.                                                          */
29e444
+
29e444
+void __dbl_mp(double x, mp_no *y, int p) {
29e444
+
29e444
+  long i,n;
29e444
+  long p2 = p;
29e444
+  double u;
29e444
+
29e444
+  /* Sign */
29e444
+  if      (x == ZERO)  {Y[0] = ZERO;  return; }
29e444
+  else if (x >  ZERO)   Y[0] = ONE;
29e444
+  else                 {Y[0] = MONE;  x=-x;   }
29e444
+
29e444
+  /* Exponent */
29e444
+  for (EY=ONE; x >= RADIX; EY += ONE)   x *= RADIXI;
29e444
+  for (      ; x <  ONE;   EY -= ONE)   x *= RADIX;
29e444
+
29e444
+  /* Digits */
29e444
+  n=MIN(p2,4);
29e444
+  for (i=1; i<=n; i++) {
29e444
+    u = (x + TWO52) - TWO52;
29e444
+    if (u>x)   u -= ONE;
29e444
+    Y[i] = u;     x -= u;    x *= RADIX; }
29e444
+  for (   ; i<=p2; i++)     Y[i] = ZERO;
29e444
+  return;
29e444
+}
29e444
+
29e444
+
29e444
+/*  add_magnitudes() adds the magnitudes of *x & *y assuming that           */
29e444
+/*  abs(*x) >= abs(*y) > 0.                                                 */
29e444
+/* The sign of the sum *z is undefined. x&y may overlap but not x&z or y&z. */
29e444
+/* No guard digit is used. The result equals the exact sum, truncated.      */
29e444
+/* *x & *y are left unchanged.                                              */
29e444
+
29e444
+static void add_magnitudes(const mp_no *x, const mp_no *y, mp_no *z, int p) {
29e444
+
29e444
+  long i,j,k;
29e444
+  long p2 = p;
29e444
+
29e444
+  EZ = EX;
29e444
+
29e444
+  i=p2;    j=p2+ EY - EX;    k=p2+1;
29e444
+
29e444
+  if (j<1)
29e444
+     {__cpy(x,z,p);  return; }
29e444
+  else   Z[k] = ZERO;
29e444
+
29e444
+  for (; j>0; i--,j--) {
29e444
+    Z[k] += X[i] + Y[j];
29e444
+    if (Z[k] >= RADIX) {
29e444
+      Z[k]  -= RADIX;
29e444
+      Z[--k] = ONE; }
29e444
+    else
29e444
+      Z[--k] = ZERO;
29e444
+  }
29e444
+
29e444
+  for (; i>0; i--) {
29e444
+    Z[k] += X[i];
29e444
+    if (Z[k] >= RADIX) {
29e444
+      Z[k]  -= RADIX;
29e444
+      Z[--k] = ONE; }
29e444
+    else
29e444
+      Z[--k] = ZERO;
29e444
+  }
29e444
+
29e444
+  if (Z[1] == ZERO) {
29e444
+    for (i=1; i<=p2; i++)    Z[i] = Z[i+1]; }
29e444
+  else   EZ += ONE;
29e444
+}
29e444
+
29e444
+
29e444
+/*  sub_magnitudes() subtracts the magnitudes of *x & *y assuming that      */
29e444
+/*  abs(*x) > abs(*y) > 0.                                                  */
29e444
+/* The sign of the difference *z is undefined. x&y may overlap but not x&z  */
29e444
+/* or y&z. One guard digit is used. The error is less than one ulp.         */
29e444
+/* *x & *y are left unchanged.                                              */
29e444
+
29e444
+static void sub_magnitudes(const mp_no *x, const mp_no *y, mp_no *z, int p) {
29e444
+
29e444
+  long i,j,k;
29e444
+  long p2 = p;
29e444
+
29e444
+  EZ = EX;
29e444
+
29e444
+  if (EX == EY) {
29e444
+    i=j=k=p2;
29e444
+    Z[k] = Z[k+1] = ZERO; }
29e444
+  else {
29e444
+    j= EX - EY;
29e444
+    if (j > p2)  {__cpy(x,z,p);  return; }
29e444
+    else {
29e444
+      i=p2;   j=p2+1-j;   k=p2;
29e444
+      if (Y[j] > ZERO) {
29e444
+        Z[k+1] = RADIX - Y[j--];
29e444
+        Z[k]   = MONE; }
29e444
+      else {
29e444
+        Z[k+1] = ZERO;
29e444
+        Z[k]   = ZERO;   j--;}
29e444
+    }
29e444
+  }
29e444
+
29e444
+  for (; j>0; i--,j--) {
29e444
+    Z[k] += (X[i] - Y[j]);
29e444
+    if (Z[k] < ZERO) {
29e444
+      Z[k]  += RADIX;
29e444
+      Z[--k] = MONE; }
29e444
+    else
29e444
+      Z[--k] = ZERO;
29e444
+  }
29e444
+
29e444
+  for (; i>0; i--) {
29e444
+    Z[k] += X[i];
29e444
+    if (Z[k] < ZERO) {
29e444
+      Z[k]  += RADIX;
29e444
+      Z[--k] = MONE; }
29e444
+    else
29e444
+      Z[--k] = ZERO;
29e444
+  }
29e444
+
29e444
+  for (i=1; Z[i] == ZERO; i++) ;
29e444
+  EZ = EZ - i + 1;
29e444
+  for (k=1; i <= p2+1; )
29e444
+    Z[k++] = Z[i++];
29e444
+  for (; k <= p2; )
29e444
+    Z[k++] = ZERO;
29e444
+
29e444
+  return;
29e444
+}
29e444
+
29e444
+
29e444
+/* Add two multiple precision numbers. Set *z = *x + *y. x&y may overlap  */
29e444
+/* but not x&z or y&z. One guard digit is used. The error is less than    */
29e444
+/* one ulp. *x & *y are left unchanged.                                   */
29e444
+
29e444
+void __add(const mp_no *x, const mp_no *y, mp_no *z, int p) {
29e444
+
29e444
+  int n;
29e444
+
29e444
+  if      (X[0] == ZERO)     {__cpy(y,z,p);  return; }
29e444
+  else if (Y[0] == ZERO)     {__cpy(x,z,p);  return; }
29e444
+
29e444
+  if (X[0] == Y[0])   {
29e444
+    if (__acr(x,y,p) > 0)      {add_magnitudes(x,y,z,p);  Z[0] = X[0]; }
29e444
+    else                     {add_magnitudes(y,x,z,p);  Z[0] = Y[0]; }
29e444
+  }
29e444
+  else                       {
29e444
+    if ((n=__acr(x,y,p)) == 1) {sub_magnitudes(x,y,z,p);  Z[0] = X[0]; }
29e444
+    else if (n == -1)        {sub_magnitudes(y,x,z,p);  Z[0] = Y[0]; }
29e444
+    else                      Z[0] = ZERO;
29e444
+  }
29e444
+  return;
29e444
+}
29e444
+
29e444
+
29e444
+/* Subtract two multiple precision numbers. *z is set to *x - *y. x&y may */
29e444
+/* overlap but not x&z or y&z. One guard digit is used. The error is      */
29e444
+/* less than one ulp. *x & *y are left unchanged.                         */
29e444
+
29e444
+void __sub(const mp_no *x, const mp_no *y, mp_no *z, int p) {
29e444
+
29e444
+  int n;
29e444
+
29e444
+  if      (X[0] == ZERO)     {__cpy(y,z,p);  Z[0] = -Z[0];  return; }
29e444
+  else if (Y[0] == ZERO)     {__cpy(x,z,p);                 return; }
29e444
+
29e444
+  if (X[0] != Y[0])    {
29e444
+    if (__acr(x,y,p) > 0)      {add_magnitudes(x,y,z,p);  Z[0] =  X[0]; }
29e444
+    else                     {add_magnitudes(y,x,z,p);  Z[0] = -Y[0]; }
29e444
+  }
29e444
+  else                       {
29e444
+    if ((n=__acr(x,y,p)) == 1) {sub_magnitudes(x,y,z,p);  Z[0] =  X[0]; }
29e444
+    else if (n == -1)        {sub_magnitudes(y,x,z,p);  Z[0] = -Y[0]; }
29e444
+    else                      Z[0] = ZERO;
29e444
+  }
29e444
+  return;
29e444
+}
29e444
+
29e444
+
29e444
+/* Multiply two multiple precision numbers. *z is set to *x * *y. x&y      */
29e444
+/* may overlap but not x&z or y&z. In case p=1,2,3 the exact result is     */
29e444
+/* truncated to p digits. In case p>3 the error is bounded by 1.001 ulp.   */
29e444
+/* *x & *y are left unchanged.                                             */
29e444
+
29e444
+void __mul(const mp_no *x, const mp_no *y, mp_no *z, int p) {
29e444
+
29e444
+  long i, i1, i2, j, k, k2;
29e444
+  long p2 = p;
29e444
+  double u, zk, zk2;
29e444
+
29e444
+                      /* Is z=0? */
29e444
+  if (X[0]*Y[0]==ZERO)
29e444
+     { Z[0]=ZERO;  return; }
29e444
+
29e444
+                       /* Multiply, add and carry */
29e444
+  k2 = (p2<3) ? p2+p2 : p2+3;
29e444
+  zk = Z[k2]=ZERO;
29e444
+  for (k=k2; k>1; ) {
29e444
+    if (k > p2)  {i1=k-p2; i2=p2+1; }
29e444
+    else        {i1=1;   i2=k;   }
29e444
+#if 1
29e444
+    /* rearange this inner loop to allow the fmadd instructions to be
29e444
+       independent and execute in parallel on processors that have
29e444
+       dual symetrical FP pipelines.  */
29e444
+    if (i1 < (i2-1))
29e444
+    {
29e444
+	/* make sure we have at least 2 iterations */
29e444
+	if (((i2 - i1) & 1L) == 1L)
29e444
+	{
29e444
+                /* Handle the odd iterations case.  */
29e444
+		zk2 = x->d[i2-1]*y->d[i1];
29e444
+	}
29e444
+	else
29e444
+		zk2 = zero.d;
29e444
+	/* Do two multiply/adds per loop iteration, using independent
29e444
+           accumulators; zk and zk2.  */
29e444
+	for (i=i1,j=i2-1; i
29e444
+	{
29e444
+		zk += x->d[i]*y->d[j];
29e444
+		zk2 += x->d[i+1]*y->d[j-1];
29e444
+	}
29e444
+	zk += zk2; /* final sum.  */
29e444
+    }
29e444
+    else
29e444
+    {
29e444
+        /* Special case when iterations is 1.  */
29e444
+	zk += x->d[i1]*y->d[i1];
29e444
+    }
29e444
+#else
29e444
+    /* The orginal code.  */
29e444
+    for (i=i1,j=i2-1; i
29e444
+#endif
29e444
+
29e444
+    u = (zk + CUTTER)-CUTTER;
29e444
+    if  (u > zk)  u -= RADIX;
29e444
+    Z[k]  = zk - u;
29e444
+    zk = u*RADIXI;
29e444
+    --k;
29e444
+  }
29e444
+  Z[k] = zk;
29e444
+
29e444
+                 /* Is there a carry beyond the most significant digit? */
29e444
+  if (Z[1] == ZERO) {
29e444
+    for (i=1; i<=p2; i++)  Z[i]=Z[i+1];
29e444
+    EZ = EX + EY - 1; }
29e444
+  else
29e444
+    EZ = EX + EY;
29e444
+
29e444
+  Z[0] = X[0] * Y[0];
29e444
+  return;
29e444
+}
29e444
+
29e444
+
29e444
+/* Invert a multiple precision number. Set *y = 1 / *x.                     */
29e444
+/* Relative error bound = 1.001*r**(1-p) for p=2, 1.063*r**(1-p) for p=3,   */
29e444
+/* 2.001*r**(1-p) for p>3.                                                  */
29e444
+/* *x=0 is not permissible. *x is left unchanged.                           */
29e444
+
29e444
+void __inv(const mp_no *x, mp_no *y, int p) {
29e444
+  long i;
29e444
+#if 0
29e444
+  int l;
29e444
+#endif
29e444
+  double t;
29e444
+  mp_no z,w;
29e444
+  static const int np1[] = {0,0,0,0,1,2,2,2,2,3,3,3,3,3,3,3,3,3,
29e444
+                            4,4,4,4,4,4,4,4,4,4,4,4,4,4,4};
29e444
+  const mp_no mptwo = {1,{1.0,2.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
29e444
+                         0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
29e444
+                         0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
29e444
+                         0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}};
29e444
+
29e444
+  __cpy(x,&z,p);  z.e=0;  __mp_dbl(&z,&t,p);
29e444
+  t=ONE/t;   __dbl_mp(t,y,p);    EY -= EX;
29e444
+
29e444
+  for (i=0; i
29e444
+    __cpy(y,&w,p);
29e444
+    __mul(x,&w,y,p);
29e444
+    __sub(&mptwo,y,&z,p);
29e444
+    __mul(&w,&z,y,p);
29e444
+  }
29e444
+  return;
29e444
+}
29e444
+
29e444
+
29e444
+/* Divide one multiple precision number by another.Set *z = *x / *y. *x & *y */
29e444
+/* are left unchanged. x&y may overlap but not x&z or y&z.                   */
29e444
+/* Relative error bound = 2.001*r**(1-p) for p=2, 2.063*r**(1-p) for p=3     */
29e444
+/* and 3.001*r**(1-p) for p>3. *y=0 is not permissible.                      */
29e444
+
29e444
+void __dvd(const mp_no *x, const mp_no *y, mp_no *z, int p) {
29e444
+
29e444
+  mp_no w;
29e444
+
29e444
+  if (X[0] == ZERO)    Z[0] = ZERO;
29e444
+  else                {__inv(y,&w,p);   __mul(x,&w,z,p);}
29e444
+  return;
29e444
+}
29e444
diff --git a/sysdeps/powerpc/powerpc32/power4/Implies b/sysdeps/powerpc/powerpc32/power4/Implies
29e444
new file mode 100644
29e444
index 0000000..a372141
29e444
--- /dev/null
29e444
+++ b/sysdeps/powerpc/powerpc32/power4/Implies
29e444
@@ -0,0 +1,2 @@
29e444
+powerpc/power4/fpu
29e444
+powerpc/power4
29e444
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/Makefile b/sysdeps/powerpc/powerpc32/power4/fpu/Makefile
29e444
deleted file mode 100644
29e444
index f487ed6..0000000
29e444
--- a/sysdeps/powerpc/powerpc32/power4/fpu/Makefile
29e444
+++ /dev/null
29e444
@@ -1,5 +0,0 @@
29e444
-# Makefile fragment for POWER4/5/5+ with FPU.
29e444
-
29e444
-ifeq ($(subdir),math)
29e444
-CFLAGS-mpa.c += --param max-unroll-times=4 -funroll-loops -fpeel-loops
29e444
-endif
29e444
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/mpa.c b/sysdeps/powerpc/powerpc32/power4/fpu/mpa.c
29e444
deleted file mode 100644
29e444
index d15680e..0000000
29e444
--- a/sysdeps/powerpc/powerpc32/power4/fpu/mpa.c
29e444
+++ /dev/null
29e444
@@ -1,548 +0,0 @@
29e444
-
29e444
-/*
29e444
- * IBM Accurate Mathematical Library
29e444
- * written by International Business Machines Corp.
29e444
- * Copyright (C) 2001, 2006 Free Software Foundation
29e444
- *
29e444
- * This program is free software; you can redistribute it and/or modify
29e444
- * it under the terms of the GNU Lesser General Public License as published by
29e444
- * the Free Software Foundation; either version 2.1 of the License, or
29e444
- * (at your option) any later version.
29e444
- *
29e444
- * This program is distributed in the hope that it will be useful,
29e444
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
29e444
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29e444
- * GNU Lesser General Public License for more details.
29e444
- *
29e444
- * You should have received a copy of the GNU Lesser General Public License
29e444
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
29e444
- */
29e444
-/************************************************************************/
29e444
-/*  MODULE_NAME: mpa.c                                                  */
29e444
-/*                                                                      */
29e444
-/*  FUNCTIONS:                                                          */
29e444
-/*               mcr                                                    */
29e444
-/*               acr                                                    */
29e444
-/*               cr                                                     */
29e444
-/*               cpy                                                    */
29e444
-/*               cpymn                                                  */
29e444
-/*               norm                                                   */
29e444
-/*               denorm                                                 */
29e444
-/*               mp_dbl                                                 */
29e444
-/*               dbl_mp                                                 */
29e444
-/*               add_magnitudes                                         */
29e444
-/*               sub_magnitudes                                         */
29e444
-/*               add                                                    */
29e444
-/*               sub                                                    */
29e444
-/*               mul                                                    */
29e444
-/*               inv                                                    */
29e444
-/*               dvd                                                    */
29e444
-/*                                                                      */
29e444
-/* Arithmetic functions for multiple precision numbers.                 */
29e444
-/* Relative errors are bounded                                          */
29e444
-/************************************************************************/
29e444
-
29e444
-
29e444
-#include "endian.h"
29e444
-#include "mpa.h"
29e444
-#include "mpa2.h"
29e444
-#include <sys/param.h>	/* For MIN() */
29e444
-/* mcr() compares the sizes of the mantissas of two multiple precision  */
29e444
-/* numbers. Mantissas are compared regardless of the signs of the       */
29e444
-/* numbers, even if x->d[0] or y->d[0] are zero. Exponents are also     */
29e444
-/* disregarded.                                                         */
29e444
-static int mcr(const mp_no *x, const mp_no *y, int p) {
29e444
-  long i;
29e444
-  long p2 = p;
29e444
-  for (i=1; i<=p2; i++) {
29e444
-    if      (X[i] == Y[i])  continue;
29e444
-    else if (X[i] >  Y[i])  return  1;
29e444
-    else                    return -1; }
29e444
-  return 0;
29e444
-}
29e444
-
29e444
-
29e444
-
29e444
-/* acr() compares the absolute values of two multiple precision numbers */
29e444
-int __acr(const mp_no *x, const mp_no *y, int p) {
29e444
-  long i;
29e444
-
29e444
-  if      (X[0] == ZERO) {
29e444
-    if    (Y[0] == ZERO) i= 0;
29e444
-    else                 i=-1;
29e444
-  }
29e444
-  else if (Y[0] == ZERO) i= 1;
29e444
-  else {
29e444
-    if      (EX >  EY)   i= 1;
29e444
-    else if (EX <  EY)   i=-1;
29e444
-    else                 i= mcr(x,y,p);
29e444
-  }
29e444
-
29e444
-  return i;
29e444
-}
29e444
-
29e444
-
29e444
-/* cr90 compares the values of two multiple precision numbers           */
29e444
-int  __cr(const mp_no *x, const mp_no *y, int p) {
29e444
-  int i;
29e444
-
29e444
-  if      (X[0] > Y[0])  i= 1;
29e444
-  else if (X[0] < Y[0])  i=-1;
29e444
-  else if (X[0] < ZERO ) i= __acr(y,x,p);
29e444
-  else                   i= __acr(x,y,p);
29e444
-
29e444
-  return i;
29e444
-}
29e444
-
29e444
-
29e444
-/* Copy a multiple precision number. Set *y=*x. x=y is permissible.      */
29e444
-void __cpy(const mp_no *x, mp_no *y, int p) {
29e444
-  long i;
29e444
-
29e444
-  EY = EX;
29e444
-  for (i=0; i <= p; i++)    Y[i] = X[i];
29e444
-
29e444
-  return;
29e444
-}
29e444
-
29e444
-
29e444
-/* Copy a multiple precision number x of precision m into a */
29e444
-/* multiple precision number y of precision n. In case n>m, */
29e444
-/* the digits of y beyond the m'th are set to zero. In case */
29e444
-/* n
29e444
-/* x=y is permissible.                                      */
29e444
-
29e444
-void __cpymn(const mp_no *x, int m, mp_no *y, int n) {
29e444
-
29e444
-  long i,k;
29e444
-  long n2 = n;
29e444
-  long m2 = m;
29e444
-
29e444
-  EY = EX;     k=MIN(m2,n2);
29e444
-  for (i=0; i <= k; i++)    Y[i] = X[i];
29e444
-  for (   ; i <= n2; i++)    Y[i] = ZERO;
29e444
-
29e444
-  return;
29e444
-}
29e444
-
29e444
-/* Convert a multiple precision number *x into a double precision */
29e444
-/* number *y, normalized case  (|x| >= 2**(-1022))) */
29e444
-static void norm(const mp_no *x, double *y, int p)
29e444
-{
29e444
-  #define R  radixi.d
29e444
-  long i;
29e444
-#if 0
29e444
-  int k;
29e444
-#endif
29e444
-  double a,c,u,v,z[5];
29e444
-  if (p<5) {
29e444
-    if      (p==1) c = X[1];
29e444
-    else if (p==2) c = X[1] + R* X[2];
29e444
-    else if (p==3) c = X[1] + R*(X[2]  +   R* X[3]);
29e444
-    else if (p==4) c =(X[1] + R* X[2]) + R*R*(X[3] + R*X[4]);
29e444
-  }
29e444
-  else {
29e444
-    for (a=ONE, z[1]=X[1]; z[1] < TWO23; )
29e444
-        {a *= TWO;   z[1] *= TWO; }
29e444
-
29e444
-    for (i=2; i<5; i++) {
29e444
-      z[i] = X[i]*a;
29e444
-      u = (z[i] + CUTTER)-CUTTER;
29e444
-      if  (u > z[i])  u -= RADIX;
29e444
-      z[i] -= u;
29e444
-      z[i-1] += u*RADIXI;
29e444
-    }
29e444
-
29e444
-    u = (z[3] + TWO71) - TWO71;
29e444
-    if (u > z[3])   u -= TWO19;
29e444
-    v = z[3]-u;
29e444
-
29e444
-    if (v == TWO18) {
29e444
-      if (z[4] == ZERO) {
29e444
-        for (i=5; i <= p; i++) {
29e444
-          if (X[i] == ZERO)   continue;
29e444
-          else                {z[3] += ONE;   break; }
29e444
-        }
29e444
-      }
29e444
-      else              z[3] += ONE;
29e444
-    }
29e444
-
29e444
-    c = (z[1] + R *(z[2] + R * z[3]))/a;
29e444
-  }
29e444
-
29e444
-  c *= X[0];
29e444
-
29e444
-  for (i=1; i
29e444
-  for (i=1; i>EX; i--)   c *= RADIXI;
29e444
-
29e444
-  *y = c;
29e444
-  return;
29e444
-#undef R
29e444
-}
29e444
-
29e444
-/* Convert a multiple precision number *x into a double precision */
29e444
-/* number *y, denormalized case  (|x| < 2**(-1022))) */
29e444
-static void denorm(const mp_no *x, double *y, int p)
29e444
-{
29e444
-  long i,k;
29e444
-  long p2 = p;
29e444
-  double c,u,z[5];
29e444
-#if 0
29e444
-  double a,v;
29e444
-#endif
29e444
-
29e444
-#define R  radixi.d
29e444
-  if (EX<-44 || (EX==-44 && X[1]
29e444
-     { *y=ZERO; return; }
29e444
-
29e444
-  if      (p2==1) {
29e444
-    if      (EX==-42) {z[1]=X[1]+TWO10;  z[2]=ZERO;  z[3]=ZERO;  k=3;}
29e444
-    else if (EX==-43) {z[1]=     TWO10;  z[2]=X[1];  z[3]=ZERO;  k=2;}
29e444
-    else              {z[1]=     TWO10;  z[2]=ZERO;  z[3]=X[1];  k=1;}
29e444
-  }
29e444
-  else if (p2==2) {
29e444
-    if      (EX==-42) {z[1]=X[1]+TWO10;  z[2]=X[2];  z[3]=ZERO;  k=3;}
29e444
-    else if (EX==-43) {z[1]=     TWO10;  z[2]=X[1];  z[3]=X[2];  k=2;}
29e444
-    else              {z[1]=     TWO10;  z[2]=ZERO;  z[3]=X[1];  k=1;}
29e444
-  }
29e444
-  else {
29e444
-    if      (EX==-42) {z[1]=X[1]+TWO10;  z[2]=X[2];  k=3;}
29e444
-    else if (EX==-43) {z[1]=     TWO10;  z[2]=X[1];  k=2;}
29e444
-    else              {z[1]=     TWO10;  z[2]=ZERO;  k=1;}
29e444
-    z[3] = X[k];
29e444
-  }
29e444
-
29e444
-  u = (z[3] + TWO57) - TWO57;
29e444
-  if  (u > z[3])   u -= TWO5;
29e444
-
29e444
-  if (u==z[3]) {
29e444
-    for (i=k+1; i <= p2; i++) {
29e444
-      if (X[i] == ZERO)   continue;
29e444
-      else {z[3] += ONE;   break; }
29e444
-    }
29e444
-  }
29e444
-
29e444
-  c = X[0]*((z[1] + R*(z[2] + R*z[3])) - TWO10);
29e444
-
29e444
-  *y = c*TWOM1032;
29e444
-  return;
29e444
-
29e444
-#undef R
29e444
-}
29e444
-
29e444
-/* Convert a multiple precision number *x into a double precision number *y. */
29e444
-/* The result is correctly rounded to the nearest/even. *x is left unchanged */
29e444
-
29e444
-void __mp_dbl(const mp_no *x, double *y, int p) {
29e444
-#if 0
29e444
-  int i,k;
29e444
-  double a,c,u,v,z[5];
29e444
-#endif
29e444
-
29e444
-  if (X[0] == ZERO)  {*y = ZERO;  return; }
29e444
-
29e444
-  if      (EX> -42)                 norm(x,y,p);
29e444
-  else if (EX==-42 && X[1]>=TWO10)  norm(x,y,p);
29e444
-  else                              denorm(x,y,p);
29e444
-}
29e444
-
29e444
-
29e444
-/* dbl_mp() converts a double precision number x into a multiple precision  */
29e444
-/* number *y. If the precision p is too small the result is truncated. x is */
29e444
-/* left unchanged.                                                          */
29e444
-
29e444
-void __dbl_mp(double x, mp_no *y, int p) {
29e444
-
29e444
-  long i,n;
29e444
-  long p2 = p;
29e444
-  double u;
29e444
-
29e444
-  /* Sign */
29e444
-  if      (x == ZERO)  {Y[0] = ZERO;  return; }
29e444
-  else if (x >  ZERO)   Y[0] = ONE;
29e444
-  else                 {Y[0] = MONE;  x=-x;   }
29e444
-
29e444
-  /* Exponent */
29e444
-  for (EY=ONE; x >= RADIX; EY += ONE)   x *= RADIXI;
29e444
-  for (      ; x <  ONE;   EY -= ONE)   x *= RADIX;
29e444
-
29e444
-  /* Digits */
29e444
-  n=MIN(p2,4);
29e444
-  for (i=1; i<=n; i++) {
29e444
-    u = (x + TWO52) - TWO52;
29e444
-    if (u>x)   u -= ONE;
29e444
-    Y[i] = u;     x -= u;    x *= RADIX; }
29e444
-  for (   ; i<=p2; i++)     Y[i] = ZERO;
29e444
-  return;
29e444
-}
29e444
-
29e444
-
29e444
-/*  add_magnitudes() adds the magnitudes of *x & *y assuming that           */
29e444
-/*  abs(*x) >= abs(*y) > 0.                                                 */
29e444
-/* The sign of the sum *z is undefined. x&y may overlap but not x&z or y&z. */
29e444
-/* No guard digit is used. The result equals the exact sum, truncated.      */
29e444
-/* *x & *y are left unchanged.                                              */
29e444
-
29e444
-static void add_magnitudes(const mp_no *x, const mp_no *y, mp_no *z, int p) {
29e444
-
29e444
-  long i,j,k;
29e444
-  long p2 = p;
29e444
-
29e444
-  EZ = EX;
29e444
-
29e444
-  i=p2;    j=p2+ EY - EX;    k=p2+1;
29e444
-
29e444
-  if (j<1)
29e444
-     {__cpy(x,z,p);  return; }
29e444
-  else   Z[k] = ZERO;
29e444
-
29e444
-  for (; j>0; i--,j--) {
29e444
-    Z[k] += X[i] + Y[j];
29e444
-    if (Z[k] >= RADIX) {
29e444
-      Z[k]  -= RADIX;
29e444
-      Z[--k] = ONE; }
29e444
-    else
29e444
-      Z[--k] = ZERO;
29e444
-  }
29e444
-
29e444
-  for (; i>0; i--) {
29e444
-    Z[k] += X[i];
29e444
-    if (Z[k] >= RADIX) {
29e444
-      Z[k]  -= RADIX;
29e444
-      Z[--k] = ONE; }
29e444
-    else
29e444
-      Z[--k] = ZERO;
29e444
-  }
29e444
-
29e444
-  if (Z[1] == ZERO) {
29e444
-    for (i=1; i<=p2; i++)    Z[i] = Z[i+1]; }
29e444
-  else   EZ += ONE;
29e444
-}
29e444
-
29e444
-
29e444
-/*  sub_magnitudes() subtracts the magnitudes of *x & *y assuming that      */
29e444
-/*  abs(*x) > abs(*y) > 0.                                                  */
29e444
-/* The sign of the difference *z is undefined. x&y may overlap but not x&z  */
29e444
-/* or y&z. One guard digit is used. The error is less than one ulp.         */
29e444
-/* *x & *y are left unchanged.                                              */
29e444
-
29e444
-static void sub_magnitudes(const mp_no *x, const mp_no *y, mp_no *z, int p) {
29e444
-
29e444
-  long i,j,k;
29e444
-  long p2 = p;
29e444
-
29e444
-  EZ = EX;
29e444
-
29e444
-  if (EX == EY) {
29e444
-    i=j=k=p2;
29e444
-    Z[k] = Z[k+1] = ZERO; }
29e444
-  else {
29e444
-    j= EX - EY;
29e444
-    if (j > p2)  {__cpy(x,z,p);  return; }
29e444
-    else {
29e444
-      i=p2;   j=p2+1-j;   k=p2;
29e444
-      if (Y[j] > ZERO) {
29e444
-        Z[k+1] = RADIX - Y[j--];
29e444
-        Z[k]   = MONE; }
29e444
-      else {
29e444
-        Z[k+1] = ZERO;
29e444
-        Z[k]   = ZERO;   j--;}
29e444
-    }
29e444
-  }
29e444
-
29e444
-  for (; j>0; i--,j--) {
29e444
-    Z[k] += (X[i] - Y[j]);
29e444
-    if (Z[k] < ZERO) {
29e444
-      Z[k]  += RADIX;
29e444
-      Z[--k] = MONE; }
29e444
-    else
29e444
-      Z[--k] = ZERO;
29e444
-  }
29e444
-
29e444
-  for (; i>0; i--) {
29e444
-    Z[k] += X[i];
29e444
-    if (Z[k] < ZERO) {
29e444
-      Z[k]  += RADIX;
29e444
-      Z[--k] = MONE; }
29e444
-    else
29e444
-      Z[--k] = ZERO;
29e444
-  }
29e444
-
29e444
-  for (i=1; Z[i] == ZERO; i++) ;
29e444
-  EZ = EZ - i + 1;
29e444
-  for (k=1; i <= p2+1; )
29e444
-    Z[k++] = Z[i++];
29e444
-  for (; k <= p2; )
29e444
-    Z[k++] = ZERO;
29e444
-
29e444
-  return;
29e444
-}
29e444
-
29e444
-
29e444
-/* Add two multiple precision numbers. Set *z = *x + *y. x&y may overlap  */
29e444
-/* but not x&z or y&z. One guard digit is used. The error is less than    */
29e444
-/* one ulp. *x & *y are left unchanged.                                   */
29e444
-
29e444
-void __add(const mp_no *x, const mp_no *y, mp_no *z, int p) {
29e444
-
29e444
-  int n;
29e444
-
29e444
-  if      (X[0] == ZERO)     {__cpy(y,z,p);  return; }
29e444
-  else if (Y[0] == ZERO)     {__cpy(x,z,p);  return; }
29e444
-
29e444
-  if (X[0] == Y[0])   {
29e444
-    if (__acr(x,y,p) > 0)      {add_magnitudes(x,y,z,p);  Z[0] = X[0]; }
29e444
-    else                     {add_magnitudes(y,x,z,p);  Z[0] = Y[0]; }
29e444
-  }
29e444
-  else                       {
29e444
-    if ((n=__acr(x,y,p)) == 1) {sub_magnitudes(x,y,z,p);  Z[0] = X[0]; }
29e444
-    else if (n == -1)        {sub_magnitudes(y,x,z,p);  Z[0] = Y[0]; }
29e444
-    else                      Z[0] = ZERO;
29e444
-  }
29e444
-  return;
29e444
-}
29e444
-
29e444
-
29e444
-/* Subtract two multiple precision numbers. *z is set to *x - *y. x&y may */
29e444
-/* overlap but not x&z or y&z. One guard digit is used. The error is      */
29e444
-/* less than one ulp. *x & *y are left unchanged.                         */
29e444
-
29e444
-void __sub(const mp_no *x, const mp_no *y, mp_no *z, int p) {
29e444
-
29e444
-  int n;
29e444
-
29e444
-  if      (X[0] == ZERO)     {__cpy(y,z,p);  Z[0] = -Z[0];  return; }
29e444
-  else if (Y[0] == ZERO)     {__cpy(x,z,p);                 return; }
29e444
-
29e444
-  if (X[0] != Y[0])    {
29e444
-    if (__acr(x,y,p) > 0)      {add_magnitudes(x,y,z,p);  Z[0] =  X[0]; }
29e444
-    else                     {add_magnitudes(y,x,z,p);  Z[0] = -Y[0]; }
29e444
-  }
29e444
-  else                       {
29e444
-    if ((n=__acr(x,y,p)) == 1) {sub_magnitudes(x,y,z,p);  Z[0] =  X[0]; }
29e444
-    else if (n == -1)        {sub_magnitudes(y,x,z,p);  Z[0] = -Y[0]; }
29e444
-    else                      Z[0] = ZERO;
29e444
-  }
29e444
-  return;
29e444
-}
29e444
-
29e444
-
29e444
-/* Multiply two multiple precision numbers. *z is set to *x * *y. x&y      */
29e444
-/* may overlap but not x&z or y&z. In case p=1,2,3 the exact result is     */
29e444
-/* truncated to p digits. In case p>3 the error is bounded by 1.001 ulp.   */
29e444
-/* *x & *y are left unchanged.                                             */
29e444
-
29e444
-void __mul(const mp_no *x, const mp_no *y, mp_no *z, int p) {
29e444
-
29e444
-  long i, i1, i2, j, k, k2;
29e444
-  long p2 = p;
29e444
-  double u, zk, zk2;
29e444
-
29e444
-                      /* Is z=0? */
29e444
-  if (X[0]*Y[0]==ZERO)
29e444
-     { Z[0]=ZERO;  return; }
29e444
-
29e444
-                       /* Multiply, add and carry */
29e444
-  k2 = (p2<3) ? p2+p2 : p2+3;
29e444
-  zk = Z[k2]=ZERO;
29e444
-  for (k=k2; k>1; ) {
29e444
-    if (k > p2)  {i1=k-p2; i2=p2+1; }
29e444
-    else        {i1=1;   i2=k;   }
29e444
-#if 1
29e444
-    /* rearange this inner loop to allow the fmadd instructions to be
29e444
-       independent and execute in parallel on processors that have
29e444
-       dual symetrical FP pipelines.  */
29e444
-    if (i1 < (i2-1))
29e444
-    {
29e444
-	/* make sure we have at least 2 iterations */
29e444
-	if (((i2 - i1) & 1L) == 1L)
29e444
-	{
29e444
-                /* Handle the odd iterations case.  */
29e444
-		zk2 = x->d[i2-1]*y->d[i1];
29e444
-	}
29e444
-	else
29e444
-		zk2 = zero.d;
29e444
-	/* Do two multiply/adds per loop iteration, using independent
29e444
-           accumulators; zk and zk2.  */
29e444
-	for (i=i1,j=i2-1; i
29e444
-	{
29e444
-		zk += x->d[i]*y->d[j];
29e444
-		zk2 += x->d[i+1]*y->d[j-1];
29e444
-	}
29e444
-	zk += zk2; /* final sum.  */
29e444
-    }
29e444
-    else
29e444
-    {
29e444
-        /* Special case when iterations is 1.  */
29e444
-	zk += x->d[i1]*y->d[i1];
29e444
-    }
29e444
-#else
29e444
-    /* The orginal code.  */
29e444
-    for (i=i1,j=i2-1; i
29e444
-#endif
29e444
-
29e444
-    u = (zk + CUTTER)-CUTTER;
29e444
-    if  (u > zk)  u -= RADIX;
29e444
-    Z[k]  = zk - u;
29e444
-    zk = u*RADIXI;
29e444
-    --k;
29e444
-  }
29e444
-  Z[k] = zk;
29e444
-
29e444
-                 /* Is there a carry beyond the most significant digit? */
29e444
-  if (Z[1] == ZERO) {
29e444
-    for (i=1; i<=p2; i++)  Z[i]=Z[i+1];
29e444
-    EZ = EX + EY - 1; }
29e444
-  else
29e444
-    EZ = EX + EY;
29e444
-
29e444
-  Z[0] = X[0] * Y[0];
29e444
-  return;
29e444
-}
29e444
-
29e444
-
29e444
-/* Invert a multiple precision number. Set *y = 1 / *x.                     */
29e444
-/* Relative error bound = 1.001*r**(1-p) for p=2, 1.063*r**(1-p) for p=3,   */
29e444
-/* 2.001*r**(1-p) for p>3.                                                  */
29e444
-/* *x=0 is not permissible. *x is left unchanged.                           */
29e444
-
29e444
-void __inv(const mp_no *x, mp_no *y, int p) {
29e444
-  long i;
29e444
-#if 0
29e444
-  int l;
29e444
-#endif
29e444
-  double t;
29e444
-  mp_no z,w;
29e444
-  static const int np1[] = {0,0,0,0,1,2,2,2,2,3,3,3,3,3,3,3,3,3,
29e444
-                            4,4,4,4,4,4,4,4,4,4,4,4,4,4,4};
29e444
-  const mp_no mptwo = {1,{1.0,2.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
29e444
-                         0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
29e444
-                         0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
29e444
-                         0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}};
29e444
-
29e444
-  __cpy(x,&z,p);  z.e=0;  __mp_dbl(&z,&t,p);
29e444
-  t=ONE/t;   __dbl_mp(t,y,p);    EY -= EX;
29e444
-
29e444
-  for (i=0; i
29e444
-    __cpy(y,&w,p);
29e444
-    __mul(x,&w,y,p);
29e444
-    __sub(&mptwo,y,&z,p);
29e444
-    __mul(&w,&z,y,p);
29e444
-  }
29e444
-  return;
29e444
-}
29e444
-
29e444
-
29e444
-/* Divide one multiple precision number by another.Set *z = *x / *y. *x & *y */
29e444
-/* are left unchanged. x&y may overlap but not x&z or y&z.                   */
29e444
-/* Relative error bound = 2.001*r**(1-p) for p=2, 2.063*r**(1-p) for p=3     */
29e444
-/* and 3.001*r**(1-p) for p>3. *y=0 is not permissible.                      */
29e444
-
29e444
-void __dvd(const mp_no *x, const mp_no *y, mp_no *z, int p) {
29e444
-
29e444
-  mp_no w;
29e444
-
29e444
-  if (X[0] == ZERO)    Z[0] = ZERO;
29e444
-  else                {__inv(y,&w,p);   __mul(x,&w,z,p);}
29e444
-  return;
29e444
-}
29e444
diff --git a/sysdeps/powerpc/powerpc64/power4/Implies b/sysdeps/powerpc/powerpc64/power4/Implies
29e444
new file mode 100644
29e444
index 0000000..a372141
29e444
--- /dev/null
29e444
+++ b/sysdeps/powerpc/powerpc64/power4/Implies
29e444
@@ -0,0 +1,2 @@
29e444
+powerpc/power4/fpu
29e444
+powerpc/power4
29e444
diff --git a/sysdeps/powerpc/powerpc64/power4/fpu/Makefile b/sysdeps/powerpc/powerpc64/power4/fpu/Makefile
29e444
deleted file mode 100644
29e444
index f8bb3ef..0000000
29e444
--- a/sysdeps/powerpc/powerpc64/power4/fpu/Makefile
29e444
+++ /dev/null
29e444
@@ -1,5 +0,0 @@
29e444
-# Makefile fragment for POWER4/5/5+ platforms with FPU.
29e444
-
29e444
-ifeq ($(subdir),math)
29e444
-CFLAGS-mpa.c += --param max-unroll-times=4 -funroll-loops -fpeel-loops
29e444
-endif
29e444
diff --git a/sysdeps/powerpc/powerpc64/power4/fpu/mpa.c b/sysdeps/powerpc/powerpc64/power4/fpu/mpa.c
29e444
deleted file mode 100644
29e444
index d15680e..0000000
29e444
--- a/sysdeps/powerpc/powerpc64/power4/fpu/mpa.c
29e444
+++ /dev/null
29e444
@@ -1,548 +0,0 @@
29e444
-
29e444
-/*
29e444
- * IBM Accurate Mathematical Library
29e444
- * written by International Business Machines Corp.
29e444
- * Copyright (C) 2001, 2006 Free Software Foundation
29e444
- *
29e444
- * This program is free software; you can redistribute it and/or modify
29e444
- * it under the terms of the GNU Lesser General Public License as published by
29e444
- * the Free Software Foundation; either version 2.1 of the License, or
29e444
- * (at your option) any later version.
29e444
- *
29e444
- * This program is distributed in the hope that it will be useful,
29e444
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
29e444
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29e444
- * GNU Lesser General Public License for more details.
29e444
- *
29e444
- * You should have received a copy of the GNU Lesser General Public License
29e444
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
29e444
- */
29e444
-/************************************************************************/
29e444
-/*  MODULE_NAME: mpa.c                                                  */
29e444
-/*                                                                      */
29e444
-/*  FUNCTIONS:                                                          */
29e444
-/*               mcr                                                    */
29e444
-/*               acr                                                    */
29e444
-/*               cr                                                     */
29e444
-/*               cpy                                                    */
29e444
-/*               cpymn                                                  */
29e444
-/*               norm                                                   */
29e444
-/*               denorm                                                 */
29e444
-/*               mp_dbl                                                 */
29e444
-/*               dbl_mp                                                 */
29e444
-/*               add_magnitudes                                         */
29e444
-/*               sub_magnitudes                                         */
29e444
-/*               add                                                    */
29e444
-/*               sub                                                    */
29e444
-/*               mul                                                    */
29e444
-/*               inv                                                    */
29e444
-/*               dvd                                                    */
29e444
-/*                                                                      */
29e444
-/* Arithmetic functions for multiple precision numbers.                 */
29e444
-/* Relative errors are bounded                                          */
29e444
-/************************************************************************/
29e444
-
29e444
-
29e444
-#include "endian.h"
29e444
-#include "mpa.h"
29e444
-#include "mpa2.h"
29e444
-#include <sys/param.h>	/* For MIN() */
29e444
-/* mcr() compares the sizes of the mantissas of two multiple precision  */
29e444
-/* numbers. Mantissas are compared regardless of the signs of the       */
29e444
-/* numbers, even if x->d[0] or y->d[0] are zero. Exponents are also     */
29e444
-/* disregarded.                                                         */
29e444
-static int mcr(const mp_no *x, const mp_no *y, int p) {
29e444
-  long i;
29e444
-  long p2 = p;
29e444
-  for (i=1; i<=p2; i++) {
29e444
-    if      (X[i] == Y[i])  continue;
29e444
-    else if (X[i] >  Y[i])  return  1;
29e444
-    else                    return -1; }
29e444
-  return 0;
29e444
-}
29e444
-
29e444
-
29e444
-
29e444
-/* acr() compares the absolute values of two multiple precision numbers */
29e444
-int __acr(const mp_no *x, const mp_no *y, int p) {
29e444
-  long i;
29e444
-
29e444
-  if      (X[0] == ZERO) {
29e444
-    if    (Y[0] == ZERO) i= 0;
29e444
-    else                 i=-1;
29e444
-  }
29e444
-  else if (Y[0] == ZERO) i= 1;
29e444
-  else {
29e444
-    if      (EX >  EY)   i= 1;
29e444
-    else if (EX <  EY)   i=-1;
29e444
-    else                 i= mcr(x,y,p);
29e444
-  }
29e444
-
29e444
-  return i;
29e444
-}
29e444
-
29e444
-
29e444
-/* cr90 compares the values of two multiple precision numbers           */
29e444
-int  __cr(const mp_no *x, const mp_no *y, int p) {
29e444
-  int i;
29e444
-
29e444
-  if      (X[0] > Y[0])  i= 1;
29e444
-  else if (X[0] < Y[0])  i=-1;
29e444
-  else if (X[0] < ZERO ) i= __acr(y,x,p);
29e444
-  else                   i= __acr(x,y,p);
29e444
-
29e444
-  return i;
29e444
-}
29e444
-
29e444
-
29e444
-/* Copy a multiple precision number. Set *y=*x. x=y is permissible.      */
29e444
-void __cpy(const mp_no *x, mp_no *y, int p) {
29e444
-  long i;
29e444
-
29e444
-  EY = EX;
29e444
-  for (i=0; i <= p; i++)    Y[i] = X[i];
29e444
-
29e444
-  return;
29e444
-}
29e444
-
29e444
-
29e444
-/* Copy a multiple precision number x of precision m into a */
29e444
-/* multiple precision number y of precision n. In case n>m, */
29e444
-/* the digits of y beyond the m'th are set to zero. In case */
29e444
-/* n
29e444
-/* x=y is permissible.                                      */
29e444
-
29e444
-void __cpymn(const mp_no *x, int m, mp_no *y, int n) {
29e444
-
29e444
-  long i,k;
29e444
-  long n2 = n;
29e444
-  long m2 = m;
29e444
-
29e444
-  EY = EX;     k=MIN(m2,n2);
29e444
-  for (i=0; i <= k; i++)    Y[i] = X[i];
29e444
-  for (   ; i <= n2; i++)    Y[i] = ZERO;
29e444
-
29e444
-  return;
29e444
-}
29e444
-
29e444
-/* Convert a multiple precision number *x into a double precision */
29e444
-/* number *y, normalized case  (|x| >= 2**(-1022))) */
29e444
-static void norm(const mp_no *x, double *y, int p)
29e444
-{
29e444
-  #define R  radixi.d
29e444
-  long i;
29e444
-#if 0
29e444
-  int k;
29e444
-#endif
29e444
-  double a,c,u,v,z[5];
29e444
-  if (p<5) {
29e444
-    if      (p==1) c = X[1];
29e444
-    else if (p==2) c = X[1] + R* X[2];
29e444
-    else if (p==3) c = X[1] + R*(X[2]  +   R* X[3]);
29e444
-    else if (p==4) c =(X[1] + R* X[2]) + R*R*(X[3] + R*X[4]);
29e444
-  }
29e444
-  else {
29e444
-    for (a=ONE, z[1]=X[1]; z[1] < TWO23; )
29e444
-        {a *= TWO;   z[1] *= TWO; }
29e444
-
29e444
-    for (i=2; i<5; i++) {
29e444
-      z[i] = X[i]*a;
29e444
-      u = (z[i] + CUTTER)-CUTTER;
29e444
-      if  (u > z[i])  u -= RADIX;
29e444
-      z[i] -= u;
29e444
-      z[i-1] += u*RADIXI;
29e444
-    }
29e444
-
29e444
-    u = (z[3] + TWO71) - TWO71;
29e444
-    if (u > z[3])   u -= TWO19;
29e444
-    v = z[3]-u;
29e444
-
29e444
-    if (v == TWO18) {
29e444
-      if (z[4] == ZERO) {
29e444
-        for (i=5; i <= p; i++) {
29e444
-          if (X[i] == ZERO)   continue;
29e444
-          else                {z[3] += ONE;   break; }
29e444
-        }
29e444
-      }
29e444
-      else              z[3] += ONE;
29e444
-    }
29e444
-
29e444
-    c = (z[1] + R *(z[2] + R * z[3]))/a;
29e444
-  }
29e444
-
29e444
-  c *= X[0];
29e444
-
29e444
-  for (i=1; i
29e444
-  for (i=1; i>EX; i--)   c *= RADIXI;
29e444
-
29e444
-  *y = c;
29e444
-  return;
29e444
-#undef R
29e444
-}
29e444
-
29e444
-/* Convert a multiple precision number *x into a double precision */
29e444
-/* number *y, denormalized case  (|x| < 2**(-1022))) */
29e444
-static void denorm(const mp_no *x, double *y, int p)
29e444
-{
29e444
-  long i,k;
29e444
-  long p2 = p;
29e444
-  double c,u,z[5];
29e444
-#if 0
29e444
-  double a,v;
29e444
-#endif
29e444
-
29e444
-#define R  radixi.d
29e444
-  if (EX<-44 || (EX==-44 && X[1]
29e444
-     { *y=ZERO; return; }
29e444
-
29e444
-  if      (p2==1) {
29e444
-    if      (EX==-42) {z[1]=X[1]+TWO10;  z[2]=ZERO;  z[3]=ZERO;  k=3;}
29e444
-    else if (EX==-43) {z[1]=     TWO10;  z[2]=X[1];  z[3]=ZERO;  k=2;}
29e444
-    else              {z[1]=     TWO10;  z[2]=ZERO;  z[3]=X[1];  k=1;}
29e444
-  }
29e444
-  else if (p2==2) {
29e444
-    if      (EX==-42) {z[1]=X[1]+TWO10;  z[2]=X[2];  z[3]=ZERO;  k=3;}
29e444
-    else if (EX==-43) {z[1]=     TWO10;  z[2]=X[1];  z[3]=X[2];  k=2;}
29e444
-    else              {z[1]=     TWO10;  z[2]=ZERO;  z[3]=X[1];  k=1;}
29e444
-  }
29e444
-  else {
29e444
-    if      (EX==-42) {z[1]=X[1]+TWO10;  z[2]=X[2];  k=3;}
29e444
-    else if (EX==-43) {z[1]=     TWO10;  z[2]=X[1];  k=2;}
29e444
-    else              {z[1]=     TWO10;  z[2]=ZERO;  k=1;}
29e444
-    z[3] = X[k];
29e444
-  }
29e444
-
29e444
-  u = (z[3] + TWO57) - TWO57;
29e444
-  if  (u > z[3])   u -= TWO5;
29e444
-
29e444
-  if (u==z[3]) {
29e444
-    for (i=k+1; i <= p2; i++) {
29e444
-      if (X[i] == ZERO)   continue;
29e444
-      else {z[3] += ONE;   break; }
29e444
-    }
29e444
-  }
29e444
-
29e444
-  c = X[0]*((z[1] + R*(z[2] + R*z[3])) - TWO10);
29e444
-
29e444
-  *y = c*TWOM1032;
29e444
-  return;
29e444
-
29e444
-#undef R
29e444
-}
29e444
-
29e444
-/* Convert a multiple precision number *x into a double precision number *y. */
29e444
-/* The result is correctly rounded to the nearest/even. *x is left unchanged */
29e444
-
29e444
-void __mp_dbl(const mp_no *x, double *y, int p) {
29e444
-#if 0
29e444
-  int i,k;
29e444
-  double a,c,u,v,z[5];
29e444
-#endif
29e444
-
29e444
-  if (X[0] == ZERO)  {*y = ZERO;  return; }
29e444
-
29e444
-  if      (EX> -42)                 norm(x,y,p);
29e444
-  else if (EX==-42 && X[1]>=TWO10)  norm(x,y,p);
29e444
-  else                              denorm(x,y,p);
29e444
-}
29e444
-
29e444
-
29e444
-/* dbl_mp() converts a double precision number x into a multiple precision  */
29e444
-/* number *y. If the precision p is too small the result is truncated. x is */
29e444
-/* left unchanged.                                                          */
29e444
-
29e444
-void __dbl_mp(double x, mp_no *y, int p) {
29e444
-
29e444
-  long i,n;
29e444
-  long p2 = p;
29e444
-  double u;
29e444
-
29e444
-  /* Sign */
29e444
-  if      (x == ZERO)  {Y[0] = ZERO;  return; }
29e444
-  else if (x >  ZERO)   Y[0] = ONE;
29e444
-  else                 {Y[0] = MONE;  x=-x;   }
29e444
-
29e444
-  /* Exponent */
29e444
-  for (EY=ONE; x >= RADIX; EY += ONE)   x *= RADIXI;
29e444
-  for (      ; x <  ONE;   EY -= ONE)   x *= RADIX;
29e444
-
29e444
-  /* Digits */
29e444
-  n=MIN(p2,4);
29e444
-  for (i=1; i<=n; i++) {
29e444
-    u = (x + TWO52) - TWO52;
29e444
-    if (u>x)   u -= ONE;
29e444
-    Y[i] = u;     x -= u;    x *= RADIX; }
29e444
-  for (   ; i<=p2; i++)     Y[i] = ZERO;
29e444
-  return;
29e444
-}
29e444
-
29e444
-
29e444
-/*  add_magnitudes() adds the magnitudes of *x & *y assuming that           */
29e444
-/*  abs(*x) >= abs(*y) > 0.                                                 */
29e444
-/* The sign of the sum *z is undefined. x&y may overlap but not x&z or y&z. */
29e444
-/* No guard digit is used. The result equals the exact sum, truncated.      */
29e444
-/* *x & *y are left unchanged.                                              */
29e444
-
29e444
-static void add_magnitudes(const mp_no *x, const mp_no *y, mp_no *z, int p) {
29e444
-
29e444
-  long i,j,k;
29e444
-  long p2 = p;
29e444
-
29e444
-  EZ = EX;
29e444
-
29e444
-  i=p2;    j=p2+ EY - EX;    k=p2+1;
29e444
-
29e444
-  if (j<1)
29e444
-     {__cpy(x,z,p);  return; }
29e444
-  else   Z[k] = ZERO;
29e444
-
29e444
-  for (; j>0; i--,j--) {
29e444
-    Z[k] += X[i] + Y[j];
29e444
-    if (Z[k] >= RADIX) {
29e444
-      Z[k]  -= RADIX;
29e444
-      Z[--k] = ONE; }
29e444
-    else
29e444
-      Z[--k] = ZERO;
29e444
-  }
29e444
-
29e444
-  for (; i>0; i--) {
29e444
-    Z[k] += X[i];
29e444
-    if (Z[k] >= RADIX) {
29e444
-      Z[k]  -= RADIX;
29e444
-      Z[--k] = ONE; }
29e444
-    else
29e444
-      Z[--k] = ZERO;
29e444
-  }
29e444
-
29e444
-  if (Z[1] == ZERO) {
29e444
-    for (i=1; i<=p2; i++)    Z[i] = Z[i+1]; }
29e444
-  else   EZ += ONE;
29e444
-}
29e444
-
29e444
-
29e444
-/*  sub_magnitudes() subtracts the magnitudes of *x & *y assuming that      */
29e444
-/*  abs(*x) > abs(*y) > 0.                                                  */
29e444
-/* The sign of the difference *z is undefined. x&y may overlap but not x&z  */
29e444
-/* or y&z. One guard digit is used. The error is less than one ulp.         */
29e444
-/* *x & *y are left unchanged.                                              */
29e444
-
29e444
-static void sub_magnitudes(const mp_no *x, const mp_no *y, mp_no *z, int p) {
29e444
-
29e444
-  long i,j,k;
29e444
-  long p2 = p;
29e444
-
29e444
-  EZ = EX;
29e444
-
29e444
-  if (EX == EY) {
29e444
-    i=j=k=p2;
29e444
-    Z[k] = Z[k+1] = ZERO; }
29e444
-  else {
29e444
-    j= EX - EY;
29e444
-    if (j > p2)  {__cpy(x,z,p);  return; }
29e444
-    else {
29e444
-      i=p2;   j=p2+1-j;   k=p2;
29e444
-      if (Y[j] > ZERO) {
29e444
-        Z[k+1] = RADIX - Y[j--];
29e444
-        Z[k]   = MONE; }
29e444
-      else {
29e444
-        Z[k+1] = ZERO;
29e444
-        Z[k]   = ZERO;   j--;}
29e444
-    }
29e444
-  }
29e444
-
29e444
-  for (; j>0; i--,j--) {
29e444
-    Z[k] += (X[i] - Y[j]);
29e444
-    if (Z[k] < ZERO) {
29e444
-      Z[k]  += RADIX;
29e444
-      Z[--k] = MONE; }
29e444
-    else
29e444
-      Z[--k] = ZERO;
29e444
-  }
29e444
-
29e444
-  for (; i>0; i--) {
29e444
-    Z[k] += X[i];
29e444
-    if (Z[k] < ZERO) {
29e444
-      Z[k]  += RADIX;
29e444
-      Z[--k] = MONE; }
29e444
-    else
29e444
-      Z[--k] = ZERO;
29e444
-  }
29e444
-
29e444
-  for (i=1; Z[i] == ZERO; i++) ;
29e444
-  EZ = EZ - i + 1;
29e444
-  for (k=1; i <= p2+1; )
29e444
-    Z[k++] = Z[i++];
29e444
-  for (; k <= p2; )
29e444
-    Z[k++] = ZERO;
29e444
-
29e444
-  return;
29e444
-}
29e444
-
29e444
-
29e444
-/* Add two multiple precision numbers. Set *z = *x + *y. x&y may overlap  */
29e444
-/* but not x&z or y&z. One guard digit is used. The error is less than    */
29e444
-/* one ulp. *x & *y are left unchanged.                                   */
29e444
-
29e444
-void __add(const mp_no *x, const mp_no *y, mp_no *z, int p) {
29e444
-
29e444
-  int n;
29e444
-
29e444
-  if      (X[0] == ZERO)     {__cpy(y,z,p);  return; }
29e444
-  else if (Y[0] == ZERO)     {__cpy(x,z,p);  return; }
29e444
-
29e444
-  if (X[0] == Y[0])   {
29e444
-    if (__acr(x,y,p) > 0)      {add_magnitudes(x,y,z,p);  Z[0] = X[0]; }
29e444
-    else                     {add_magnitudes(y,x,z,p);  Z[0] = Y[0]; }
29e444
-  }
29e444
-  else                       {
29e444
-    if ((n=__acr(x,y,p)) == 1) {sub_magnitudes(x,y,z,p);  Z[0] = X[0]; }
29e444
-    else if (n == -1)        {sub_magnitudes(y,x,z,p);  Z[0] = Y[0]; }
29e444
-    else                      Z[0] = ZERO;
29e444
-  }
29e444
-  return;
29e444
-}
29e444
-
29e444
-
29e444
-/* Subtract two multiple precision numbers. *z is set to *x - *y. x&y may */
29e444
-/* overlap but not x&z or y&z. One guard digit is used. The error is      */
29e444
-/* less than one ulp. *x & *y are left unchanged.                         */
29e444
-
29e444
-void __sub(const mp_no *x, const mp_no *y, mp_no *z, int p) {
29e444
-
29e444
-  int n;
29e444
-
29e444
-  if      (X[0] == ZERO)     {__cpy(y,z,p);  Z[0] = -Z[0];  return; }
29e444
-  else if (Y[0] == ZERO)     {__cpy(x,z,p);                 return; }
29e444
-
29e444
-  if (X[0] != Y[0])    {
29e444
-    if (__acr(x,y,p) > 0)      {add_magnitudes(x,y,z,p);  Z[0] =  X[0]; }
29e444
-    else                     {add_magnitudes(y,x,z,p);  Z[0] = -Y[0]; }
29e444
-  }
29e444
-  else                       {
29e444
-    if ((n=__acr(x,y,p)) == 1) {sub_magnitudes(x,y,z,p);  Z[0] =  X[0]; }
29e444
-    else if (n == -1)        {sub_magnitudes(y,x,z,p);  Z[0] = -Y[0]; }
29e444
-    else                      Z[0] = ZERO;
29e444
-  }
29e444
-  return;
29e444
-}
29e444
-
29e444
-
29e444
-/* Multiply two multiple precision numbers. *z is set to *x * *y. x&y      */
29e444
-/* may overlap but not x&z or y&z. In case p=1,2,3 the exact result is     */
29e444
-/* truncated to p digits. In case p>3 the error is bounded by 1.001 ulp.   */
29e444
-/* *x & *y are left unchanged.                                             */
29e444
-
29e444
-void __mul(const mp_no *x, const mp_no *y, mp_no *z, int p) {
29e444
-
29e444
-  long i, i1, i2, j, k, k2;
29e444
-  long p2 = p;
29e444
-  double u, zk, zk2;
29e444
-
29e444
-                      /* Is z=0? */
29e444
-  if (X[0]*Y[0]==ZERO)
29e444
-     { Z[0]=ZERO;  return; }
29e444
-
29e444
-                       /* Multiply, add and carry */
29e444
-  k2 = (p2<3) ? p2+p2 : p2+3;
29e444
-  zk = Z[k2]=ZERO;
29e444
-  for (k=k2; k>1; ) {
29e444
-    if (k > p2)  {i1=k-p2; i2=p2+1; }
29e444
-    else        {i1=1;   i2=k;   }
29e444
-#if 1
29e444
-    /* rearange this inner loop to allow the fmadd instructions to be
29e444
-       independent and execute in parallel on processors that have
29e444
-       dual symetrical FP pipelines.  */
29e444
-    if (i1 < (i2-1))
29e444
-    {
29e444
-	/* make sure we have at least 2 iterations */
29e444
-	if (((i2 - i1) & 1L) == 1L)
29e444
-	{
29e444
-                /* Handle the odd iterations case.  */
29e444
-		zk2 = x->d[i2-1]*y->d[i1];
29e444
-	}
29e444
-	else
29e444
-		zk2 = zero.d;
29e444
-	/* Do two multiply/adds per loop iteration, using independent
29e444
-           accumulators; zk and zk2.  */
29e444
-	for (i=i1,j=i2-1; i
29e444
-	{
29e444
-		zk += x->d[i]*y->d[j];
29e444
-		zk2 += x->d[i+1]*y->d[j-1];
29e444
-	}
29e444
-	zk += zk2; /* final sum.  */
29e444
-    }
29e444
-    else
29e444
-    {
29e444
-        /* Special case when iterations is 1.  */
29e444
-	zk += x->d[i1]*y->d[i1];
29e444
-    }
29e444
-#else
29e444
-    /* The orginal code.  */
29e444
-    for (i=i1,j=i2-1; i
29e444
-#endif
29e444
-
29e444
-    u = (zk + CUTTER)-CUTTER;
29e444
-    if  (u > zk)  u -= RADIX;
29e444
-    Z[k]  = zk - u;
29e444
-    zk = u*RADIXI;
29e444
-    --k;
29e444
-  }
29e444
-  Z[k] = zk;
29e444
-
29e444
-                 /* Is there a carry beyond the most significant digit? */
29e444
-  if (Z[1] == ZERO) {
29e444
-    for (i=1; i<=p2; i++)  Z[i]=Z[i+1];
29e444
-    EZ = EX + EY - 1; }
29e444
-  else
29e444
-    EZ = EX + EY;
29e444
-
29e444
-  Z[0] = X[0] * Y[0];
29e444
-  return;
29e444
-}
29e444
-
29e444
-
29e444
-/* Invert a multiple precision number. Set *y = 1 / *x.                     */
29e444
-/* Relative error bound = 1.001*r**(1-p) for p=2, 1.063*r**(1-p) for p=3,   */
29e444
-/* 2.001*r**(1-p) for p>3.                                                  */
29e444
-/* *x=0 is not permissible. *x is left unchanged.                           */
29e444
-
29e444
-void __inv(const mp_no *x, mp_no *y, int p) {
29e444
-  long i;
29e444
-#if 0
29e444
-  int l;
29e444
-#endif
29e444
-  double t;
29e444
-  mp_no z,w;
29e444
-  static const int np1[] = {0,0,0,0,1,2,2,2,2,3,3,3,3,3,3,3,3,3,
29e444
-                            4,4,4,4,4,4,4,4,4,4,4,4,4,4,4};
29e444
-  const mp_no mptwo = {1,{1.0,2.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
29e444
-                         0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
29e444
-                         0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
29e444
-                         0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}};
29e444
-
29e444
-  __cpy(x,&z,p);  z.e=0;  __mp_dbl(&z,&t,p);
29e444
-  t=ONE/t;   __dbl_mp(t,y,p);    EY -= EX;
29e444
-
29e444
-  for (i=0; i
29e444
-    __cpy(y,&w,p);
29e444
-    __mul(x,&w,y,p);
29e444
-    __sub(&mptwo,y,&z,p);
29e444
-    __mul(&w,&z,y,p);
29e444
-  }
29e444
-  return;
29e444
-}
29e444
-
29e444
-
29e444
-/* Divide one multiple precision number by another.Set *z = *x / *y. *x & *y */
29e444
-/* are left unchanged. x&y may overlap but not x&z or y&z.                   */
29e444
-/* Relative error bound = 2.001*r**(1-p) for p=2, 2.063*r**(1-p) for p=3     */
29e444
-/* and 3.001*r**(1-p) for p>3. *y=0 is not permissible.                      */
29e444
-
29e444
-void __dvd(const mp_no *x, const mp_no *y, mp_no *z, int p) {
29e444
-
29e444
-  mp_no w;
29e444
-
29e444
-  if (X[0] == ZERO)    Z[0] = ZERO;
29e444
-  else                {__inv(y,&w,p);   __mul(x,&w,z,p);}
29e444
-  return;
29e444
-}
29e444
-- 
29e444
1.7.11.7
29e444