Don't fail on non-bi-arch arches.
[glibc.git] / sysdeps / ia64 / fpu / s_log1pf.S
bloba148d4b272101309e6fa966460e70428f3f775c5
1 .file "log1pf.s"
4 // Copyright (c) 2000 - 2003, Intel Corporation
5 // All rights reserved.
6 //
7 // Contributed 2000 by the Intel Numerics Group, Intel Corporation
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are
11 // met:
13 // * Redistributions of source code must retain the above copyright
14 // notice, this list of conditions and the following disclaimer.
16 // * Redistributions in binary form must reproduce the above copyright
17 // notice, this list of conditions and the following disclaimer in the
18 // documentation and/or other materials provided with the distribution.
20 // * The name of Intel Corporation may not be used to endorse or promote
21 // products derived from this software without specific prior written
22 // permission.
24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS
28 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
32 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING
33 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 // Intel Corporation is the author of this code, and requests that all
37 // problem reports or change requests be submitted to it directly at
38 // http://www.intel.com/software/products/opensource/libraries/num.htm.
40 // History
41 //==============================================================
42 // 02/02/00 Initial version
43 // 04/04/00 Unwind support added
44 // 08/15/00 Bundle added after call to __libm_error_support to properly
45 //          set [the previously overwritten] GR_Parameter_RESULT.
46 // 06/29/01 Improved speed of all paths
47 // 05/20/02 Cleaned up namespace and sf0 syntax
48 // 10/02/02 Improved performance by basing on log algorithm
49 // 02/10/03 Reordered header: .section, .global, .proc, .align
50 // 04/18/03 Eliminate possible WAW dependency warning
52 // API
53 //==============================================================
54 // float log1pf(float)
56 // log1p(x) = log(x+1)
58 // Overview of operation
59 //==============================================================
60 // Background
61 // ----------
63 // This algorithm is based on fact that
64 // log1p(x) = log(1+x) and
65 // log(a b) = log(a) + log(b).
66 // In our case we have 1+x = 2^N f, where 1 <= f < 2.
67 // So
68 //   log(1+x) = log(2^N f) = log(2^N) + log(f) = n*log(2) + log(f)
70 // To calculate log(f) we do following
71 //   log(f) = log(f * frcpa(f) / frcpa(f)) =
72 //          = log(f * frcpa(f)) + log(1/frcpa(f))
74 // According to definition of IA-64's frcpa instruction it's a
75 // floating point that approximates 1/f using a lookup on the
76 // top of 8 bits of the input number's + 1 significand with relative
77 // error < 2^(-8.886). So we have following
79 // |(1/f - frcpa(f)) / (1/f))| = |1 - f*frcpa(f)| < 1/256
81 // and
83 // log(f) = log(f * frcpa(f)) + log(1/frcpa(f)) =
84 //        = log(1 + r) + T
86 // The first value can be computed by polynomial P(r) approximating
87 // log(1 + r) on |r| < 1/256 and the second is precomputed tabular
88 // value defined by top 8 bit of f.
90 // Finally we have that  log(1+x) ~ (N*log(2) + T) + P(r)
92 // Note that if input argument is close to 0.0 (in our case it means
93 // that |x| < 1/256) we can use just polynomial approximation
94 // because 1+x = 2^0 * f = f = 1 + r and
95 // log(1+x) = log(1 + r) ~ P(r)
98 // Implementation
99 // --------------
101 // 1. |x| >= 2^(-8), and x > -1
102 //   InvX = frcpa(x+1)
103 //   r = InvX*(x+1) - 1
104 //   P(r) = r*((1 - A2*4) + r^2*(A3 - A4*r)) = r*P2(r),
105 //   A4,A3,A2 are created with setf instruction.
106 //   We use Taylor series and so A4 = 1/4, A3 = 1/3,
107 //   A2 = 1/2 rounded to double.
109 //   N = float(n) where n is true unbiased exponent of x
111 //   T is tabular value of log(1/frcpa(x)) calculated in quad precision
112 //   and rounded to double.  To load T we get bits from 55 to 62 of register
113 //   format significand as index and calculate address
114 //     ad_T = table_base_addr + 8 * index
116 //   L1 (log(2)) is calculated in quad precision and rounded to double;
117 //   it's created with setf
119 //   And final result = P2(r)*r + (T + N*L1)
122 // 2. 2^(-40) <= |x| < 2^(-8)
123 //   r = x
124 //   P(r) = r*((1 - A2*4) + r^2*(A3 - A4*r)) = r*P2(r),
125 //   A4,A3,A2 are the same as in case |x| >= 1/256
127 //   And final result = P2(r)*r
129 // 3. 0 < |x| < 2^(-40)
130 //   Although log1p(x) is basically x, we would like to preserve the inexactness
131 //   nature as well as consistent behavior under different rounding modes.
132 //   We can do this by computing the result as
134 //     log1p(x) = x - x*x
137 //    Note: NaT, any NaNs, +/-INF, +/-0, negatives and unnormalized numbers are
138 //          filtered and processed on special branches.
142 // Special values
143 //==============================================================
145 // log1p(-1)    = -inf            // Call error support
147 // log1p(+qnan) = +qnan
148 // log1p(-qnan) = -qnan
149 // log1p(+snan) = +qnan
150 // log1p(-snan) = -qnan
152 // log1p(x),x<-1= QNAN Indefinite // Call error support
153 // log1p(-inf)  = QNAN Indefinite
154 // log1p(+inf)  = +inf
155 // log1p(+/-0)  = +/-0
158 // Registers used
159 //==============================================================
160 // Floating Point registers used:
161 // f8, input
162 // f7 -> f15,  f32 -> f36
164 // General registers used:
165 // r8  -> r11
166 // r14 -> r22
168 // Predicate registers used:
169 // p6 -> p12
171 // Assembly macros
172 //==============================================================
173 GR_TAG                 = r8
174 GR_ad_T                = r9
175 GR_Exp                 = r10
176 GR_N                   = r11
178 GR_signexp_x           = r14
179 GR_exp_mask            = r15
180 GR_exp_bias            = r16
181 GR_05                  = r17
182 GR_A3                  = r18
183 GR_Sig                 = r19
184 GR_Ind                 = r19
185 GR_exp_x               = r20
186 GR_Ln2                 = r21
187 GR_025                 = r22
190 GR_SAVE_B0             = r33
191 GR_SAVE_PFS            = r34
192 GR_SAVE_GP             = r35
193 GR_SAVE_SP             = r36
195 GR_Parameter_X         = r37
196 GR_Parameter_Y         = r38
197 GR_Parameter_RESULT    = r39
198 GR_Parameter_TAG       = r40
202 FR_NormX               = f7
203 FR_RcpX                = f9
204 FR_r                   = f10
205 FR_r2                  = f11
206 FR_r4                  = f12
207 FR_N                   = f13
208 FR_Ln2                 = f14
209 FR_Xp1                 = f15
211 FR_A4                  = f33
212 FR_A3                  = f34
213 FR_A2                  = f35
215 FR_T                   = f36
216 FR_NxLn2pT             = f36
220 FR_Y                   = f1
221 FR_X                   = f10
222 FR_RESULT              = f8
225 // Data
226 //==============================================================
227 RODATA
228 .align 16
230 LOCAL_OBJECT_START(log_data)
231 // ln(1/frcpa(1+i/256)), i=0...255
232 data8 0x3F60040155D5889E // 0
233 data8 0x3F78121214586B54 // 1
234 data8 0x3F841929F96832F0 // 2
235 data8 0x3F8C317384C75F06 // 3
236 data8 0x3F91A6B91AC73386 // 4
237 data8 0x3F95BA9A5D9AC039 // 5
238 data8 0x3F99D2A8074325F4 // 6
239 data8 0x3F9D6B2725979802 // 7
240 data8 0x3FA0C58FA19DFAAA // 8
241 data8 0x3FA2954C78CBCE1B // 9
242 data8 0x3FA4A94D2DA96C56 // 10
243 data8 0x3FA67C94F2D4BB58 // 11
244 data8 0x3FA85188B630F068 // 12
245 data8 0x3FAA6B8ABE73AF4C // 13
246 data8 0x3FAC441E06F72A9E // 14
247 data8 0x3FAE1E6713606D07 // 15
248 data8 0x3FAFFA6911AB9301 // 16
249 data8 0x3FB0EC139C5DA601 // 17
250 data8 0x3FB1DBD2643D190B // 18
251 data8 0x3FB2CC7284FE5F1C // 19
252 data8 0x3FB3BDF5A7D1EE64 // 20
253 data8 0x3FB4B05D7AA012E0 // 21
254 data8 0x3FB580DB7CEB5702 // 22
255 data8 0x3FB674F089365A7A // 23
256 data8 0x3FB769EF2C6B568D // 24
257 data8 0x3FB85FD927506A48 // 25
258 data8 0x3FB9335E5D594989 // 26
259 data8 0x3FBA2B0220C8E5F5 // 27
260 data8 0x3FBB0004AC1A86AC // 28
261 data8 0x3FBBF968769FCA11 // 29
262 data8 0x3FBCCFEDBFEE13A8 // 30
263 data8 0x3FBDA727638446A2 // 31
264 data8 0x3FBEA3257FE10F7A // 32
265 data8 0x3FBF7BE9FEDBFDE6 // 33
266 data8 0x3FC02AB352FF25F4 // 34
267 data8 0x3FC097CE579D204D // 35
268 data8 0x3FC1178E8227E47C // 36
269 data8 0x3FC185747DBECF34 // 37
270 data8 0x3FC1F3B925F25D41 // 38
271 data8 0x3FC2625D1E6DDF57 // 39
272 data8 0x3FC2D1610C86813A // 40
273 data8 0x3FC340C59741142E // 41
274 data8 0x3FC3B08B6757F2A9 // 42
275 data8 0x3FC40DFB08378003 // 43
276 data8 0x3FC47E74E8CA5F7C // 44
277 data8 0x3FC4EF51F6466DE4 // 45
278 data8 0x3FC56092E02BA516 // 46
279 data8 0x3FC5D23857CD74D5 // 47
280 data8 0x3FC6313A37335D76 // 48
281 data8 0x3FC6A399DABBD383 // 49
282 data8 0x3FC70337DD3CE41B // 50
283 data8 0x3FC77654128F6127 // 51
284 data8 0x3FC7E9D82A0B022D // 52
285 data8 0x3FC84A6B759F512F // 53
286 data8 0x3FC8AB47D5F5A310 // 54
287 data8 0x3FC91FE49096581B // 55
288 data8 0x3FC981634011AA75 // 56
289 data8 0x3FC9F6C407089664 // 57
290 data8 0x3FCA58E729348F43 // 58
291 data8 0x3FCABB55C31693AD // 59
292 data8 0x3FCB1E104919EFD0 // 60
293 data8 0x3FCB94EE93E367CB // 61
294 data8 0x3FCBF851C067555F // 62
295 data8 0x3FCC5C0254BF23A6 // 63
296 data8 0x3FCCC000C9DB3C52 // 64
297 data8 0x3FCD244D99C85674 // 65
298 data8 0x3FCD88E93FB2F450 // 66
299 data8 0x3FCDEDD437EAEF01 // 67
300 data8 0x3FCE530EFFE71012 // 68
301 data8 0x3FCEB89A1648B971 // 69
302 data8 0x3FCF1E75FADF9BDE // 70
303 data8 0x3FCF84A32EAD7C35 // 71
304 data8 0x3FCFEB2233EA07CD // 72
305 data8 0x3FD028F9C7035C1C // 73
306 data8 0x3FD05C8BE0D9635A // 74
307 data8 0x3FD085EB8F8AE797 // 75
308 data8 0x3FD0B9C8E32D1911 // 76
309 data8 0x3FD0EDD060B78081 // 77
310 data8 0x3FD122024CF0063F // 78
311 data8 0x3FD14BE2927AECD4 // 79
312 data8 0x3FD180618EF18ADF // 80
313 data8 0x3FD1B50BBE2FC63B // 81
314 data8 0x3FD1DF4CC7CF242D // 82
315 data8 0x3FD214456D0EB8D4 // 83
316 data8 0x3FD23EC5991EBA49 // 84
317 data8 0x3FD2740D9F870AFB // 85
318 data8 0x3FD29ECDABCDFA04 // 86
319 data8 0x3FD2D46602ADCCEE // 87
320 data8 0x3FD2FF66B04EA9D4 // 88
321 data8 0x3FD335504B355A37 // 89
322 data8 0x3FD360925EC44F5D // 90
323 data8 0x3FD38BF1C3337E75 // 91
324 data8 0x3FD3C25277333184 // 92
325 data8 0x3FD3EDF463C1683E // 93
326 data8 0x3FD419B423D5E8C7 // 94
327 data8 0x3FD44591E0539F49 // 95
328 data8 0x3FD47C9175B6F0AD // 96
329 data8 0x3FD4A8B341552B09 // 97
330 data8 0x3FD4D4F3908901A0 // 98
331 data8 0x3FD501528DA1F968 // 99
332 data8 0x3FD52DD06347D4F6 // 100
333 data8 0x3FD55A6D3C7B8A8A // 101
334 data8 0x3FD5925D2B112A59 // 102
335 data8 0x3FD5BF406B543DB2 // 103
336 data8 0x3FD5EC433D5C35AE // 104
337 data8 0x3FD61965CDB02C1F // 105
338 data8 0x3FD646A84935B2A2 // 106
339 data8 0x3FD6740ADD31DE94 // 107
340 data8 0x3FD6A18DB74A58C5 // 108
341 data8 0x3FD6CF31058670EC // 109
342 data8 0x3FD6F180E852F0BA // 110
343 data8 0x3FD71F5D71B894F0 // 111
344 data8 0x3FD74D5AEFD66D5C // 112
345 data8 0x3FD77B79922BD37E // 113
346 data8 0x3FD7A9B9889F19E2 // 114
347 data8 0x3FD7D81B037EB6A6 // 115
348 data8 0x3FD8069E33827231 // 116
349 data8 0x3FD82996D3EF8BCB // 117
350 data8 0x3FD85855776DCBFB // 118
351 data8 0x3FD8873658327CCF // 119
352 data8 0x3FD8AA75973AB8CF // 120
353 data8 0x3FD8D992DC8824E5 // 121
354 data8 0x3FD908D2EA7D9512 // 122
355 data8 0x3FD92C59E79C0E56 // 123
356 data8 0x3FD95BD750EE3ED3 // 124
357 data8 0x3FD98B7811A3EE5B // 125
358 data8 0x3FD9AF47F33D406C // 126
359 data8 0x3FD9DF270C1914A8 // 127
360 data8 0x3FDA0325ED14FDA4 // 128
361 data8 0x3FDA33440224FA79 // 129
362 data8 0x3FDA57725E80C383 // 130
363 data8 0x3FDA87D0165DD199 // 131
364 data8 0x3FDAAC2E6C03F896 // 132
365 data8 0x3FDADCCC6FDF6A81 // 133
366 data8 0x3FDB015B3EB1E790 // 134
367 data8 0x3FDB323A3A635948 // 135
368 data8 0x3FDB56FA04462909 // 136
369 data8 0x3FDB881AA659BC93 // 137
370 data8 0x3FDBAD0BEF3DB165 // 138
371 data8 0x3FDBD21297781C2F // 139
372 data8 0x3FDC039236F08819 // 140
373 data8 0x3FDC28CB1E4D32FD // 141
374 data8 0x3FDC4E19B84723C2 // 142
375 data8 0x3FDC7FF9C74554C9 // 143
376 data8 0x3FDCA57B64E9DB05 // 144
377 data8 0x3FDCCB130A5CEBB0 // 145
378 data8 0x3FDCF0C0D18F326F // 146
379 data8 0x3FDD232075B5A201 // 147
380 data8 0x3FDD490246DEFA6B // 148
381 data8 0x3FDD6EFA918D25CD // 149
382 data8 0x3FDD9509707AE52F // 150
383 data8 0x3FDDBB2EFE92C554 // 151
384 data8 0x3FDDEE2F3445E4AF // 152
385 data8 0x3FDE148A1A2726CE // 153
386 data8 0x3FDE3AFC0A49FF40 // 154
387 data8 0x3FDE6185206D516E // 155
388 data8 0x3FDE882578823D52 // 156
389 data8 0x3FDEAEDD2EAC990C // 157
390 data8 0x3FDED5AC5F436BE3 // 158
391 data8 0x3FDEFC9326D16AB9 // 159
392 data8 0x3FDF2391A2157600 // 160
393 data8 0x3FDF4AA7EE03192D // 161
394 data8 0x3FDF71D627C30BB0 // 162
395 data8 0x3FDF991C6CB3B379 // 163
396 data8 0x3FDFC07ADA69A910 // 164
397 data8 0x3FDFE7F18EB03D3E // 165
398 data8 0x3FE007C053C5002E // 166
399 data8 0x3FE01B942198A5A1 // 167
400 data8 0x3FE02F74400C64EB // 168
401 data8 0x3FE04360BE7603AD // 169
402 data8 0x3FE05759AC47FE34 // 170
403 data8 0x3FE06B5F1911CF52 // 171
404 data8 0x3FE078BF0533C568 // 172
405 data8 0x3FE08CD9687E7B0E // 173
406 data8 0x3FE0A10074CF9019 // 174
407 data8 0x3FE0B5343A234477 // 175
408 data8 0x3FE0C974C89431CE // 176
409 data8 0x3FE0DDC2305B9886 // 177
410 data8 0x3FE0EB524BAFC918 // 178
411 data8 0x3FE0FFB54213A476 // 179
412 data8 0x3FE114253DA97D9F // 180
413 data8 0x3FE128A24F1D9AFF // 181
414 data8 0x3FE1365252BF0865 // 182
415 data8 0x3FE14AE558B4A92D // 183
416 data8 0x3FE15F85A19C765B // 184
417 data8 0x3FE16D4D38C119FA // 185
418 data8 0x3FE18203C20DD133 // 186
419 data8 0x3FE196C7BC4B1F3B // 187
420 data8 0x3FE1A4A738B7A33C // 188
421 data8 0x3FE1B981C0C9653D // 189
422 data8 0x3FE1CE69E8BB106B // 190
423 data8 0x3FE1DC619DE06944 // 191
424 data8 0x3FE1F160A2AD0DA4 // 192
425 data8 0x3FE2066D7740737E // 193
426 data8 0x3FE2147DBA47A394 // 194
427 data8 0x3FE229A1BC5EBAC3 // 195
428 data8 0x3FE237C1841A502E // 196
429 data8 0x3FE24CFCE6F80D9A // 197
430 data8 0x3FE25B2C55CD5762 // 198
431 data8 0x3FE2707F4D5F7C41 // 199
432 data8 0x3FE285E0842CA384 // 200
433 data8 0x3FE294294708B773 // 201
434 data8 0x3FE2A9A2670AFF0C // 202
435 data8 0x3FE2B7FB2C8D1CC1 // 203
436 data8 0x3FE2C65A6395F5F5 // 204
437 data8 0x3FE2DBF557B0DF43 // 205
438 data8 0x3FE2EA64C3F97655 // 206
439 data8 0x3FE3001823684D73 // 207
440 data8 0x3FE30E97E9A8B5CD // 208
441 data8 0x3FE32463EBDD34EA // 209
442 data8 0x3FE332F4314AD796 // 210
443 data8 0x3FE348D90E7464D0 // 211
444 data8 0x3FE35779F8C43D6E // 212
445 data8 0x3FE36621961A6A99 // 213
446 data8 0x3FE37C299F3C366A // 214
447 data8 0x3FE38AE2171976E7 // 215
448 data8 0x3FE399A157A603E7 // 216
449 data8 0x3FE3AFCCFE77B9D1 // 217
450 data8 0x3FE3BE9D503533B5 // 218
451 data8 0x3FE3CD7480B4A8A3 // 219
452 data8 0x3FE3E3C43918F76C // 220
453 data8 0x3FE3F2ACB27ED6C7 // 221
454 data8 0x3FE4019C2125CA93 // 222
455 data8 0x3FE4181061389722 // 223
456 data8 0x3FE42711518DF545 // 224
457 data8 0x3FE436194E12B6BF // 225
458 data8 0x3FE445285D68EA69 // 226
459 data8 0x3FE45BCC464C893A // 227
460 data8 0x3FE46AED21F117FC // 228
461 data8 0x3FE47A1527E8A2D3 // 229
462 data8 0x3FE489445EFFFCCC // 230
463 data8 0x3FE4A018BCB69835 // 231
464 data8 0x3FE4AF5A0C9D65D7 // 232
465 data8 0x3FE4BEA2A5BDBE87 // 233
466 data8 0x3FE4CDF28F10AC46 // 234
467 data8 0x3FE4DD49CF994058 // 235
468 data8 0x3FE4ECA86E64A684 // 236
469 data8 0x3FE503C43CD8EB68 // 237
470 data8 0x3FE513356667FC57 // 238
471 data8 0x3FE522AE0738A3D8 // 239
472 data8 0x3FE5322E26867857 // 240
473 data8 0x3FE541B5CB979809 // 241
474 data8 0x3FE55144FDBCBD62 // 242
475 data8 0x3FE560DBC45153C7 // 243
476 data8 0x3FE5707A26BB8C66 // 244
477 data8 0x3FE587F60ED5B900 // 245
478 data8 0x3FE597A7977C8F31 // 246
479 data8 0x3FE5A760D634BB8B // 247
480 data8 0x3FE5B721D295F10F // 248
481 data8 0x3FE5C6EA94431EF9 // 249
482 data8 0x3FE5D6BB22EA86F6 // 250
483 data8 0x3FE5E6938645D390 // 251
484 data8 0x3FE5F673C61A2ED2 // 252
485 data8 0x3FE6065BEA385926 // 253
486 data8 0x3FE6164BFA7CC06B // 254
487 data8 0x3FE62643FECF9743 // 255
488 LOCAL_OBJECT_END(log_data)
491 // Code
492 //==============================================================
494 .section .text
495 GLOBAL_IEEE754_ENTRY(log1pf)
496 { .mfi
497       getf.exp      GR_signexp_x = f8 // if x is unorm then must recompute
498       fadd.s1       FR_Xp1 = f8, f1       // Form 1+x
499       mov           GR_05 = 0xfffe
501 { .mlx
502       addl          GR_ad_T = @ltoff(log_data),gp
503       movl          GR_A3 = 0x3fd5555555555555 // double precision memory
504                                                // representation of A3
508 { .mfi
509       ld8           GR_ad_T = [GR_ad_T]
510       fclass.m      p8,p0 = f8,0xb // Is x unorm?
511       mov           GR_exp_mask = 0x1ffff
513 { .mfi
514       mov           GR_025 = 0xfffd            // Exponent of 0.25
515       fnorm.s1      FR_NormX = f8              // Normalize x
516       mov           GR_exp_bias = 0xffff
520 { .mfi
521       setf.exp      FR_A2 = GR_05 // create A2 = 0.5
522       fclass.m      p9,p0 = f8,0x1E1 // is x NaN, NaT or +Inf?
523       nop.i         0
525 { .mib
526       setf.d        FR_A3 = GR_A3 // create A3
527       nop.i         0
528 (p8)  br.cond.spnt  log1p_unorm          // Branch if x=unorm
532 log1p_common:
533 { .mfi
534       setf.exp      FR_A4 = GR_025 // create A4 = 0.25
535       frcpa.s1      FR_RcpX,p0 = f1,FR_Xp1
536       nop.i         0
538 { .mfb
539       nop.m         0
540 (p9)  fma.s.s0      f8 = f8,f1,f0 // set V-flag
541 (p9)  br.ret.spnt   b0 // exit for NaN, NaT and +Inf
545 { .mfi
546       getf.exp      GR_Exp = FR_Xp1            // signexp of x+1
547       fclass.m      p10,p0 = FR_Xp1,0x3A // is 1+x < 0?
548       and           GR_exp_x = GR_exp_mask, GR_signexp_x // biased exponent of x
550 { .mlx
551       nop.m         0
552       movl          GR_Ln2 = 0x3FE62E42FEFA39EF // double precision memory
553                                                 // representation of log(2)
557 { .mfi
558       getf.sig      GR_Sig = FR_Xp1 // get significand to calculate index
559                                     // for T if |x| >= 2^-8
560       fcmp.eq.s1    p12,p0 = f8,f0     // is x equal to 0?
561       sub           GR_exp_x = GR_exp_x, GR_exp_bias // true exponent of x
565 { .mfi
566       sub           GR_N = GR_Exp,GR_exp_bias // true exponent of x+1
567       fcmp.eq.s1    p11,p0 = FR_Xp1,f0     // is x = -1?
568       cmp.gt        p6,p7 = -8, GR_exp_x  // Is |x| < 2^-8
570 { .mfb
571       nop.m         0
572       nop.f         0
573 (p10) br.cond.spnt  log1p_lt_minus_1   // jump if x < -1
577 // p6 is true if |x| < 1/256
578 // p7 is true if |x| >= 1/256
579 .pred.rel "mutex",p6,p7
580 { .mfi
581       nop.m         0
582 (p6)  fms.s1        FR_r = f8,f1,f0 // range reduction for |x|<1/256
583 (p6)  cmp.gt.unc    p10,p0 = -40, GR_exp_x  // Is |x| < 2^-40
585 { .mfb
586 (p7)  setf.sig      FR_N = GR_N // copy unbiased exponent of x to the
587                                 // significand field of FR_N
588 (p7)  fms.s1        FR_r = FR_RcpX,FR_Xp1,f1 // range reduction for |x|>=1/256
589 (p12) br.ret.spnt   b0 // exit for x=0, return x
593 { .mib
594       setf.d        FR_Ln2 = GR_Ln2 // create log(2)
595 (p7)  extr.u        GR_Ind = GR_Sig,55,8 // get bits from 55 to 62 as index
596 (p11) br.cond.spnt  log1p_eq_minus_1 // jump if x = -1
600 { .mmf
601 (p7)  shladd        GR_ad_T = GR_Ind,3,GR_ad_T // address of T
602       nop.m         0
603 (p10) fnma.s.s0     f8 = f8,f8,f8   // If |x| very small, result=x-x*x
607 { .mmb
608 (p7)  ldfd          FR_T = [GR_ad_T]
609       nop.m         0
610 (p10) br.ret.spnt   b0              // Exit if |x| < 2^-40
614 { .mfi
615       nop.m         0
616       fma.s1        FR_r2 = FR_r,FR_r,f0 // r^2
617       nop.i         0
619 { .mfi
620       nop.m         0
621       fnma.s1       FR_A2 = FR_A2,FR_r,f1      // 1.0 - A2*r
622       nop.i         0
626 { .mfi
627       nop.m         0
628       fnma.s1       FR_A3 = FR_A4,FR_r,FR_A3 // A3 - A4*r
629       nop.i         0
633 { .mfi
634       nop.m         0
635 (p7)  fcvt.xf       FR_N = FR_N
636       nop.i         0
640 { .mfi
641       nop.m         0
642       // (A3*r+A2)*r^2+r
643       fma.s1        FR_A2 = FR_A3,FR_r2,FR_A2 // (A4*r+A3)*r^2+(A2*r+1)
644       nop.i         0
648 { .mfi
649       nop.m         0
650       // N*Ln2hi+T
651 (p7)  fma.s1        FR_NxLn2pT = FR_N,FR_Ln2,FR_T
652       nop.i         0
656 .pred.rel "mutex",p6,p7
657 { .mfi
658       nop.m         0
659 (p6)  fma.s.s0      f8 = FR_A2,FR_r,f0 // result if 2^(-40) <= |x| < 1/256
660       nop.i         0
662 { .mfb
663       nop.m         0
664 (p7)  fma.s.s0      f8 = FR_A2,FR_r,FR_NxLn2pT  // result if |x| >= 1/256
665       br.ret.sptk   b0                          // Exit if |x| >= 2^(-40)
669 .align 32
670 log1p_unorm:
671 // Here if x=unorm
672 { .mfb
673       getf.exp      GR_signexp_x = FR_NormX // recompute biased exponent
674       nop.f         0
675       br.cond.sptk  log1p_common
679 .align 32
680 log1p_eq_minus_1:
681 // Here if x=-1
682 { .mfi
683       nop.m         0
684       fmerge.s      FR_X = f8,f8 // keep input argument for subsequent
685                                  // call of __libm_error_support#
686       nop.i         0
690 { .mfi
691       mov           GR_TAG = 142  // set libm error in case of log1p(-1).
692       frcpa.s0      f8,p0 = f8,f0 // log1p(-1) should be equal to -INF.
693                                       // We can get it using frcpa because it
694                                       // sets result to the IEEE-754 mandated
695                                       // quotient of f8/f0.
696       nop.i         0
698 { .mib
699       nop.m         0
700       nop.i         0
701       br.cond.sptk  log_libm_err
705 .align 32
706 log1p_lt_minus_1:
707 // Here if x < -1
708 { .mfi
709       nop.m         0
710       fmerge.s      FR_X = f8,f8
711       nop.i         0
715 { .mfi
716       mov           GR_TAG = 143  // set libm error in case of x < -1.
717       frcpa.s0      f8,p0 = f0,f0 // log1p(x) x < -1 should be equal to NaN.
718                                   // We can get it using frcpa because it
719                                   // sets result to the IEEE-754 mandated
720                                   // quotient of f0/f0 i.e. NaN.
721       nop.i         0
725 .align 32
726 log_libm_err:
727 { .mmi
728       alloc         r32 = ar.pfs,1,4,4,0
729       mov           GR_Parameter_TAG = GR_TAG
730       nop.i         0
734 GLOBAL_IEEE754_END(log1pf)
736 LOCAL_LIBM_ENTRY(__libm_error_region)
737 .prologue
738 { .mfi
739         add   GR_Parameter_Y = -32,sp         // Parameter 2 value
740         nop.f 0
741 .save   ar.pfs,GR_SAVE_PFS
742         mov  GR_SAVE_PFS = ar.pfs             // Save ar.pfs
744 { .mfi
745 .fframe 64
746         add sp = -64,sp                       // Create new stack
747         nop.f 0
748         mov GR_SAVE_GP = gp                   // Save gp
750 { .mmi
751         stfs [GR_Parameter_Y] = FR_Y,16       // STORE Parameter 2 on stack
752         add GR_Parameter_X = 16,sp            // Parameter 1 address
753 .save   b0, GR_SAVE_B0
754         mov GR_SAVE_B0 = b0                   // Save b0
756 .body
757 { .mib
758         stfs [GR_Parameter_X] = FR_X          // STORE Parameter 1 on stack
759         add   GR_Parameter_RESULT = 0,GR_Parameter_Y // Parameter 3 address
760         nop.b 0
762 { .mib
763         stfs [GR_Parameter_Y] = FR_RESULT     // STORE Parameter 3 on stack
764         add   GR_Parameter_Y = -16,GR_Parameter_Y
765         br.call.sptk b0=__libm_error_support# // Call error handling function
767 { .mmi
768         add   GR_Parameter_RESULT = 48,sp
769         nop.m 0
770         nop.i 0
772 { .mmi
773         ldfs  f8 = [GR_Parameter_RESULT]      // Get return result off stack
774 .restore sp
775         add   sp = 64,sp                      // Restore stack pointer
776         mov   b0 = GR_SAVE_B0                 // Restore return address
778 { .mib
779         mov   gp = GR_SAVE_GP                 // Restore gp
780         mov   ar.pfs = GR_SAVE_PFS            // Restore ar.pfs
781         br.ret.sptk     b0                    // Return
783 LOCAL_LIBM_END(__libm_error_region)
785 .type   __libm_error_support#,@function
786 .global __libm_error_support#