patches/glibc/ports-2.10.1/470-alpha-floor_ceil_fix.patch
author Arnaud Lacombe <lacombar@gmail.com>
Thu Aug 05 17:59:51 2010 +0200 (2010-08-05)
changeset 2069 366bd2b22675
permissions -rw-r--r--
complibs/mpc: fix MPC 0.8.1 build with MPFR 3.0.0

This is the change introduced by revision 734 of MPC repository.

Author: Paul Zimmermann <Paul.Zimmermann@loria.fr>
Revision log: [acos.c] fixed problem with GMP_RNDA (should be MPFR_RNDA, and code was wrong)

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
     1 http://sources.redhat.com/bugzilla/show_bug.cgi?id=5350
     2 https://bugs.gentoo.org/264335
     3 
     4 diff -durN glibc-2.10.1.orig/glibc-ports-2.10.1/sysdeps/alpha/fpu/s_ceil.c glibc-2.10.1/glibc-ports-2.10.1/sysdeps/alpha/fpu/s_ceil.c
     5 --- glibc-2.10.1.orig/glibc-ports-2.10.1/sysdeps/alpha/fpu/s_ceil.c	2009-05-16 10:36:20.000000000 +0200
     6 +++ glibc-2.10.1/glibc-ports-2.10.1/sysdeps/alpha/fpu/s_ceil.c	2009-11-13 00:50:59.000000000 +0100
     7 @@ -27,20 +27,25 @@
     8  double
     9  __ceil (double x)
    10  {
    11 -  double two52 = copysign (0x1.0p52, x);
    12 -  double r, tmp;
    13 -  
    14 -  __asm (
    15 +  if (isless (fabs (x), 9007199254740992.0))	/* 1 << DBL_MANT_DIG */
    16 +    {
    17 +      double tmp1, new_x;
    18 +
    19 +      new_x = -x;
    20 +      __asm (
    21  #ifdef _IEEE_FP_INEXACT
    22 -	 "addt/suim %2, %3, %1\n\tsubt/suim %1, %3, %0"
    23 +	     "cvttq/svim %2,%1\n\t"
    24  #else
    25 -	 "addt/sum %2, %3, %1\n\tsubt/sum %1, %3, %0"
    26 +	     "cvttq/svm %2,%1\n\t"
    27  #endif
    28 -	 : "=&f"(r), "=&f"(tmp)
    29 -	 : "f"(-x), "f"(-two52));
    30 +	     "cvtqt/m %1,%0\n\t"
    31 +	     : "=f"(new_x), "=&f"(tmp1)
    32 +	     : "f"(new_x));
    33  
    34 -  /* Fix up the negation we did above, as well as handling -0 properly. */
    35 -  return copysign (r, x);
    36 +      /* Fix up the negation we did above, as well as handling -0 properly. */
    37 +      x = copysign(new_x, x);
    38 +    }
    39 +  return x;
    40  }
    41  
    42  weak_alias (__ceil, ceil)
    43 diff -durN glibc-2.10.1.orig/glibc-ports-2.10.1/sysdeps/alpha/fpu/s_ceilf.c glibc-2.10.1/glibc-ports-2.10.1/sysdeps/alpha/fpu/s_ceilf.c
    44 --- glibc-2.10.1.orig/glibc-ports-2.10.1/sysdeps/alpha/fpu/s_ceilf.c	2009-05-16 10:36:20.000000000 +0200
    45 +++ glibc-2.10.1/glibc-ports-2.10.1/sysdeps/alpha/fpu/s_ceilf.c	2009-11-13 00:50:59.000000000 +0100
    46 @@ -26,20 +26,30 @@
    47  float
    48  __ceilf (float x)
    49  {
    50 -  float two23 = copysignf (0x1.0p23, x);
    51 -  float r, tmp;
    52 -  
    53 -  __asm (
    54 +  if (isless (fabsf (x), 16777216.0f))	/* 1 << FLT_MANT_DIG */
    55 +    {
    56 +      /* Note that Alpha S_Floating is stored in registers in a
    57 +	 restricted T_Floating format, so we don't even need to
    58 +	 convert back to S_Floating in the end.  The initial
    59 +	 conversion to T_Floating is needed to handle denormals.  */
    60 +
    61 +      float tmp1, tmp2, new_x;
    62 +
    63 +      new_x = -x;
    64 +      __asm ("cvtst/s %3,%2\n\t"
    65  #ifdef _IEEE_FP_INEXACT
    66 -	 "adds/suim %2, %3, %1\n\tsubs/suim %1, %3, %0"
    67 +	     "cvttq/svim %2,%1\n\t"
    68  #else
    69 -	 "adds/sum %2, %3, %1\n\tsubs/sum %1, %3, %0"
    70 +	     "cvttq/svm %2,%1\n\t"
    71  #endif
    72 -	 : "=&f"(r), "=&f"(tmp)
    73 -	 : "f"(-x), "f"(-two23));
    74 +	     "cvtqt/m %1,%0\n\t"
    75 +	     : "=f"(new_x), "=&f"(tmp1), "=&f"(tmp2)
    76 +	     : "f"(new_x));
    77  
    78 -  /* Fix up the negation we did above, as well as handling -0 properly. */
    79 -  return copysignf (r, x);
    80 +      /* Fix up the negation we did above, as well as handling -0 properly. */
    81 +      x = copysignf(new_x, x);
    82 +    }
    83 +  return x;
    84  }
    85  
    86  weak_alias (__ceilf, ceilf)
    87 diff -durN glibc-2.10.1.orig/glibc-ports-2.10.1/sysdeps/alpha/fpu/s_floor.c glibc-2.10.1/glibc-ports-2.10.1/sysdeps/alpha/fpu/s_floor.c
    88 --- glibc-2.10.1.orig/glibc-ports-2.10.1/sysdeps/alpha/fpu/s_floor.c	2009-05-16 10:36:20.000000000 +0200
    89 +++ glibc-2.10.1/glibc-ports-2.10.1/sysdeps/alpha/fpu/s_floor.c	2009-11-13 00:50:59.000000000 +0100
    90 @@ -21,26 +21,32 @@
    91  #include <math_ldbl_opt.h>
    92  
    93  
    94 -/* Use the -inf rounding mode conversion instructions to implement floor.  */
    95 +/* Use the -inf rounding mode conversion instructions to implement
    96 +   floor.  We note when the exponent is large enough that the value
    97 +   must be integral, as this avoids unpleasant integer overflows.  */
    98  
    99  double
   100  __floor (double x)
   101  {
   102 -  double two52 = copysign (0x1.0p52, x);
   103 -  double r, tmp;
   104 -  
   105 -  __asm (
   106 +  if (isless (fabs (x), 9007199254740992.0))	/* 1 << DBL_MANT_DIG */
   107 +    {
   108 +      double tmp1, new_x;
   109 +
   110 +      __asm (
   111  #ifdef _IEEE_FP_INEXACT
   112 -	 "addt/suim %2, %3, %1\n\tsubt/suim %1, %3, %0"
   113 +	     "cvttq/svim %2,%1\n\t"
   114  #else
   115 -	 "addt/sum %2, %3, %1\n\tsubt/sum %1, %3, %0"
   116 +	     "cvttq/svm %2,%1\n\t"
   117  #endif
   118 -	 : "=&f"(r), "=&f"(tmp)
   119 -	 : "f"(x), "f"(two52));
   120 +	     "cvtqt/m %1,%0\n\t"
   121 +	     : "=f"(new_x), "=&f"(tmp1)
   122 +	     : "f"(x));
   123  
   124 -  /* floor(-0) == -0, and in general we'll always have the same
   125 -     sign as our input.  */
   126 -  return copysign (r, x);
   127 +      /* floor(-0) == -0, and in general we'll always have the same
   128 +	 sign as our input.  */
   129 +      x = copysign(new_x, x);
   130 +    }
   131 +  return x;
   132  }
   133  
   134  weak_alias (__floor, floor)
   135 diff -durN glibc-2.10.1.orig/glibc-ports-2.10.1/sysdeps/alpha/fpu/s_floorf.c glibc-2.10.1/glibc-ports-2.10.1/sysdeps/alpha/fpu/s_floorf.c
   136 --- glibc-2.10.1.orig/glibc-ports-2.10.1/sysdeps/alpha/fpu/s_floorf.c	2009-05-16 10:36:20.000000000 +0200
   137 +++ glibc-2.10.1/glibc-ports-2.10.1/sysdeps/alpha/fpu/s_floorf.c	2009-11-13 00:50:59.000000000 +0100
   138 @@ -20,26 +20,37 @@
   139  #include <math.h>
   140  
   141  
   142 -/* Use the -inf rounding mode conversion instructions to implement floor.  */
   143 +/* Use the -inf rounding mode conversion instructions to implement
   144 +   floor.  We note when the exponent is large enough that the value
   145 +   must be integral, as this avoids unpleasant integer overflows.  */
   146  
   147  float
   148  __floorf (float x)
   149  {
   150 -  float two23 = copysignf (0x1.0p23, x);
   151 -  float r, tmp;
   152 -  
   153 -  __asm (
   154 +  if (isless (fabsf (x), 16777216.0f))	/* 1 << FLT_MANT_DIG */
   155 +    {
   156 +      /* Note that Alpha S_Floating is stored in registers in a
   157 +	 restricted T_Floating format, so we don't even need to
   158 +	 convert back to S_Floating in the end.  The initial
   159 +	 conversion to T_Floating is needed to handle denormals.  */
   160 +
   161 +      float tmp1, tmp2, new_x;
   162 +
   163 +      __asm ("cvtst/s %3,%2\n\t"
   164  #ifdef _IEEE_FP_INEXACT
   165 -	 "adds/suim %2, %3, %1\n\tsubs/suim %1, %3, %0"
   166 +	     "cvttq/svim %2,%1\n\t"
   167  #else
   168 -	 "adds/sum %2, %3, %1\n\tsubs/sum %1, %3, %0"
   169 +	     "cvttq/svm %2,%1\n\t"
   170  #endif
   171 -	 : "=&f"(r), "=&f"(tmp)
   172 -	 : "f"(x), "f"(two23));
   173 +	     "cvtqt/m %1,%0\n\t"
   174 +	     : "=f"(new_x), "=&f"(tmp1), "=&f"(tmp2)
   175 +	     : "f"(x));
   176  
   177 -  /* floor(-0) == -0, and in general we'll always have the same
   178 -     sign as our input.  */
   179 -  return copysignf (r, x);
   180 +      /* floor(-0) == -0, and in general we'll always have the same
   181 +	 sign as our input.  */
   182 +      x = copysignf(new_x, x);
   183 +    }
   184 +  return x;
   185  }
   186  
   187  weak_alias (__floorf, floorf)
   188 diff -durN glibc-2.10.1.orig/glibc-ports-2.10.1/sysdeps/alpha/fpu/s_rint.c glibc-2.10.1/glibc-ports-2.10.1/sysdeps/alpha/fpu/s_rint.c
   189 --- glibc-2.10.1.orig/glibc-ports-2.10.1/sysdeps/alpha/fpu/s_rint.c	2009-05-16 10:36:20.000000000 +0200
   190 +++ glibc-2.10.1/glibc-ports-2.10.1/sysdeps/alpha/fpu/s_rint.c	2009-11-13 00:50:59.000000000 +0100
   191 @@ -24,15 +24,24 @@
   192  double
   193  __rint (double x)
   194  {
   195 -  double two52 = copysign (0x1.0p52, x);
   196 -  double r;
   197 -  
   198 -  r = x + two52;
   199 -  r = r - two52;
   200 +  if (isless (fabs (x), 9007199254740992.0))	/* 1 << DBL_MANT_DIG */
   201 +    {
   202 +      double tmp1, new_x;
   203 +      __asm (
   204 +#ifdef _IEEE_FP_INEXACT
   205 +	     "cvttq/svid %2,%1\n\t"
   206 +#else
   207 +	     "cvttq/svd %2,%1\n\t"
   208 +#endif
   209 +	     "cvtqt/d %1,%0\n\t"
   210 +	     : "=f"(new_x), "=&f"(tmp1)
   211 +	     : "f"(x));
   212  
   213 -  /* rint(-0.1) == -0, and in general we'll always have the same sign
   214 -     as our input.  */
   215 -  return copysign (r, x);
   216 +      /* rint(-0.1) == -0, and in general we'll always have the same
   217 +	 sign as our input.  */
   218 +      x = copysign(new_x, x);
   219 +    }
   220 +  return x;
   221  }
   222  
   223  weak_alias (__rint, rint)
   224 diff -durN glibc-2.10.1.orig/glibc-ports-2.10.1/sysdeps/alpha/fpu/s_rintf.c glibc-2.10.1/glibc-ports-2.10.1/sysdeps/alpha/fpu/s_rintf.c
   225 --- glibc-2.10.1.orig/glibc-ports-2.10.1/sysdeps/alpha/fpu/s_rintf.c	2009-05-16 10:36:20.000000000 +0200
   226 +++ glibc-2.10.1/glibc-ports-2.10.1/sysdeps/alpha/fpu/s_rintf.c	2009-11-13 00:50:59.000000000 +0100
   227 @@ -23,15 +23,30 @@
   228  float
   229  __rintf (float x)
   230  {
   231 -  float two23 = copysignf (0x1.0p23, x);
   232 -  float r;
   233 +  if (isless (fabsf (x), 16777216.0f))	/* 1 << FLT_MANT_DIG */
   234 +    {
   235 +      /* Note that Alpha S_Floating is stored in registers in a
   236 +	 restricted T_Floating format, so we don't even need to
   237 +	 convert back to S_Floating in the end.  The initial
   238 +	 conversion to T_Floating is needed to handle denormals.  */
   239  
   240 -  r = x + two23;
   241 -  r = r - two23;
   242 +      float tmp1, tmp2, new_x;
   243  
   244 -  /* rint(-0.1) == -0, and in general we'll always have the same sign
   245 -     as our input.  */
   246 -  return copysign (r, x);
   247 +      __asm ("cvtst/s %3,%2\n\t"
   248 +#ifdef _IEEE_FP_INEXACT
   249 +	     "cvttq/svid %2,%1\n\t"
   250 +#else
   251 +	     "cvttq/svd %2,%1\n\t"
   252 +#endif
   253 +	     "cvtqt/d %1,%0\n\t"
   254 +	     : "=f"(new_x), "=&f"(tmp1), "=&f"(tmp2)
   255 +	     : "f"(x));
   256 +
   257 +      /* rint(-0.1) == -0, and in general we'll always have the same
   258 +	 sign as our input.  */
   259 +      x = copysignf(new_x, x);
   260 +    }
   261 +  return x;
   262  }
   263  
   264  weak_alias (__rintf, rintf)
   265 diff -durN glibc-2.10.1.orig/ports/sysdeps/alpha/fpu/s_ceil.c glibc-2.10.1/ports/sysdeps/alpha/fpu/s_ceil.c
   266 diff -durN glibc-2.10.1.orig/ports/sysdeps/alpha/fpu/s_ceilf.c glibc-2.10.1/ports/sysdeps/alpha/fpu/s_ceilf.c
   267 diff -durN glibc-2.10.1.orig/ports/sysdeps/alpha/fpu/s_floor.c glibc-2.10.1/ports/sysdeps/alpha/fpu/s_floor.c
   268 diff -durN glibc-2.10.1.orig/ports/sysdeps/alpha/fpu/s_floorf.c glibc-2.10.1/ports/sysdeps/alpha/fpu/s_floorf.c
   269 diff -durN glibc-2.10.1.orig/ports/sysdeps/alpha/fpu/s_rint.c glibc-2.10.1/ports/sysdeps/alpha/fpu/s_rint.c
   270 diff -durN glibc-2.10.1.orig/ports/sysdeps/alpha/fpu/s_rintf.c glibc-2.10.1/ports/sysdeps/alpha/fpu/s_rintf.c