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