Fix POWER7 Implies
[glibc.git] / sysdeps / ia64 / fpu / s_erfcf.S
blob2e3eeab3c75501a457cd1de25718ddeedb25318e
1 .file "erfcf.s"
4 // Copyright (c) 2002 - 2005, Intel Corporation
5 // All rights reserved.
6 //
7 // Contributed 2002 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. 
35 // 
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 // 01/17/02  Initial version
43 // 05/20/02  Cleaned up namespace and sf0 syntax
44 // 02/06/03  Reordered header: .section, .global, .proc, .align
45 // 03/31/05  Reformatted delimiters between data tables
47 // API
48 //==============================================================
49 // float erfcf(float)
51 // Overview of operation
52 //==============================================================
53 // 1. 0 <= x <= 10.06
54 //    
55 //    erfcf(x)  = P15(x) * exp( -x^2 )
57 //    Comment:
59 //    Let x(0)=0, x(i) = 2^(i), i=1,...3, x(4)= 10.06
60 // 
61 //    Let x(i)<= x < x(i+1).
62 //    We can find i as exponent of argument x (let i = 0 for 0<= x < 2  )
63 // 
64 //    Let P15(x) - polynomial approximation of degree 15 for function
65 //    erfcf(x) * exp( x^2) and x(i) <= x <= x(i+1), i = 0,1,2,3
66 //    Polynomial coeffitients we have in the table erfc_p_table.
68 //    So we can find result for erfcf(x) as above.
69 //    Algorithm description for exp function see below.
70 //                     
71 // 2. -4.4 <= x < 0
73 //    erfcf(x)  = 2.0 - erfcf(-x)
75 // 3. x > 10.06
77 //    erfcf(x)  ~=~ 0.0
79 // 4. x < -4.4
80 //            
81 //    erfcf(x)  ~=~ 2.0
83 // Special values 
84 //==============================================================
85 // erfcf(+0)    = 1.0
86 // erfcf(-0)    = 1.0
88 // erfcf(+qnan) = +qnan 
89 // erfcf(-qnan) = -qnan 
90 // erfcf(+snan) = +qnan 
91 // erfcf(-snan) = -qnan 
93 // erfcf(-inf)  = 2.0 
94 // erfcf(+inf)  = +0
96 //==============================================================
97 // Take double exp(double) from libm_64.
99 // Overview of operation
100 //==============================================================
101 // Take the input x. w is "how many log2/128 in x?"
102 //  w = x * 128/log2
103 //  n = int(w)
104 //  x = n log2/128 + r + delta
106 //  n = 128M + index_1 + 2^4 index_2
107 //  x = M log2 + (log2/128) index_1 + (log2/8) index_2 + r + delta
109 //  exp(x) = 2^M  2^(index_1/128)  2^(index_2/8) exp(r) exp(delta)
110 //       Construct 2^M
111 //       Get 2^(index_1/128) from table_1;
112 //       Get 2^(index_2/8)   from table_2;
113 //       Calculate exp(r) by series
114 //          r = x - n (log2/128)_high
115 //          delta = - n (log2/128)_low
116 //       Calculate exp(delta) as 1 + delta
118 // Comment for erfcf:
120 // Let exp(r) = 1 + x + 0.5*x^2 + (1/6)*x^3
121 // Let delta  = 0.
122 //==============================================================
124 // Registers used
125 //==============================================================
126 // Floating Point registers used: 
127 // f8, input
128 // f6,f7,f9 -> f11,  f32 -> f92
130 // General registers used: 
131 // r14 -> r22,r32 -> r50 
133 // Predicate registers used:
134 // p6 -> p15
136 // Assembly macros
137 //==============================================================
138 EXP_AD_TB1             = r14
139 exp_GR_sig_inv_ln2     = r15
140 exp_TB1_size           = r16
141 exp_GR_rshf_2to56      = r17
142 exp_GR_exp_2tom56      = r18
144 exp_GR_rshf            = r33
145 EXP_AD_TB2             = r34
146 EXP_AD_P               = r35
147 exp_GR_N               = r36
148 exp_GR_index_1         = r37
149 exp_GR_index_2_16      = r38
150 exp_GR_biased_M        = r39
151 EXP_AD_T1              = r40
152 EXP_AD_T2              = r41
153 exp_TB2_size           = r42
155 // GR for erfcf(x)
156 //==============================================================
157 GR_IndxPlusBias        = r19
158 GR_ExpMask             = r20
159 GR_BIAS                = r21
160 GR_ShftPi_bias         = r22
162 GR_P_POINT_1           = r43
163 GR_P_POINT_2           = r44
164 GR_P_POINT_3           = r45
165 GR_P_POINT_4           = r46
167 GR_ShftPi              = r47
168 GR_EpsNorm             = r48
170 GR_05                  = r49
171 GR_1_by_6              = r50
173 // GR for __libm_support call
174 //==============================================================
176 GR_SAVE_B0             = r43
177 GR_SAVE_PFS            = r44
178 GR_SAVE_GP             = r45
179 GR_SAVE_SP             = r46
181 GR_Parameter_X         = r47
182 GR_Parameter_Y         = r48
183 GR_Parameter_RESULT    = r49
184 GR_Parameter_TAG       = r50
187 // FR for exp(-x^2)
188 //==============================================================
189 FR_X                   = f10
190 FR_Y                   = f1
191 FR_RESULT              = f8
193 EXP_2TOM56             = f6
194 EXP_INV_LN2_2TO63      = f7
195 EXP_W_2TO56_RSH        = f9
196 exp_ln2_by_128_hi      = f11
198 EXP_RSHF_2TO56         = f32 
199 exp_ln2_by_128_lo      = f33 
200 EXP_RSHF               = f34
201 EXP_Nfloat             = f35 
202 exp_r                  = f36
203 exp_rsq                = f37
204 EXP_2M                 = f38
205 exp_S1                 = f39
206 exp_T1                 = f40
207 exp_P                  = f41
208 exp_S                  = f42
209 EXP_NORM_f8            = f43   
210 exp_S2                 = f44
211 exp_T2                 = f45
213 // FR for erfcf(x)
214 //==============================================================
215 FR_AbsArg              = f46
216 FR_Tmp                 = f47
217 FR_Tmp1                = f48
218 FR_Tmpf                = f49
219 FR_NormX               = f50
221 FR_A15                 = f51
222 FR_A14                 = f52
224 FR_A13                 = f53
225 FR_A12                 = f54
227 FR_A11                 = f55
228 FR_A10                 = f56
230 FR_A9                  = f57
231 FR_A8                  = f58
233 FR_A7                  = f59
234 FR_A6                  = f60
236 FR_A5                  = f61
237 FR_A4                  = f62
239 FR_A3                  = f63
240 FR_A2                  = f64
242 FR_A1                  = f65
243 FR_A0                  = f66
245 FR_P15_0_1             = f67
246 FR_P15_1_1             = f68
247 FR_P15_1_2             = f69
248 FR_P15_2_1             = f70
249 FR_P15_2_2             = f71
250 FR_P15_3_1             = f72
251 FR_P15_3_2             = f73
252 FR_P15_4_1             = f74
253 FR_P15_4_2             = f75
254 FR_P15_7_1             = f76
255 FR_P15_7_2             = f77
256 FR_P15_8_1             = f78
257 FR_P15_9_1             = f79
258 FR_P15_9_2             = f80
259 FR_P15_13_1            = f81
260 FR_P15_14_1            = f82
261 FR_P15_14_2            = f83
263 FR_2                   = f84
264 FR_05                  = f85
265 FR_1_by_6              = f86
266 FR_Pol                 = f87
267 FR_Exp                 = f88
269 FR_POS_ARG_ASYMP       = f89
270 FR_NEG_ARG_ASYMP       = f90
272 FR_UnfBound            = f91
273 FR_EpsNorm             = f92
275 // Data tables
276 //==============================================================
277 RODATA
278 .align 16
280 // ************* DO NOT CHANGE ORDER OF THESE TABLES ********************
282 // double-extended 1/ln(2)
283 // 3fff b8aa 3b29 5c17 f0bb be87fed0691d3e88
284 // 3fff b8aa 3b29 5c17 f0bc 
285 // For speed the significand will be loaded directly with a movl and setf.sig
286 //   and the exponent will be bias+63 instead of bias+0.  Thus subsequent
287 //   computations need to scale appropriately.
288 // The constant 128/ln(2) is needed for the computation of w.  This is also 
289 //   obtained by scaling the computations.
291 // Two shifting constants are loaded directly with movl and setf.d. 
292 //   1. EXP_RSHF_2TO56 = 1.1000..00 * 2^(63-7) 
293 //        This constant is added to x*1/ln2 to shift the integer part of
294 //        x*128/ln2 into the rightmost bits of the significand.
295 //        The result of this fma is EXP_W_2TO56_RSH.
296 //   2. EXP_RSHF       = 1.1000..00 * 2^(63) 
297 //        This constant is subtracted from EXP_W_2TO56_RSH * 2^(-56) to give
298 //        the integer part of w, n, as a floating-point number.
299 //        The result of this fms is EXP_Nfloat.
302 LOCAL_OBJECT_START(exp_table_1)
304 data4 0x4120f5c3, 0x408ccccd      //POS_ARG_ASYMP = 10.06, NEG_ARG_ASYMP = 4.4
305 data4 0x41131Cdf, 0x00800000     //UnfBound ~=~ 9.1, EpsNorm ~=~ 1.1754944e-38
307 data8 0xb17217f7d1cf79ab , 0x00003ff7                            // ln2/128 hi
308 data8 0xc9e3b39803f2f6af , 0x00003fb7                            // ln2/128 lo
310 // Table 1 is 2^(index_1/128) where
311 // index_1 goes from 0 to 15
313 data8 0x8000000000000000 , 0x00003FFF
314 data8 0x80B1ED4FD999AB6C , 0x00003FFF
315 data8 0x8164D1F3BC030773 , 0x00003FFF
316 data8 0x8218AF4373FC25EC , 0x00003FFF
317 data8 0x82CD8698AC2BA1D7 , 0x00003FFF
318 data8 0x8383594EEFB6EE37 , 0x00003FFF
319 data8 0x843A28C3ACDE4046 , 0x00003FFF
320 data8 0x84F1F656379C1A29 , 0x00003FFF
321 data8 0x85AAC367CC487B15 , 0x00003FFF
322 data8 0x8664915B923FBA04 , 0x00003FFF
323 data8 0x871F61969E8D1010 , 0x00003FFF
324 data8 0x87DB357FF698D792 , 0x00003FFF
325 data8 0x88980E8092DA8527 , 0x00003FFF
326 data8 0x8955EE03618E5FDD , 0x00003FFF
327 data8 0x8A14D575496EFD9A , 0x00003FFF
328 data8 0x8AD4C6452C728924 , 0x00003FFF
329 LOCAL_OBJECT_END(exp_table_1)
331 // Table 2 is 2^(index_1/8) where
332 // index_2 goes from 0 to 7
334 LOCAL_OBJECT_START(exp_table_2)
336 data8 0x8000000000000000 , 0x00003FFF
337 data8 0x8B95C1E3EA8BD6E7 , 0x00003FFF
338 data8 0x9837F0518DB8A96F , 0x00003FFF
339 data8 0xA5FED6A9B15138EA , 0x00003FFF
340 data8 0xB504F333F9DE6484 , 0x00003FFF
341 data8 0xC5672A115506DADD , 0x00003FFF
342 data8 0xD744FCCAD69D6AF4 , 0x00003FFF
343 data8 0xEAC0C6E7DD24392F , 0x00003FFF
344 LOCAL_OBJECT_END(exp_table_2)
346 LOCAL_OBJECT_START(erfc_p_table)
348 // Pol_0 
349 data8 0xBEA3260C63CB0446             //A15 = -5.70673541831883454676e-07
350 data8 0x3EE63D6178077654             //A14 = +1.06047480138940182343e-05
351 data8 0xBF18646BC5FC70A7             //A13 = -9.30491237309283694347e-05
352 data8 0x3F40F92F909117FE             //A12 = +5.17986512144075019133e-04
353 data8 0xBF611344289DE1E6             //A11 = -2.08438217390159994419e-03
354 data8 0x3F7AF9FE6AD16DC0             //A10 = +6.58606893292862351928e-03
355 data8 0xBF91D219E196CBA7             //A9 = -1.74030345858217321001e-02
356 data8 0x3FA4AFDDA355854C             //A8 = +4.04042493708041968315e-02
357 data8 0xBFB5D465BB7025AE             //A7 = -8.52721769916999425445e-02
358 data8 0x3FC54C15A95B717D             //A6 = +1.66384418195672549029e-01
359 data8 0xBFD340A75B4B1AB5             //A5 = -3.00821150926292166899e-01
360 data8 0x3FDFFFC0BFCD247F             //A4 = +4.99984919839853542841e-01
361 data8 0xBFE81270C361852B             //A3 = -7.52251035312075583309e-01
362 data8 0x3FEFFFFFC67295FC             //A2 = +9.99999892800303301771e-01
363 data8 0xBFF20DD74F8CD2BF             //A1 = -1.12837916445020868099e+00
364 data8 0x3FEFFFFFFFFE7C1D             //A0 = +9.99999999988975570714e-01
365 // Pol_1 
366 data8 0xBDE8EC4BDD953B56             //A15 = -1.81338928934942767144e-10
367 data8 0x3E43607F269E2A1C             //A14 = +9.02309090272196442358e-09
368 data8 0xBE8C4D9E69C10E02             //A13 = -2.10875261143659275328e-07
369 data8 0x3EC9CF2F84566725             //A12 = +3.07671055805877356583e-06
370 data8 0xBF007980B1B46A4D             //A11 = -3.14228438702169818945e-05
371 data8 0x3F2F4C3AD6DEF24A             //A10 = +2.38783056770846320260e-04
372 data8 0xBF56F5129F8D30FA             //A9 = -1.40120333363130546426e-03
373 data8 0x3F7AA6C7ABFC38EE             //A8 = +6.50671002200751820429e-03
374 data8 0xBF98E7522CB84BEF             //A7 = -2.43199195666185511109e-02
375 data8 0x3FB2F68EB1C3D073             //A6 = +7.40746673580490638637e-02
376 data8 0xBFC7C16055AC6385             //A5 = -1.85588876564704611769e-01
377 data8 0x3FD8A707AEF5A440             //A4 = +3.85194702967570635211e-01
378 data8 0xBFE547BFE39AE2EA             //A3 = -6.65008492032112467310e-01
379 data8 0x3FEE7C91BDF13578             //A2 = +9.52706213932898128515e-01
380 data8 0xBFF1CB5B61F8C589             //A1 = -1.11214769621105541214e+00
381 data8 0x3FEFEA56BC81FD37             //A0 = +9.97355812243688815239e-01
382 // Pol_2 
383 data8 0xBD302724A12F46E0             //A15 = -5.73866382814058809406e-14
384 data8 0x3D98889B75D3102E             //A14 = +5.57829983681360947356e-12
385 data8 0xBDF16EA15074A1E9             //A13 = -2.53671153922423457844e-10
386 data8 0x3E3EC6E688CFEE5F             //A12 = +7.16581828336436419561e-09
387 data8 0xBE82E5ED44C52609             //A11 = -1.40802202239825487803e-07
388 data8 0x3EC120BE5CE42353             //A10 = +2.04180535157522081699e-06
389 data8 0xBEF7B8B0311A1911             //A9 = -2.26225266204633600888e-05
390 data8 0x3F29A281F43FC238             //A8 = +1.95577968156184077632e-04
391 data8 0xBF55E19858B3B7A4             //A7 = -1.33552434527526534043e-03
392 data8 0x3F7DAC8C3D12E5FD             //A6 = +7.24463253680473816303e-03
393 data8 0xBF9FF9C04613FB47             //A5 = -3.12261622211693854028e-02
394 data8 0x3FBB3D5DBF9D9366             //A4 = +1.06405123978743883370e-01
395 data8 0xBFD224DE9F62C258             //A3 = -2.83500342989133623476e-01
396 data8 0x3FE28A95CB8C6D3E             //A2 = +5.79417131000276437708e-01
397 data8 0xBFEC21205D358672             //A1 = -8.79043752717008257224e-01
398 data8 0x3FEDAE44D5EDFE5B             //A0 = +9.27523057776805771830e-01
399 // Pol_3 
400 data8 0xBCA3BCA734AC82F1             //A15 = -1.36952437983096410260e-16
401 data8 0x3D16740DC3990612             //A14 = +1.99425676175410093285e-14
402 data8 0xBD77F4353812C46A             //A13 = -1.36162367755616790260e-12
403 data8 0x3DCFD0BE13C73DB4             //A12 = +5.78718761040355136007e-11
404 data8 0xBE1D728DF71189B4             //A11 = -1.71406885583934105120e-09
405 data8 0x3E64252C8CB710B5             //A10 = +3.75233795940731111303e-08
406 data8 0xBEA514B93180F33D             //A9 = -6.28261292774310809962e-07
407 data8 0x3EE1381118CC7151             //A8 = +8.21066421390821904504e-06
408 data8 0xBF1634404FB0FA72             //A7 = -8.47019436358372148764e-05
409 data8 0x3F46B2CBBCF0EB32             //A6 = +6.92700845213200923490e-04
410 data8 0xBF725C2B445E6D81             //A5 = -4.48243046949004063741e-03
411 data8 0x3F974E7CFA4D89D9             //A4 = +2.27603462002522228717e-02
412 data8 0xBFB6D7BAC2E342D1             //A3 = -8.92292714882032736443e-02
413 data8 0x3FD0D156AD9CE2A6             //A2 = +2.62777013343603696631e-01
414 data8 0xBFE1C228572AADB0             //A1 = -5.54950876471982857725e-01
415 data8 0x3FE8A739F48B9A3B             //A0 = +7.70413377406675619766e-01
416 LOCAL_OBJECT_END(erfc_p_table)
419 .section .text
420 GLOBAL_LIBM_ENTRY(erfcf)
422 // Form index i for table erfc_p_table as exponent of x 
423 // We use i + bias in real calculations 
424 { .mlx
425       getf.exp       GR_IndxPlusBias = f8          // (sign + exp + bias) of x
426       movl           exp_GR_sig_inv_ln2 = 0xb8aa3b295c17f0bc //signif.of 1/ln2
428 { .mlx
429       addl           EXP_AD_TB1    = @ltoff(exp_table_1), gp
430       movl           exp_GR_rshf_2to56 = 0x4768000000000000 // 1.100 2^(63+56)
434 // Form argument EXP_NORM_f8 for exp(-x^2)
435 { .mfi
436       ld8            EXP_AD_TB1    = [EXP_AD_TB1]
437       fcmp.ge.s1     p6,p7 = f8, f0                     // p6: x >= 0 ,p7: x<0
438       mov            GR_BIAS = 0x0FFFF
440 { .mfi
441       mov            exp_GR_exp_2tom56 = 0xffff-56
442       fnma.s1        EXP_NORM_f8   = f8, f8, f0                       //  -x^2
443       mov            GR_ExpMask  = 0x1ffff
447 // Form two constants we need
448 //  1/ln2 * 2^63  to compute  w = x * 1/ln2 * 128 
449 //  1.1000..000 * 2^(63+63-7) to right shift int(w) into the significand
451 // p9:  x = 0,+inf,-inf,nan,unnorm.
452 // p10: x!= 0,+inf,-inf,nan,unnorm.
453 { .mfi
454       setf.sig       EXP_INV_LN2_2TO63 = exp_GR_sig_inv_ln2 // Form 1/ln2*2^63
455       fclass.m       p9,p10 = f8,0xef       
456       shl            GR_ShftPi_bias = GR_BIAS, 7
458 { .mfi
459       setf.d         EXP_RSHF_2TO56 = exp_GR_rshf_2to56 //Const 1.10*2^(63+56)
460       nop.f          0
461       and            GR_IndxPlusBias = GR_IndxPlusBias, GR_ExpMask // i + bias
465 { .mfi
466       alloc          r32 = ar.pfs, 0, 15, 4, 0
467 (p6)  fma.s1         FR_AbsArg = f1, f0, f8                  // |x| if x >= 0
468       cmp.lt         p15,p0 = GR_IndxPlusBias, GR_BIAS//p15: i < 0 (for |x|<1)
470 { .mlx
471       setf.exp       EXP_2TOM56 = exp_GR_exp_2tom56 //2^-56 for scaling Nfloat
472       movl           exp_GR_rshf = 0x43e8000000000000 //1.10 2^63,right shift.
476 { .mfi
477       ldfps          FR_POS_ARG_ASYMP, FR_NEG_ARG_ASYMP = [EXP_AD_TB1],8
478       nop.f          0
479 (p15) mov            GR_IndxPlusBias = GR_BIAS            //Let i = 0 if i < 0
481 { .mlx
482       mov            GR_P_POINT_3 = 0x1A0
483       movl           GR_05 = 0x3fe0000000000000
487 // Form shift GR_ShftPi from the beginning of erfc_p_table 
488 // to the polynomial with number i
489 { .mfi
490       ldfps          FR_UnfBound, FR_EpsNorm = [EXP_AD_TB1],8
491       nop.f          0
492       shl            GR_ShftPi = GR_IndxPlusBias, 7
494 { .mfi
495       setf.d         EXP_RSHF = exp_GR_rshf   // Form right shift 1.100 * 2^63
496 (p7)  fms.s1         FR_AbsArg = f1, f0, f8                   // |x|  if x < 0
497       mov            exp_TB1_size  = 0x100 
501 // Form pointer GR_P_POINT_3 to the beginning of erfc_p_table 
502 { .mfi
503       setf.d         FR_05 = GR_05
504       nop.f          0
505       sub            GR_ShftPi = GR_ShftPi,GR_ShftPi_bias
507 { .mfb
508       add            GR_P_POINT_3 = GR_P_POINT_3, EXP_AD_TB1
509       nop.f          0
510 (p9)  br.cond.spnt   SPECIAL                  // For x = 0,+inf,-inf,nan,unnorm
514 { .mfi
515       add            GR_P_POINT_1 = GR_P_POINT_3, GR_ShftPi
516       nop.f          0
517       add            GR_P_POINT_2 = GR_P_POINT_3, GR_ShftPi
519 { .mfi
520       ldfe           exp_ln2_by_128_hi  = [EXP_AD_TB1],16 
521       fma.s1         FR_NormX = f8,f1,f0
522       add            GR_P_POINT_3 = GR_P_POINT_3, GR_ShftPi
526 // Load coefficients for polynomial P15(x)
527 { .mfi
528       ldfpd          FR_A15, FR_A14 = [GR_P_POINT_1], 16
529       nop.f          0      
530       add            GR_P_POINT_3 = 0x30, GR_P_POINT_3
532 { .mfi
533       ldfe           exp_ln2_by_128_lo  = [EXP_AD_TB1], 16
534       nop.f          0      
535       add            GR_P_POINT_2 = 0x20, GR_P_POINT_2 
539 // Now EXP_AD_TB1 points to the beginning of table 1
540 { .mlx
541       ldfpd          FR_A13, FR_A12 = [GR_P_POINT_1] 
542       movl           GR_1_by_6 = 0x3FC5555555555555
544 { .mfi
545       add            GR_P_POINT_4 = 0x30, GR_P_POINT_2
546       nop.f          0
547       nop.i          0
551 { .mfi
552       ldfpd          FR_A11, FR_A10 = [GR_P_POINT_2]
553       fma.s1         FR_2 = f1, f1, f1
554       mov            exp_TB2_size  = 0x80
556 { .mfi
557       ldfpd          FR_A9, FR_A8 = [GR_P_POINT_3],16
558       nop.f          0
559       add            GR_P_POINT_1 = 0x60 ,GR_P_POINT_1
563 // W = X * Inv_log2_by_128
564 // By adding 1.10...0*2^63 we shift and get round_int(W) in significand.
565 // We actually add 1.10...0*2^56 to X * Inv_log2 to do the same thing.
566 { .mfi
567       ldfpd          FR_A7, FR_A6 = [GR_P_POINT_3] 
568       fma.s1     EXP_W_2TO56_RSH = EXP_NORM_f8,EXP_INV_LN2_2TO63,EXP_RSHF_2TO56
569       add            EXP_AD_TB2 = exp_TB1_size, EXP_AD_TB1
570       
572 { .mfi
573       ldfpd          FR_A5, FR_A4 = [GR_P_POINT_4], 16
574       nop.f          0
575       nop.i          0
579 { .mfi
580       ldfpd          FR_A3, FR_A2 = [GR_P_POINT_4]
581       fmerge.s       FR_X = f8,f8
582       nop.i          0
584 { .mfi 
585       ldfpd          FR_A1, FR_A0 = [GR_P_POINT_1]
586       nop.f          0
587       nop.i          0
591 //p14: x < - NEG_ARG_ASYMP = -4.4 -> erfcf(x) ~=~ 2.0
592 { .mfi
593       setf.d         FR_1_by_6  = GR_1_by_6
594 (p7)  fcmp.gt.unc.s1 p14,p0 = FR_AbsArg, FR_NEG_ARG_ASYMP          //p7: x < 0
595       nop.i          0
599 //p15: x > POS_ARG_ASYMP = 10.06 -> erfcf(x) ~=~ 0.0
600 { .mfi
601       nop.m          0
602 (p6)  fcmp.gt.unc.s1 p15,p0 = FR_AbsArg, FR_POS_ARG_ASYMP          //p6: x > 0
603       nop.i          0
604 }                       
607 { .mfi
608       nop.m          0
609       fcmp.le.s1     p8,p0 = FR_NormX, FR_UnfBound        // p8: x <= UnfBound
610       nop.i          0
612 { .mfb
613       nop.m          0
614 (p14) fnma.s.s0      FR_RESULT = FR_EpsNorm, FR_EpsNorm, FR_2//y = 2 if x <-4.4
615 (p14) br.ret.spnt    b0
619 // Nfloat = round_int(W) 
620 // The signficand of EXP_W_2TO56_RSH contains the rounded integer part of W,
621 // as a twos complement number in the lower bits (that is, it may be negative).
622 // That twos complement number (called N) is put into exp_GR_N.
624 // Since EXP_W_2TO56_RSH is scaled by 2^56, it must be multiplied by 2^-56
625 // before the shift constant 1.10000 * 2^63 is subtracted to yield EXP_Nfloat.
626 // Thus, EXP_Nfloat contains the floating point version of N
628 { .mfi
629       nop.m          0
630       fms.s1         EXP_Nfloat = EXP_W_2TO56_RSH, EXP_2TOM56, EXP_RSHF
631       nop.i          0
633 { .mfb
634 (p15) mov            GR_Parameter_TAG = 209
635 (p15) fma.s.s0       FR_RESULT = FR_EpsNorm,FR_EpsNorm,f0 //Result.for x>10.06
636 (p15) br.cond.spnt   __libm_error_region
637 }                   
640 // Now we can calculate polynomial P15(x)
641 { .mfi
642       nop.m          0
643       fma.s1         FR_P15_1_1 = FR_AbsArg, FR_AbsArg, f0             // x ^2
644       nop.i          0
646 { .mfi
647       nop.m          0
648       fma.s1         FR_P15_0_1 = FR_A15, FR_AbsArg, FR_A14
649       nop.i          0
653 { .mfi
654       nop.m          0
655       fma.s1         FR_P15_1_2 = FR_A13, FR_AbsArg, FR_A12 
656       nop.i          0 
660 { .mfi
661       getf.sig       exp_GR_N        = EXP_W_2TO56_RSH 
662       fma.s1         FR_P15_2_1 = FR_A9, FR_AbsArg, FR_A8 
663       nop.i          0 
665 { .mfi
666       nop.m          0
667       fma.s1         FR_P15_2_2 = FR_A11, FR_AbsArg, FR_A10 
668       nop.i          0
672 { .mfi
673       nop.m          0
674       fma.s1         FR_P15_3_1 = FR_A5, FR_AbsArg, FR_A4
675       nop.i          0                   
677 { .mfi
678       nop.m          0
679       fma.s1         FR_P15_3_2 = FR_A7, FR_AbsArg, FR_A6
680       nop.i          0
684 // exp_GR_index_1 has index_1
685 // exp_GR_index_2_16 has index_2 * 16
686 // exp_GR_biased_M has M
687 // exp_GR_index_1_16 has index_1 * 16
689 // r2 has true M
690 { .mfi
691       and            exp_GR_index_1 = 0x0f, exp_GR_N
692       fma.s1         FR_P15_4_1 = FR_A1, FR_AbsArg, FR_A0
693       shr            r2 = exp_GR_N,  0x7
694        
696 { .mfi
697       and            exp_GR_index_2_16 = 0x70, exp_GR_N
698       fma.s1         FR_P15_4_2 = FR_A3, FR_AbsArg, FR_A2
699       nop.i          0
703 // EXP_AD_T1 has address of T1                           
704 // EXP_AD_T2 has address if T2                            
706 { .mfi
707       add            EXP_AD_T2 = EXP_AD_TB2, exp_GR_index_2_16
708       nop.f          0                      
709       shladd         EXP_AD_T1 = exp_GR_index_1, 4, EXP_AD_TB1
711 { .mfi
712       addl           exp_GR_biased_M = 0xffff, r2
713       fnma.s1        exp_r   = EXP_Nfloat, exp_ln2_by_128_hi, EXP_NORM_f8
714       nop.i          0
718 // Create Scale = 2^M
719 // r = x - Nfloat * ln2_by_128_hi 
721 { .mfi
722       setf.exp       EXP_2M = exp_GR_biased_M
723       fma.s1         FR_P15_7_1 = FR_P15_0_1, FR_P15_1_1, FR_P15_1_2
724       nop.i          0
726 { .mfi
727       ldfe           exp_T2  = [EXP_AD_T2]      
728       nop.f          0
729       nop.i          0
733 // Load T1 and T2
735 { .mfi
736       ldfe           exp_T1  = [EXP_AD_T1]
737       fma.s1         FR_P15_7_2 = FR_P15_1_1, FR_P15_1_1, f0            // x^4
738       nop.i          0
740 { .mfi
741       nop.m          0
742       fma.s1         FR_P15_8_1 = FR_P15_1_1, FR_P15_2_2, FR_P15_2_1 
743       nop.i          0
747 { .mfi
748       nop.m          0
749       fma.s1         FR_P15_9_1 = FR_P15_1_1, FR_P15_4_2, FR_P15_4_1 
750       nop.i          0
752 { .mfi
753       nop.m          0
754       fma.s1         FR_P15_9_2 = FR_P15_1_1, FR_P15_3_2, FR_P15_3_1 
755       nop.i          0
759 { .mfi
760       nop.m          0
761       fma.s1         exp_P = FR_1_by_6, exp_r, FR_05 
762       nop.i          0
764 { .mfi
765       nop.m          0
766       fma.s1         exp_rsq = exp_r, exp_r, f0 
767       nop.i          0
771 { .mfi
772       nop.m          0
773       fma.s1         FR_P15_13_1 = FR_P15_7_2, FR_P15_7_1, FR_P15_8_1 
774       nop.i          0
778 { .mfi
779       nop.m          0
780       fma.s1         FR_P15_14_1 = FR_P15_7_2, FR_P15_9_2, FR_P15_9_1 
781       nop.i          0
783 { .mfi
784       nop.m          0
785       fma.s1         FR_P15_14_2 = FR_P15_7_2, FR_P15_7_2, f0           // x^8
786       nop.i          0
790 { .mfi
791       nop.m          0
792       fma.s1         exp_P     = exp_P, exp_rsq, exp_r
793       nop.i          0
795 { .mfi
796       nop.m          0
797       fma.s1         exp_S1  = EXP_2M, exp_T2, f0   
798       nop.i          0
802 { .mfi
803       nop.m          0
804       fma.s1         FR_Pol = FR_P15_14_2, FR_P15_13_1, FR_P15_14_1  // P15(x)
805       nop.i          0
809 { .mfi
810       nop.m          0
811       fma.s1         exp_S   = exp_S1, exp_T1, f0
812       nop.i          0
816 { .mfi
817       nop.m          0
818       fma.s1         FR_Exp = exp_S, exp_P, exp_S                 // exp(-x^2)
819       nop.i          0          
821 ;;   
823 { .mfi
824       nop.m          0
825       fma.s.s0       FR_Tmpf = f8, f1, f0                          //  Flag  d
826       nop.i          0 
830 //p6: result for     0 < x < = POS_ARG_ASYMP 
831 //p7: result for   - NEG_ARG_ASYMP  <= x < 0
832 //p8: exit   for   - NEG_ARG_ASYMP <= x <= UnfBound, x!=0
833 .pred.rel "mutex",p6,p7
834 { .mfi
835       nop.m          0
836 (p6)  fma.s.s0       f8 = FR_Exp, FR_Pol, f0 
837       nop.i          0         
839 { .mfb
840       mov            GR_Parameter_TAG = 209
841 (p7)  fnma.s.s0      f8 = FR_Exp, FR_Pol, FR_2
842 (p8)  br.ret.sptk    b0 
846 //p10: branch for  UnfBound < x < = POS_ARG_ASYMP
847 { .mfb
848       nop.m          0
849       nop.f          0
850 (p10) br.cond.spnt   __libm_error_region  
854 //Only via (p9)  br.cond.spnt   SPECIAL  for x = 0,+inf,-inf,nan,unnorm
855 SPECIAL:
857 { .mfi
858       nop.m          0
859       fclass.m.unc   p10,p0 = f8,0x07                            // p10: x = 0
860       nop.i          0
864 { .mfi
865       nop.m          0
866       fclass.m.unc   p11,p0 = f8,0x21                         // p11: x = +inf
867       nop.i          0
871 { .mfi
872       nop.m          0
873       fclass.m.unc   p12,p0 = f8,0x22                          // p12 x = -inf
874       nop.i          0
876 { .mfb
877       nop.m          0
878 (p10) fma.s.s0       f8 = f1, f1, f0
879 (p10) br.ret.sptk    b0                                // Quick exit for x = 0
883 { .mfi
884       nop.m          0
885       fclass.m.unc   p13,p0 = f8,0xc3                          // p13: x = nan
886       nop.i          0
888 { .mfb
889       nop.m          0
890 (p11) fma.s.s0       f8 = f0, f1, f0
891 (p11) br.ret.spnt    b0                             // Quick exit for x = +inf
894 { .mfi
895       nop.m          0
896       fclass.m.unc   p14,p0 = f8,0x0b                 // P14: x = unnormalized
897       nop.i          0
899 { .mfb
900       nop.m          0
901 (p12) fma.s.s0       f8 = f1, f1, f1
902 (p12) br.ret.spnt    b0                             // Quick exit for x = -inf
906 { .mfb
907       nop.m          0
908 (p13) fma.s.s0       f8 = f8, f1, f0
909 (p13) br.ret.sptk    b0                              // Quick exit for x = nan
913 { .mfb
914       nop.m          0
915 (p14) fnma.s.s0      f8 = f8, f1, f1
916 (p14) br.ret.sptk    b0                     // Quick exit for x = unnormalized
920 GLOBAL_LIBM_END(erfcf)
923 // Call via (p10) br.cond.spnt   __libm_error_region
924 //          for  UnfBound < x < = POS_ARG_ASYMP 
925 // and
926 // 
927 // call via (p15) br.cond.spnt   __libm_error_region
928 //          for  x > POS_ARG_ASYMP
930 LOCAL_LIBM_ENTRY(__libm_error_region)
931 .prologue
932 { .mfi
933         add   GR_Parameter_Y=-32,sp                       // Parameter 2 value
934         nop.f 0
935 .save   ar.pfs,GR_SAVE_PFS
936         mov  GR_SAVE_PFS=ar.pfs                                 // Save ar.pfs
938 { .mfi
939 .fframe 64 
940         add sp=-64,sp                                      // Create new stack
941         nop.f 0
942         mov GR_SAVE_GP=gp                                           // Save gp
944 { .mmi
945         stfs [GR_Parameter_Y] = FR_Y,16          // STORE Parameter 2 on stack
946         add GR_Parameter_X = 16,sp                      // Parameter 1 address
947 .save   b0, GR_SAVE_B0                      
948         mov GR_SAVE_B0=b0                                           // Save b0
950 .body
951 { .mib
952         stfs [GR_Parameter_X] = FR_X             // STORE Parameter 1 on stack
953         add   GR_Parameter_RESULT = 0,GR_Parameter_Y    // Parameter 3 address
954         nop.b 0                                      
956 { .mib
957         stfs [GR_Parameter_Y] = FR_RESULT        // STORE Parameter 3 on stack
958         add   GR_Parameter_Y = -16,GR_Parameter_Y  
959         br.call.sptk b0=__libm_error_support#  // Call error handling function
961 { .mmi
962         nop.m 0
963         nop.m 0
964         add   GR_Parameter_RESULT = 48,sp
966 { .mmi
967         ldfs  f8 = [GR_Parameter_RESULT]        // Get return result off stack
968 .restore sp
969         add   sp = 64,sp                              // Restore stack pointer
970         mov   b0 = GR_SAVE_B0                        // Restore return address
972 { .mib
973         mov   gp = GR_SAVE_GP                                    // Restore gp
974         mov   ar.pfs = GR_SAVE_PFS                           // Restore ar.pfs
975         br.ret.sptk     b0                                           // Return
976 };; 
978 LOCAL_LIBM_END(__libm_error_region)
979 .type   __libm_error_support#,@function
980 .global __libm_error_support#