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