]>
Commit | Line | Data |
---|---|---|
d5efd131 MF |
1 | .file "expf_m1.s" |
2 | ||
3 | ||
4 | // Copyright (c) 2000 - 2005, Intel Corporation | |
5 | // All rights reserved. | |
6 | // | |
d5efd131 MF |
7 | // |
8 | // Redistribution and use in source and binary forms, with or without | |
9 | // modification, are permitted provided that the following conditions are | |
10 | // met: | |
11 | // | |
12 | // * Redistributions of source code must retain the above copyright | |
13 | // notice, this list of conditions and the following disclaimer. | |
14 | // | |
15 | // * Redistributions in binary form must reproduce the above copyright | |
16 | // notice, this list of conditions and the following disclaimer in the | |
17 | // documentation and/or other materials provided with the distribution. | |
18 | // | |
19 | // * The name of Intel Corporation may not be used to endorse or promote | |
20 | // products derived from this software without specific prior written | |
21 | // permission. | |
22 | ||
23 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
24 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
25 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
26 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS | |
27 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
28 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
29 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
30 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
31 | // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING | |
32 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
33 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
34 | // | |
35 | // Intel Corporation is the author of this code, and requests that all | |
36 | // problem reports or change requests be submitted to it directly at | |
37 | // http://www.intel.com/software/products/opensource/libraries/num.htm. | |
38 | ||
39 | // History | |
40 | //********************************************************************* | |
41 | // 02/02/00 Initial Version | |
42 | // 04/04/00 Unwind support added | |
43 | // 08/15/00 Bundle added after call to __libm_error_support to properly | |
44 | // set [the previously overwritten] GR_Parameter_RESULT. | |
45 | // 07/07/01 Improved speed of all paths | |
46 | // 05/20/02 Cleaned up namespace and sf0 syntax | |
47 | // 11/20/02 Improved speed, algorithm based on expf | |
48 | // 03/31/05 Reformatted delimiters between data tables | |
49 | // | |
50 | // | |
51 | // API | |
52 | //********************************************************************* | |
53 | // float expm1f(float) | |
54 | // | |
55 | // Overview of operation | |
56 | //********************************************************************* | |
57 | // 1. Inputs of Nan, Inf, Zero, NatVal handled with special paths | |
58 | // | |
59 | // 2. |x| < 2^-40 | |
60 | // Result = x, computed by x + x*x to handle appropriate flags and rounding | |
61 | // | |
62 | // 3. 2^-40 <= |x| < 2^-2 | |
63 | // Result determined by 8th order Taylor series polynomial | |
64 | // expm1f(x) = x + A2*x^2 + ... + A8*x^8 | |
65 | // | |
66 | // 4. x < -24.0 | |
67 | // Here we know result is essentially -1 + eps, where eps only affects | |
68 | // rounded result. Set I. | |
69 | // | |
0347518d | 70 | // 5. x >= 88.7228 |
d5efd131 MF |
71 | // Result overflows. Set I, O, and call error support |
72 | // | |
0347518d | 73 | // 6. 2^-2 <= x < 88.7228 or -24.0 <= x < -2^-2 |
d5efd131 MF |
74 | // This is the main path. The algorithm is described below: |
75 | ||
76 | // Take the input x. w is "how many log2/128 in x?" | |
77 | // w = x * 64/log2 | |
78 | // NJ = int(w) | |
79 | // x = NJ*log2/64 + R | |
80 | ||
81 | // NJ = 64*n + j | |
82 | // x = n*log2 + (log2/64)*j + R | |
83 | // | |
84 | // So, exp(x) = 2^n * 2^(j/64)* exp(R) | |
85 | // | |
86 | // T = 2^n * 2^(j/64) | |
87 | // Construct 2^n | |
88 | // Get 2^(j/64) table | |
89 | // actually all the entries of 2^(j/64) table are stored in DP and | |
90 | // with exponent bits set to 0 -> multiplication on 2^n can be | |
91 | // performed by doing logical "or" operation with bits presenting 2^n | |
92 | ||
93 | // exp(R) = 1 + (exp(R) - 1) | |
94 | // P = exp(R) - 1 approximated by Taylor series of 3rd degree | |
95 | // P = A3*R^3 + A2*R^2 + R, A3 = 1/6, A2 = 1/2 | |
96 | // | |
97 | ||
98 | // The final result is reconstructed as follows | |
99 | // expm1f(x) = T*P + (T - 1.0) | |
100 | ||
101 | // Special values | |
102 | //********************************************************************* | |
103 | // expm1f(+0) = +0.0 | |
104 | // expm1f(-0) = -0.0 | |
105 | ||
106 | // expm1f(+qnan) = +qnan | |
107 | // expm1f(-qnan) = -qnan | |
108 | // expm1f(+snan) = +qnan | |
109 | // expm1f(-snan) = -qnan | |
110 | ||
111 | // expm1f(-inf) = -1.0 | |
112 | // expm1f(+inf) = +inf | |
113 | ||
114 | // Overflow and Underflow | |
115 | //********************************************************************* | |
116 | // expm1f(x) = largest single normal when | |
117 | // x = 88.7228 = 0x42b17217 | |
118 | // | |
119 | // Underflow is handled as described in case 2 above. | |
120 | ||
121 | ||
122 | // Registers used | |
123 | //********************************************************************* | |
124 | // Floating Point registers used: | |
125 | // f8, input | |
126 | // f6,f7, f9 -> f15, f32 -> f45 | |
127 | ||
128 | // General registers used: | |
129 | // r3, r20 -> r38 | |
130 | ||
131 | // Predicate registers used: | |
132 | // p9 -> p15 | |
133 | ||
134 | // Assembly macros | |
135 | //********************************************************************* | |
136 | // integer registers used | |
137 | // scratch | |
138 | rNJ = r3 | |
139 | ||
140 | rExp_half = r20 | |
141 | rSignexp_x = r21 | |
142 | rExp_x = r22 | |
143 | rExp_mask = r23 | |
144 | rExp_bias = r24 | |
145 | rTmp = r25 | |
146 | rM1_lim = r25 | |
147 | rGt_ln = r25 | |
148 | rJ = r26 | |
149 | rN = r27 | |
150 | rTblAddr = r28 | |
151 | rLn2Div64 = r29 | |
152 | rRightShifter = r30 | |
153 | r64DivLn2 = r31 | |
154 | // stacked | |
155 | GR_SAVE_PFS = r32 | |
156 | GR_SAVE_B0 = r33 | |
157 | GR_SAVE_GP = r34 | |
158 | GR_Parameter_X = r35 | |
159 | GR_Parameter_Y = r36 | |
160 | GR_Parameter_RESULT = r37 | |
161 | GR_Parameter_TAG = r38 | |
162 | ||
163 | // floating point registers used | |
164 | FR_X = f10 | |
165 | FR_Y = f1 | |
166 | FR_RESULT = f8 | |
167 | // scratch | |
168 | fRightShifter = f6 | |
169 | f64DivLn2 = f7 | |
170 | fNormX = f9 | |
171 | fNint = f10 | |
172 | fN = f11 | |
173 | fR = f12 | |
174 | fLn2Div64 = f13 | |
175 | fA2 = f14 | |
176 | fA3 = f15 | |
177 | // stacked | |
178 | fP = f32 | |
179 | fX3 = f33 | |
180 | fT = f34 | |
181 | fMIN_SGL_OFLOW_ARG = f35 | |
182 | fMAX_SGL_NORM_ARG = f36 | |
183 | fMAX_SGL_MINUS_1_ARG = f37 | |
184 | fA4 = f38 | |
185 | fA43 = f38 | |
186 | fA432 = f38 | |
187 | fRSqr = f39 | |
188 | fA5 = f40 | |
189 | fTmp = f41 | |
190 | fGt_pln = f41 | |
191 | fXsq = f41 | |
192 | fA7 = f42 | |
193 | fA6 = f43 | |
194 | fA65 = f43 | |
195 | fTm1 = f44 | |
196 | fA8 = f45 | |
197 | fA87 = f45 | |
198 | fA8765 = f45 | |
199 | fA8765432 = f45 | |
200 | fWre_urm_f8 = f45 | |
201 | ||
202 | RODATA | |
203 | .align 16 | |
204 | LOCAL_OBJECT_START(_expf_table) | |
205 | data8 0x3efa01a01a01a01a // A8 = 1/8! | |
206 | data8 0x3f2a01a01a01a01a // A7 = 1/7! | |
207 | data8 0x3f56c16c16c16c17 // A6 = 1/6! | |
208 | data8 0x3f81111111111111 // A5 = 1/5! | |
209 | data8 0x3fa5555555555555 // A4 = 1/4! | |
210 | data8 0x3fc5555555555555 // A3 = 1/3! | |
211 | // | |
212 | data4 0x42b17218 // Smallest sgl arg to overflow sgl result | |
213 | data4 0x42b17217 // Largest sgl arg to give sgl result | |
214 | // | |
215 | // 2^(j/64) table, j goes from 0 to 63 | |
216 | data8 0x0000000000000000 // 2^(0/64) | |
217 | data8 0x00002C9A3E778061 // 2^(1/64) | |
218 | data8 0x000059B0D3158574 // 2^(2/64) | |
219 | data8 0x0000874518759BC8 // 2^(3/64) | |
220 | data8 0x0000B5586CF9890F // 2^(4/64) | |
221 | data8 0x0000E3EC32D3D1A2 // 2^(5/64) | |
222 | data8 0x00011301D0125B51 // 2^(6/64) | |
223 | data8 0x0001429AAEA92DE0 // 2^(7/64) | |
224 | data8 0x000172B83C7D517B // 2^(8/64) | |
225 | data8 0x0001A35BEB6FCB75 // 2^(9/64) | |
226 | data8 0x0001D4873168B9AA // 2^(10/64) | |
227 | data8 0x0002063B88628CD6 // 2^(11/64) | |
228 | data8 0x0002387A6E756238 // 2^(12/64) | |
229 | data8 0x00026B4565E27CDD // 2^(13/64) | |
230 | data8 0x00029E9DF51FDEE1 // 2^(14/64) | |
231 | data8 0x0002D285A6E4030B // 2^(15/64) | |
232 | data8 0x000306FE0A31B715 // 2^(16/64) | |
233 | data8 0x00033C08B26416FF // 2^(17/64) | |
234 | data8 0x000371A7373AA9CB // 2^(18/64) | |
235 | data8 0x0003A7DB34E59FF7 // 2^(19/64) | |
236 | data8 0x0003DEA64C123422 // 2^(20/64) | |
237 | data8 0x0004160A21F72E2A // 2^(21/64) | |
238 | data8 0x00044E086061892D // 2^(22/64) | |
239 | data8 0x000486A2B5C13CD0 // 2^(23/64) | |
240 | data8 0x0004BFDAD5362A27 // 2^(24/64) | |
241 | data8 0x0004F9B2769D2CA7 // 2^(25/64) | |
242 | data8 0x0005342B569D4F82 // 2^(26/64) | |
243 | data8 0x00056F4736B527DA // 2^(27/64) | |
244 | data8 0x0005AB07DD485429 // 2^(28/64) | |
245 | data8 0x0005E76F15AD2148 // 2^(29/64) | |
246 | data8 0x0006247EB03A5585 // 2^(30/64) | |
247 | data8 0x0006623882552225 // 2^(31/64) | |
248 | data8 0x0006A09E667F3BCD // 2^(32/64) | |
249 | data8 0x0006DFB23C651A2F // 2^(33/64) | |
250 | data8 0x00071F75E8EC5F74 // 2^(34/64) | |
251 | data8 0x00075FEB564267C9 // 2^(35/64) | |
252 | data8 0x0007A11473EB0187 // 2^(36/64) | |
253 | data8 0x0007E2F336CF4E62 // 2^(37/64) | |
254 | data8 0x00082589994CCE13 // 2^(38/64) | |
255 | data8 0x000868D99B4492ED // 2^(39/64) | |
256 | data8 0x0008ACE5422AA0DB // 2^(40/64) | |
257 | data8 0x0008F1AE99157736 // 2^(41/64) | |
258 | data8 0x00093737B0CDC5E5 // 2^(42/64) | |
259 | data8 0x00097D829FDE4E50 // 2^(43/64) | |
260 | data8 0x0009C49182A3F090 // 2^(44/64) | |
261 | data8 0x000A0C667B5DE565 // 2^(45/64) | |
262 | data8 0x000A5503B23E255D // 2^(46/64) | |
263 | data8 0x000A9E6B5579FDBF // 2^(47/64) | |
264 | data8 0x000AE89F995AD3AD // 2^(48/64) | |
265 | data8 0x000B33A2B84F15FB // 2^(49/64) | |
266 | data8 0x000B7F76F2FB5E47 // 2^(50/64) | |
267 | data8 0x000BCC1E904BC1D2 // 2^(51/64) | |
268 | data8 0x000C199BDD85529C // 2^(52/64) | |
269 | data8 0x000C67F12E57D14B // 2^(53/64) | |
270 | data8 0x000CB720DCEF9069 // 2^(54/64) | |
271 | data8 0x000D072D4A07897C // 2^(55/64) | |
272 | data8 0x000D5818DCFBA487 // 2^(56/64) | |
273 | data8 0x000DA9E603DB3285 // 2^(57/64) | |
274 | data8 0x000DFC97337B9B5F // 2^(58/64) | |
275 | data8 0x000E502EE78B3FF6 // 2^(59/64) | |
276 | data8 0x000EA4AFA2A490DA // 2^(60/64) | |
277 | data8 0x000EFA1BEE615A27 // 2^(61/64) | |
278 | data8 0x000F50765B6E4540 // 2^(62/64) | |
279 | data8 0x000FA7C1819E90D8 // 2^(63/64) | |
280 | LOCAL_OBJECT_END(_expf_table) | |
281 | ||
282 | ||
283 | .section .text | |
284 | GLOBAL_IEEE754_ENTRY(expm1f) | |
285 | ||
286 | { .mlx | |
287 | getf.exp rSignexp_x = f8 // Must recompute if x unorm | |
288 | movl r64DivLn2 = 0x40571547652B82FE // 64/ln(2) | |
289 | } | |
290 | { .mlx | |
291 | addl rTblAddr = @ltoff(_expf_table),gp | |
292 | movl rRightShifter = 0x43E8000000000000 // DP Right Shifter | |
293 | } | |
294 | ;; | |
295 | ||
296 | { .mfi | |
297 | // point to the beginning of the table | |
298 | ld8 rTblAddr = [rTblAddr] | |
299 | fclass.m p14, p0 = f8 , 0x22 // test for -INF | |
300 | mov rExp_mask = 0x1ffff // Exponent mask | |
301 | } | |
302 | { .mfi | |
303 | nop.m 0 | |
304 | fnorm.s1 fNormX = f8 // normalized x | |
305 | nop.i 0 | |
306 | } | |
307 | ;; | |
308 | ||
309 | { .mfi | |
310 | setf.d f64DivLn2 = r64DivLn2 // load 64/ln(2) to FP reg | |
311 | fclass.m p9, p0 = f8 , 0x0b // test for x unorm | |
312 | mov rExp_bias = 0xffff // Exponent bias | |
313 | } | |
314 | { .mlx | |
315 | // load Right Shifter to FP reg | |
316 | setf.d fRightShifter = rRightShifter | |
317 | movl rLn2Div64 = 0x3F862E42FEFA39EF // DP ln(2)/64 in GR | |
318 | } | |
319 | ;; | |
320 | ||
321 | { .mfi | |
322 | ldfpd fA8, fA7 = [rTblAddr], 16 | |
323 | fcmp.eq.s1 p13, p0 = f0, f8 // test for x = 0.0 | |
324 | mov rExp_half = 0xfffe | |
325 | } | |
326 | { .mfb | |
327 | setf.d fLn2Div64 = rLn2Div64 // load ln(2)/64 to FP reg | |
328 | nop.f 0 | |
329 | (p9) br.cond.spnt EXPM1_UNORM // Branch if x unorm | |
330 | } | |
331 | ;; | |
332 | ||
333 | EXPM1_COMMON: | |
334 | { .mfb | |
335 | ldfpd fA6, fA5 = [rTblAddr], 16 | |
336 | (p14) fms.s.s0 f8 = f0, f0, f1 // result if x = -inf | |
337 | (p14) br.ret.spnt b0 // exit here if x = -inf | |
338 | } | |
339 | ;; | |
340 | ||
341 | { .mfb | |
342 | ldfpd fA4, fA3 = [rTblAddr], 16 | |
343 | fclass.m p15, p0 = f8 , 0x1e1 // test for NaT,NaN,+Inf | |
344 | (p13) br.ret.spnt b0 // exit here if x =0.0, result is x | |
345 | } | |
346 | ;; | |
347 | ||
348 | { .mfi | |
349 | // overflow thresholds | |
350 | ldfps fMIN_SGL_OFLOW_ARG, fMAX_SGL_NORM_ARG = [rTblAddr], 8 | |
351 | fma.s1 fXsq = fNormX, fNormX, f0 // x^2 for small path | |
352 | and rExp_x = rExp_mask, rSignexp_x // Biased exponent of x | |
353 | } | |
354 | { .mlx | |
355 | nop.m 0 | |
356 | movl rM1_lim = 0xc1c00000 // Minus -1 limit (-24.0), SP | |
357 | } | |
358 | ;; | |
359 | ||
360 | { .mfi | |
361 | setf.exp fA2 = rExp_half | |
362 | // x*(64/ln(2)) + Right Shifter | |
363 | fma.s1 fNint = fNormX, f64DivLn2, fRightShifter | |
364 | sub rExp_x = rExp_x, rExp_bias // True exponent of x | |
365 | } | |
366 | { .mfb | |
367 | nop.m 0 | |
368 | (p15) fma.s.s0 f8 = f8, f1, f0 // result if x = NaT,NaN,+Inf | |
369 | (p15) br.ret.spnt b0 // exit here if x = NaT,NaN,+Inf | |
370 | } | |
371 | ;; | |
372 | ||
373 | { .mfi | |
374 | setf.s fMAX_SGL_MINUS_1_ARG = rM1_lim // -1 threshold, -24.0 | |
375 | nop.f 0 | |
376 | cmp.gt p7, p8 = -2, rExp_x // Test |x| < 2^(-2) | |
377 | } | |
378 | ;; | |
379 | ||
380 | { .mfi | |
381 | (p7) cmp.gt.unc p6, p7 = -40, rExp_x // Test |x| < 2^(-40) | |
382 | fma.s1 fA87 = fA8, fNormX, fA7 // Small path, A8*x+A7 | |
383 | nop.i 0 | |
384 | } | |
385 | { .mfi | |
386 | nop.m 0 | |
387 | fma.s1 fA65 = fA6, fNormX, fA5 // Small path, A6*x+A5 | |
388 | nop.i 0 | |
389 | } | |
390 | ;; | |
391 | ||
392 | { .mfb | |
393 | nop.m 0 | |
394 | (p6) fma.s.s0 f8 = f8, f8, f8 // If x < 2^-40, result=x+x*x | |
395 | (p6) br.ret.spnt b0 // Exit if x < 2^-40 | |
396 | } | |
397 | ;; | |
398 | ||
399 | { .mfi | |
400 | nop.m 0 | |
401 | // check for overflow | |
402 | fcmp.gt.s1 p15, p14 = fNormX, fMIN_SGL_OFLOW_ARG | |
403 | nop.i 0 | |
404 | } | |
405 | { .mfi | |
406 | nop.m 0 | |
407 | fms.s1 fN = fNint, f1, fRightShifter // n in FP register | |
408 | nop.i 0 | |
409 | } | |
410 | ;; | |
411 | ||
412 | { .mfi | |
413 | nop.m 0 | |
414 | (p7) fma.s1 fA43 = fA4, fNormX, fA3 // Small path, A4*x+A3 | |
415 | nop.i 0 | |
416 | } | |
417 | ;; | |
418 | ||
419 | { .mfi | |
420 | getf.sig rNJ = fNint // bits of n, j | |
421 | (p7) fma.s1 fA8765 = fA87, fXsq, fA65 // Small path, A87*xsq+A65 | |
422 | nop.i 0 | |
423 | } | |
424 | { .mfb | |
425 | nop.m 0 | |
426 | (p7) fma.s1 fX3 = fXsq, fNormX, f0 // Small path, x^3 | |
427 | // branch out if overflow | |
428 | (p15) br.cond.spnt EXPM1_CERTAIN_OVERFLOW | |
429 | } | |
430 | ;; | |
431 | ||
432 | { .mfi | |
433 | addl rN = 0xffff-63, rNJ // biased and shifted n | |
434 | fnma.s1 fR = fLn2Div64, fN, fNormX // R = x - N*ln(2)/64 | |
435 | extr.u rJ = rNJ , 0 , 6 // bits of j | |
436 | } | |
437 | ;; | |
438 | ||
439 | { .mfi | |
440 | shladd rJ = rJ, 3, rTblAddr // address in the 2^(j/64) table | |
441 | // check for certain -1 | |
442 | fcmp.le.s1 p13, p0 = fNormX, fMAX_SGL_MINUS_1_ARG | |
443 | shr rN = rN, 6 // biased n | |
444 | } | |
445 | { .mfi | |
446 | nop.m 0 | |
447 | (p7) fma.s1 fA432 = fA43, fNormX, fA2 // Small path, A43*x+A2 | |
448 | nop.i 0 | |
449 | } | |
450 | ;; | |
451 | ||
452 | { .mfi | |
453 | ld8 rJ = [rJ] | |
454 | nop.f 0 | |
455 | shl rN = rN , 52 // 2^n bits in DP format | |
456 | } | |
457 | ;; | |
458 | ||
459 | { .mmi | |
460 | or rN = rN, rJ // bits of 2^n * 2^(j/64) in DP format | |
461 | (p13) mov rTmp = 1 // Make small value for -1 path | |
462 | nop.i 0 | |
463 | } | |
464 | ;; | |
465 | ||
466 | { .mfi | |
467 | setf.d fT = rN // 2^n | |
468 | // check for possible overflow (only happens if input higher precision) | |
469 | (p14) fcmp.gt.s1 p14, p0 = fNormX, fMAX_SGL_NORM_ARG | |
470 | nop.i 0 | |
471 | } | |
472 | { .mfi | |
473 | nop.m 0 | |
474 | (p7) fma.s1 fA8765432 = fA8765, fX3, fA432 // A8765*x^3+A432 | |
475 | nop.i 0 | |
476 | } | |
477 | ;; | |
478 | ||
479 | { .mfi | |
480 | (p13) setf.exp fTmp = rTmp // Make small value for -1 path | |
481 | fma.s1 fP = fA3, fR, fA2 // A3*R + A2 | |
482 | nop.i 0 | |
483 | } | |
484 | { .mfb | |
485 | nop.m 0 | |
486 | fma.s1 fRSqr = fR, fR, f0 // R^2 | |
487 | (p13) br.cond.spnt EXPM1_CERTAIN_MINUS_ONE // Branch if x < -24.0 | |
488 | } | |
489 | ;; | |
490 | ||
491 | { .mfb | |
492 | nop.m 0 | |
0347518d | 493 | (p7) fma.s.s0 f8 = fA8765432, fXsq, fNormX // Small path, |
d5efd131 MF |
494 | // result=xsq*A8765432+x |
495 | (p7) br.ret.spnt b0 // Exit if 2^-40 <= |x| < 2^-2 | |
496 | } | |
497 | ;; | |
498 | ||
499 | { .mfi | |
500 | nop.m 0 | |
501 | fma.s1 fP = fP, fRSqr, fR // P = (A3*R + A2)*Rsqr + R | |
502 | nop.i 0 | |
503 | } | |
504 | ;; | |
505 | ||
506 | { .mfb | |
507 | nop.m 0 | |
508 | fms.s1 fTm1 = fT, f1, f1 // T - 1.0 | |
509 | (p14) br.cond.spnt EXPM1_POSSIBLE_OVERFLOW | |
510 | } | |
511 | ;; | |
512 | ||
513 | { .mfb | |
514 | nop.m 0 | |
515 | fma.s.s0 f8 = fP, fT, fTm1 | |
516 | br.ret.sptk b0 // Result for main path | |
517 | // minus_one_limit < x < -2^-2 | |
518 | // and +2^-2 <= x < overflow_limit | |
519 | } | |
520 | ;; | |
521 | ||
522 | // Here if x unorm | |
523 | EXPM1_UNORM: | |
524 | { .mfb | |
525 | getf.exp rSignexp_x = fNormX // Must recompute if x unorm | |
526 | fcmp.eq.s0 p6, p0 = f8, f0 // Set D flag | |
527 | br.cond.sptk EXPM1_COMMON | |
528 | } | |
529 | ;; | |
530 | ||
531 | // here if result will be -1 and inexact, x <= -24.0 | |
532 | EXPM1_CERTAIN_MINUS_ONE: | |
533 | { .mfb | |
534 | nop.m 0 | |
535 | fms.s.s0 f8 = fTmp, fTmp, f1 // Result -1, and Inexact set | |
536 | br.ret.sptk b0 | |
537 | } | |
538 | ;; | |
539 | ||
540 | EXPM1_POSSIBLE_OVERFLOW: | |
541 | ||
542 | // Here if fMAX_SGL_NORM_ARG < x < fMIN_SGL_OFLOW_ARG | |
543 | // This cannot happen if input is a single, only if input higher precision. | |
544 | // Overflow is a possibility, not a certainty. | |
545 | ||
546 | // Recompute result using status field 2 with user's rounding mode, | |
547 | // and wre set. If result is larger than largest single, then we have | |
548 | // overflow | |
549 | ||
550 | { .mfi | |
551 | mov rGt_ln = 0x1007f // Exponent for largest sgl + 1 ulp | |
552 | fsetc.s2 0x7F,0x42 // Get user's round mode, set wre | |
553 | nop.i 0 | |
554 | } | |
555 | ;; | |
556 | ||
557 | { .mfi | |
558 | setf.exp fGt_pln = rGt_ln // Create largest single + 1 ulp | |
559 | fma.s.s2 fWre_urm_f8 = fP, fT, fTm1 // Result with wre set | |
560 | nop.i 0 | |
561 | } | |
562 | ;; | |
563 | ||
564 | { .mfi | |
565 | nop.m 0 | |
566 | fsetc.s2 0x7F,0x40 // Turn off wre in sf2 | |
567 | nop.i 0 | |
568 | } | |
569 | ;; | |
570 | ||
571 | { .mfi | |
572 | nop.m 0 | |
573 | fcmp.ge.s1 p6, p0 = fWre_urm_f8, fGt_pln // Test for overflow | |
574 | nop.i 0 | |
575 | } | |
576 | ;; | |
577 | ||
578 | { .mfb | |
579 | nop.m 0 | |
580 | nop.f 0 | |
581 | (p6) br.cond.spnt EXPM1_CERTAIN_OVERFLOW // Branch if overflow | |
582 | } | |
583 | ;; | |
584 | ||
585 | { .mfb | |
586 | nop.m 0 | |
587 | fma.s.s0 f8 = fP, fT, fTm1 | |
588 | br.ret.sptk b0 // Exit if really no overflow | |
589 | } | |
590 | ;; | |
591 | ||
592 | // here if overflow | |
593 | EXPM1_CERTAIN_OVERFLOW: | |
594 | { .mmi | |
595 | addl rTmp = 0x1FFFE, r0;; | |
596 | setf.exp fTmp = rTmp | |
597 | nop.i 999 | |
598 | } | |
599 | ;; | |
600 | ||
601 | { .mfi | |
602 | alloc r32 = ar.pfs, 0, 3, 4, 0 // get some registers | |
603 | fmerge.s FR_X = fNormX,fNormX | |
604 | nop.i 0 | |
605 | } | |
606 | { .mfb | |
607 | mov GR_Parameter_TAG = 43 | |
608 | fma.s.s0 FR_RESULT = fTmp, fTmp, f0 // Set I,O and +INF result | |
609 | br.cond.sptk __libm_error_region | |
610 | } | |
611 | ;; | |
612 | ||
613 | GLOBAL_IEEE754_END(expm1f) | |
aa1142c5 | 614 | libm_alias_float_other (__expm1, expm1) |
d5efd131 MF |
615 | |
616 | ||
617 | LOCAL_LIBM_ENTRY(__libm_error_region) | |
618 | .prologue | |
619 | { .mfi | |
620 | add GR_Parameter_Y=-32,sp // Parameter 2 value | |
621 | nop.f 999 | |
622 | .save ar.pfs,GR_SAVE_PFS | |
623 | mov GR_SAVE_PFS=ar.pfs // Save ar.pfs | |
624 | } | |
625 | { .mfi | |
626 | .fframe 64 | |
627 | add sp=-64,sp // Create new stack | |
628 | nop.f 0 | |
629 | mov GR_SAVE_GP=gp // Save gp | |
630 | };; | |
631 | { .mmi | |
632 | stfs [GR_Parameter_Y] = FR_Y,16 // Store Parameter 2 on stack | |
633 | add GR_Parameter_X = 16,sp // Parameter 1 address | |
634 | .save b0, GR_SAVE_B0 | |
635 | mov GR_SAVE_B0=b0 // Save b0 | |
636 | };; | |
637 | .body | |
638 | { .mfi | |
639 | stfs [GR_Parameter_X] = FR_X // Store Parameter 1 on stack | |
640 | nop.f 0 | |
641 | add GR_Parameter_RESULT = 0,GR_Parameter_Y // Parameter 3 address | |
642 | } | |
643 | { .mib | |
644 | stfs [GR_Parameter_Y] = FR_RESULT // Store Parameter 3 on stack | |
645 | add GR_Parameter_Y = -16,GR_Parameter_Y | |
646 | br.call.sptk b0=__libm_error_support# // Call error handling function | |
647 | };; | |
648 | ||
649 | { .mmi | |
650 | add GR_Parameter_RESULT = 48,sp | |
651 | nop.m 0 | |
652 | nop.i 0 | |
653 | };; | |
654 | ||
655 | { .mmi | |
656 | ldfs f8 = [GR_Parameter_RESULT] // Get return result off stack | |
657 | .restore sp | |
658 | add sp = 64,sp // Restore stack pointer | |
659 | mov b0 = GR_SAVE_B0 // Restore return address | |
660 | };; | |
661 | { .mib | |
662 | mov gp = GR_SAVE_GP // Restore gp | |
663 | mov ar.pfs = GR_SAVE_PFS // Restore ar.pfs | |
664 | br.ret.sptk b0 // Return | |
665 | };; | |
666 | ||
667 | LOCAL_LIBM_END(__libm_error_region) | |
668 | ||
669 | ||
670 | .type __libm_error_support#,@function | |
671 | .global __libm_error_support# |