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