4 // Copyright (c) 2002 - 2005, Intel Corporation
5 // All rights reserved.
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions are
12 // * Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
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.
19 // * The name of Intel Corporation may not be used to endorse or promote
20 // products derived from this software without specific prior written
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.
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.
39 //*********************************************************************
42 // 01/10/02 Initial version
43 // 01/25/02 Corrected parameter store, load, and tag for __libm_error_support
44 // 02/01/02 Added support of SIGN(GAMMA(x)) calculation
45 // 05/20/02 Cleaned up namespace and sf0 syntax
46 // 09/16/02 Improved accuracy on intervals reduced to [1;1.25]
47 // 10/21/02 Now it returns SIGN(GAMMA(x))=-1 for negative zero
48 // 02/10/03 Reordered header: .section, .global, .proc, .align
49 // 07/22/03 Reformatted some data tables
50 // 03/31/05 Reformatted delimiters between data tables
52 //*********************************************************************
54 //*********************************************************************
56 // Function: __libm_lgammaf(float x, int* signgam, int szsigngam)
57 // computes the principle value of the logarithm of the GAMMA function
58 // of x. Signum of GAMMA(x) is stored to memory starting at the address
59 // specified by the signgam.
61 //*********************************************************************
65 // Floating-Point Registers: f6-f15
68 // General Purpose Registers:
72 // r37-r40 (Used to pass arguments to error handling routine)
74 // Predicate Registers: p6-p15
76 //*********************************************************************
78 // IEEE Special Conditions:
80 // lgamma(+inf) = +inf
81 // lgamma(-inf) = +inf
82 // lgamma(+/-0) = +inf
83 // lgamma(x<0, x - integer) = +inf
84 // lgamma(SNaN) = QNaN
85 // lgamma(QNaN) = QNaN
87 //*********************************************************************
91 // The method consists of three cases.
93 // If 2^13 <= x < OVERFLOW_BOUNDARY use case lgammaf_pstirling;
94 // else if 1 < x < 2^13 use case lgammaf_regular;
95 // else if -9 < x < 1 use case lgammaf_negrecursion;
96 // else if -2^13 < x < -9 use case lgammaf_negpoly;
97 // else if x < -2^13 use case lgammaf_negstirling;
98 // else if x is close to negative
99 // roots of ln(GAMMA(x)) use case lgammaf_negroots;
102 // Case 2^13 <= x < OVERFLOW_BOUNDARY
103 // ----------------------------------
104 // Here we use algorithm based on the Stirling formula:
105 // ln(GAMMA(x)) = ln(sqrt(2*Pi)) + (x-0.5)*ln(x) - x
109 // To calculate ln(GAMMA(x)) for such arguments we use polynomial
110 // approximation on following intervals: [1.0; 1.25), [1.25; 1.5),
111 // [1.5, 1.75), [1.75; 2), [2; 4), [2^i; 2^(i+1)), i=1..8
113 // Following variants of approximation and argument reduction are used:
115 // ln(GAMMA(x)) ~ (x-1.0)*P7(x)
118 // ln(GAMMA(x)) ~ ln(GAMMA(x0))+(x-x0)*P8(x-x0),
119 // where x0 - point of local minimum on [1;2] rounded to nearest double
123 // ln(GAMMA(x)) ~ P8(x)
126 // ln(GAMMA(x)) ~ (x-2)*P7(x)
129 // ln(GAMMA(x)) ~ (x-2)*P10(x)
131 // 6. [2^i; 2^(i+1)), i=2..8
132 // ln(GAMMA(x)) ~ P10((x-2^i)/2^i)
136 // Here we use the recursive formula:
137 // ln(GAMMA(x)) = ln(GAMMA(x+1)) - ln(x)
139 // Using this formula we reduce argument to base interval [1.0; 2.0]
141 // Case -2^13 < x < -9
142 // --------------------
143 // Here we use the formula:
144 // ln(GAMMA(x)) = ln(Pi/(|x|*GAMMA(|x|)*sin(Pi*|x|))) =
145 // = -ln(|x|) - ln((GAMMA(|x|)) - ln(sin(Pi*r)/(Pi*r)) - ln(|r|)
146 // where r = x - rounded_to_nearest(x), i.e |r| <= 0.5 and
147 // ln(sin(Pi*r)/(Pi*r)) is approximated by 8-degree polynomial of r^2
151 // Here we use algorithm based on the Stirling formula:
152 // ln(GAMMA(x)) = -ln(sqrt(2*Pi)) + (|x|-0.5)ln(x) - |x| -
153 // - ln(sin(Pi*r)/(Pi*r)) - ln(|r|)
154 // where r = x - rounded_to_nearest(x).
156 // Neighbourhoods of negative roots
157 // --------------------------------
158 // Here we use polynomial approximation
159 // ln(GAMMA(x-x0)) = ln(GAMMA(x0)) + (x-x0)*P14(x-x0),
160 // where x0 is a root of ln(GAMMA(x)) rounded to nearest double
164 // Calculation of logarithm
165 // ------------------------
166 // Consider x = 2^N * xf so
167 // ln(x) = ln(frcpa(x)*x/frcpa(x))
168 // = ln(1/frcpa(x)) + ln(frcpa(x)*x)
170 // frcpa(x) = 2^(-N) * frcpa(xf)
172 // ln(1/frcpa(x)) = -ln(2^(-N)) - ln(frcpa(xf))
173 // = N*ln(2) - ln(frcpa(xf))
174 // = N*ln(2) + ln(1/frcpa(xf))
176 // ln(x) = ln(1/frcpa(x)) + ln(frcpa(x)*x) =
177 // = N*ln(2) + ln(1/frcpa(xf)) + ln(frcpa(x)*x)
178 // = N*ln(2) + T + ln(frcpa(x)*x)
180 // Let r = 1 - frcpa(x)*x, note that r is quite small by
183 // ln(x) = N*ln(2) + T + ln(1+r) ~ N*ln(2) + T + Series(r),
184 // where T - is precomputed tabular value,
185 // Series(r) = (P3*r + P2)*r^2 + (P1*r + 1)
187 //*********************************************************************
237 GR_Parameter_RESULT = r39
238 GR_Parameter_TAG = r40
240 //*********************************************************************
243 FR_Y = f1 // lgammaf is single argument function
332 FR_OverflowBound = f93
339 //*********************************************************************
343 LOCAL_OBJECT_START(lgammaf_data)
345 data8 0xbfd0001008f39d59 // P3
346 data8 0x3fd5556073e0c45a // P2
347 data8 0x3fe62e42fefa39ef // ln(2)
348 data8 0x3fe0000000000000 // 0.5
350 data8 0x3F60040155D5889E //ln(1/frcpa(1+ 0/256)
351 data8 0x3F78121214586B54 //ln(1/frcpa(1+ 1/256)
352 data8 0x3F841929F96832F0 //ln(1/frcpa(1+ 2/256)
353 data8 0x3F8C317384C75F06 //ln(1/frcpa(1+ 3/256)
354 data8 0x3F91A6B91AC73386 //ln(1/frcpa(1+ 4/256)
355 data8 0x3F95BA9A5D9AC039 //ln(1/frcpa(1+ 5/256)
356 data8 0x3F99D2A8074325F4 //ln(1/frcpa(1+ 6/256)
357 data8 0x3F9D6B2725979802 //ln(1/frcpa(1+ 7/256)
358 data8 0x3FA0C58FA19DFAAA //ln(1/frcpa(1+ 8/256)
359 data8 0x3FA2954C78CBCE1B //ln(1/frcpa(1+ 9/256)
360 data8 0x3FA4A94D2DA96C56 //ln(1/frcpa(1+ 10/256)
361 data8 0x3FA67C94F2D4BB58 //ln(1/frcpa(1+ 11/256)
362 data8 0x3FA85188B630F068 //ln(1/frcpa(1+ 12/256)
363 data8 0x3FAA6B8ABE73AF4C //ln(1/frcpa(1+ 13/256)
364 data8 0x3FAC441E06F72A9E //ln(1/frcpa(1+ 14/256)
365 data8 0x3FAE1E6713606D07 //ln(1/frcpa(1+ 15/256)
366 data8 0x3FAFFA6911AB9301 //ln(1/frcpa(1+ 16/256)
367 data8 0x3FB0EC139C5DA601 //ln(1/frcpa(1+ 17/256)
368 data8 0x3FB1DBD2643D190B //ln(1/frcpa(1+ 18/256)
369 data8 0x3FB2CC7284FE5F1C //ln(1/frcpa(1+ 19/256)
370 data8 0x3FB3BDF5A7D1EE64 //ln(1/frcpa(1+ 20/256)
371 data8 0x3FB4B05D7AA012E0 //ln(1/frcpa(1+ 21/256)
372 data8 0x3FB580DB7CEB5702 //ln(1/frcpa(1+ 22/256)
373 data8 0x3FB674F089365A7A //ln(1/frcpa(1+ 23/256)
374 data8 0x3FB769EF2C6B568D //ln(1/frcpa(1+ 24/256)
375 data8 0x3FB85FD927506A48 //ln(1/frcpa(1+ 25/256)
376 data8 0x3FB9335E5D594989 //ln(1/frcpa(1+ 26/256)
377 data8 0x3FBA2B0220C8E5F5 //ln(1/frcpa(1+ 27/256)
378 data8 0x3FBB0004AC1A86AC //ln(1/frcpa(1+ 28/256)
379 data8 0x3FBBF968769FCA11 //ln(1/frcpa(1+ 29/256)
380 data8 0x3FBCCFEDBFEE13A8 //ln(1/frcpa(1+ 30/256)
381 data8 0x3FBDA727638446A2 //ln(1/frcpa(1+ 31/256)
382 data8 0x3FBEA3257FE10F7A //ln(1/frcpa(1+ 32/256)
383 data8 0x3FBF7BE9FEDBFDE6 //ln(1/frcpa(1+ 33/256)
384 data8 0x3FC02AB352FF25F4 //ln(1/frcpa(1+ 34/256)
385 data8 0x3FC097CE579D204D //ln(1/frcpa(1+ 35/256)
386 data8 0x3FC1178E8227E47C //ln(1/frcpa(1+ 36/256)
387 data8 0x3FC185747DBECF34 //ln(1/frcpa(1+ 37/256)
388 data8 0x3FC1F3B925F25D41 //ln(1/frcpa(1+ 38/256)
389 data8 0x3FC2625D1E6DDF57 //ln(1/frcpa(1+ 39/256)
390 data8 0x3FC2D1610C86813A //ln(1/frcpa(1+ 40/256)
391 data8 0x3FC340C59741142E //ln(1/frcpa(1+ 41/256)
392 data8 0x3FC3B08B6757F2A9 //ln(1/frcpa(1+ 42/256)
393 data8 0x3FC40DFB08378003 //ln(1/frcpa(1+ 43/256)
394 data8 0x3FC47E74E8CA5F7C //ln(1/frcpa(1+ 44/256)
395 data8 0x3FC4EF51F6466DE4 //ln(1/frcpa(1+ 45/256)
396 data8 0x3FC56092E02BA516 //ln(1/frcpa(1+ 46/256)
397 data8 0x3FC5D23857CD74D5 //ln(1/frcpa(1+ 47/256)
398 data8 0x3FC6313A37335D76 //ln(1/frcpa(1+ 48/256)
399 data8 0x3FC6A399DABBD383 //ln(1/frcpa(1+ 49/256)
400 data8 0x3FC70337DD3CE41B //ln(1/frcpa(1+ 50/256)
401 data8 0x3FC77654128F6127 //ln(1/frcpa(1+ 51/256)
402 data8 0x3FC7E9D82A0B022D //ln(1/frcpa(1+ 52/256)
403 data8 0x3FC84A6B759F512F //ln(1/frcpa(1+ 53/256)
404 data8 0x3FC8AB47D5F5A310 //ln(1/frcpa(1+ 54/256)
405 data8 0x3FC91FE49096581B //ln(1/frcpa(1+ 55/256)
406 data8 0x3FC981634011AA75 //ln(1/frcpa(1+ 56/256)
407 data8 0x3FC9F6C407089664 //ln(1/frcpa(1+ 57/256)
408 data8 0x3FCA58E729348F43 //ln(1/frcpa(1+ 58/256)
409 data8 0x3FCABB55C31693AD //ln(1/frcpa(1+ 59/256)
410 data8 0x3FCB1E104919EFD0 //ln(1/frcpa(1+ 60/256)
411 data8 0x3FCB94EE93E367CB //ln(1/frcpa(1+ 61/256)
412 data8 0x3FCBF851C067555F //ln(1/frcpa(1+ 62/256)
413 data8 0x3FCC5C0254BF23A6 //ln(1/frcpa(1+ 63/256)
414 data8 0x3FCCC000C9DB3C52 //ln(1/frcpa(1+ 64/256)
415 data8 0x3FCD244D99C85674 //ln(1/frcpa(1+ 65/256)
416 data8 0x3FCD88E93FB2F450 //ln(1/frcpa(1+ 66/256)
417 data8 0x3FCDEDD437EAEF01 //ln(1/frcpa(1+ 67/256)
418 data8 0x3FCE530EFFE71012 //ln(1/frcpa(1+ 68/256)
419 data8 0x3FCEB89A1648B971 //ln(1/frcpa(1+ 69/256)
420 data8 0x3FCF1E75FADF9BDE //ln(1/frcpa(1+ 70/256)
421 data8 0x3FCF84A32EAD7C35 //ln(1/frcpa(1+ 71/256)
422 data8 0x3FCFEB2233EA07CD //ln(1/frcpa(1+ 72/256)
423 data8 0x3FD028F9C7035C1C //ln(1/frcpa(1+ 73/256)
424 data8 0x3FD05C8BE0D9635A //ln(1/frcpa(1+ 74/256)
425 data8 0x3FD085EB8F8AE797 //ln(1/frcpa(1+ 75/256)
426 data8 0x3FD0B9C8E32D1911 //ln(1/frcpa(1+ 76/256)
427 data8 0x3FD0EDD060B78081 //ln(1/frcpa(1+ 77/256)
428 data8 0x3FD122024CF0063F //ln(1/frcpa(1+ 78/256)
429 data8 0x3FD14BE2927AECD4 //ln(1/frcpa(1+ 79/256)
430 data8 0x3FD180618EF18ADF //ln(1/frcpa(1+ 80/256)
431 data8 0x3FD1B50BBE2FC63B //ln(1/frcpa(1+ 81/256)
432 data8 0x3FD1DF4CC7CF242D //ln(1/frcpa(1+ 82/256)
433 data8 0x3FD214456D0EB8D4 //ln(1/frcpa(1+ 83/256)
434 data8 0x3FD23EC5991EBA49 //ln(1/frcpa(1+ 84/256)
435 data8 0x3FD2740D9F870AFB //ln(1/frcpa(1+ 85/256)
436 data8 0x3FD29ECDABCDFA04 //ln(1/frcpa(1+ 86/256)
437 data8 0x3FD2D46602ADCCEE //ln(1/frcpa(1+ 87/256)
438 data8 0x3FD2FF66B04EA9D4 //ln(1/frcpa(1+ 88/256)
439 data8 0x3FD335504B355A37 //ln(1/frcpa(1+ 89/256)
440 data8 0x3FD360925EC44F5D //ln(1/frcpa(1+ 90/256)
441 data8 0x3FD38BF1C3337E75 //ln(1/frcpa(1+ 91/256)
442 data8 0x3FD3C25277333184 //ln(1/frcpa(1+ 92/256)
443 data8 0x3FD3EDF463C1683E //ln(1/frcpa(1+ 93/256)
444 data8 0x3FD419B423D5E8C7 //ln(1/frcpa(1+ 94/256)
445 data8 0x3FD44591E0539F49 //ln(1/frcpa(1+ 95/256)
446 data8 0x3FD47C9175B6F0AD //ln(1/frcpa(1+ 96/256)
447 data8 0x3FD4A8B341552B09 //ln(1/frcpa(1+ 97/256)
448 data8 0x3FD4D4F3908901A0 //ln(1/frcpa(1+ 98/256)
449 data8 0x3FD501528DA1F968 //ln(1/frcpa(1+ 99/256)
450 data8 0x3FD52DD06347D4F6 //ln(1/frcpa(1+ 100/256)
451 data8 0x3FD55A6D3C7B8A8A //ln(1/frcpa(1+ 101/256)
452 data8 0x3FD5925D2B112A59 //ln(1/frcpa(1+ 102/256)
453 data8 0x3FD5BF406B543DB2 //ln(1/frcpa(1+ 103/256)
454 data8 0x3FD5EC433D5C35AE //ln(1/frcpa(1+ 104/256)
455 data8 0x3FD61965CDB02C1F //ln(1/frcpa(1+ 105/256)
456 data8 0x3FD646A84935B2A2 //ln(1/frcpa(1+ 106/256)
457 data8 0x3FD6740ADD31DE94 //ln(1/frcpa(1+ 107/256)
458 data8 0x3FD6A18DB74A58C5 //ln(1/frcpa(1+ 108/256)
459 data8 0x3FD6CF31058670EC //ln(1/frcpa(1+ 109/256)
460 data8 0x3FD6F180E852F0BA //ln(1/frcpa(1+ 110/256)
461 data8 0x3FD71F5D71B894F0 //ln(1/frcpa(1+ 111/256)
462 data8 0x3FD74D5AEFD66D5C //ln(1/frcpa(1+ 112/256)
463 data8 0x3FD77B79922BD37E //ln(1/frcpa(1+ 113/256)
464 data8 0x3FD7A9B9889F19E2 //ln(1/frcpa(1+ 114/256)
465 data8 0x3FD7D81B037EB6A6 //ln(1/frcpa(1+ 115/256)
466 data8 0x3FD8069E33827231 //ln(1/frcpa(1+ 116/256)
467 data8 0x3FD82996D3EF8BCB //ln(1/frcpa(1+ 117/256)
468 data8 0x3FD85855776DCBFB //ln(1/frcpa(1+ 118/256)
469 data8 0x3FD8873658327CCF //ln(1/frcpa(1+ 119/256)
470 data8 0x3FD8AA75973AB8CF //ln(1/frcpa(1+ 120/256)
471 data8 0x3FD8D992DC8824E5 //ln(1/frcpa(1+ 121/256)
472 data8 0x3FD908D2EA7D9512 //ln(1/frcpa(1+ 122/256)
473 data8 0x3FD92C59E79C0E56 //ln(1/frcpa(1+ 123/256)
474 data8 0x3FD95BD750EE3ED3 //ln(1/frcpa(1+ 124/256)
475 data8 0x3FD98B7811A3EE5B //ln(1/frcpa(1+ 125/256)
476 data8 0x3FD9AF47F33D406C //ln(1/frcpa(1+ 126/256)
477 data8 0x3FD9DF270C1914A8 //ln(1/frcpa(1+ 127/256)
478 data8 0x3FDA0325ED14FDA4 //ln(1/frcpa(1+ 128/256)
479 data8 0x3FDA33440224FA79 //ln(1/frcpa(1+ 129/256)
480 data8 0x3FDA57725E80C383 //ln(1/frcpa(1+ 130/256)
481 data8 0x3FDA87D0165DD199 //ln(1/frcpa(1+ 131/256)
482 data8 0x3FDAAC2E6C03F896 //ln(1/frcpa(1+ 132/256)
483 data8 0x3FDADCCC6FDF6A81 //ln(1/frcpa(1+ 133/256)
484 data8 0x3FDB015B3EB1E790 //ln(1/frcpa(1+ 134/256)
485 data8 0x3FDB323A3A635948 //ln(1/frcpa(1+ 135/256)
486 data8 0x3FDB56FA04462909 //ln(1/frcpa(1+ 136/256)
487 data8 0x3FDB881AA659BC93 //ln(1/frcpa(1+ 137/256)
488 data8 0x3FDBAD0BEF3DB165 //ln(1/frcpa(1+ 138/256)
489 data8 0x3FDBD21297781C2F //ln(1/frcpa(1+ 139/256)
490 data8 0x3FDC039236F08819 //ln(1/frcpa(1+ 140/256)
491 data8 0x3FDC28CB1E4D32FD //ln(1/frcpa(1+ 141/256)
492 data8 0x3FDC4E19B84723C2 //ln(1/frcpa(1+ 142/256)
493 data8 0x3FDC7FF9C74554C9 //ln(1/frcpa(1+ 143/256)
494 data8 0x3FDCA57B64E9DB05 //ln(1/frcpa(1+ 144/256)
495 data8 0x3FDCCB130A5CEBB0 //ln(1/frcpa(1+ 145/256)
496 data8 0x3FDCF0C0D18F326F //ln(1/frcpa(1+ 146/256)
497 data8 0x3FDD232075B5A201 //ln(1/frcpa(1+ 147/256)
498 data8 0x3FDD490246DEFA6B //ln(1/frcpa(1+ 148/256)
499 data8 0x3FDD6EFA918D25CD //ln(1/frcpa(1+ 149/256)
500 data8 0x3FDD9509707AE52F //ln(1/frcpa(1+ 150/256)
501 data8 0x3FDDBB2EFE92C554 //ln(1/frcpa(1+ 151/256)
502 data8 0x3FDDEE2F3445E4AF //ln(1/frcpa(1+ 152/256)
503 data8 0x3FDE148A1A2726CE //ln(1/frcpa(1+ 153/256)
504 data8 0x3FDE3AFC0A49FF40 //ln(1/frcpa(1+ 154/256)
505 data8 0x3FDE6185206D516E //ln(1/frcpa(1+ 155/256)
506 data8 0x3FDE882578823D52 //ln(1/frcpa(1+ 156/256)
507 data8 0x3FDEAEDD2EAC990C //ln(1/frcpa(1+ 157/256)
508 data8 0x3FDED5AC5F436BE3 //ln(1/frcpa(1+ 158/256)
509 data8 0x3FDEFC9326D16AB9 //ln(1/frcpa(1+ 159/256)
510 data8 0x3FDF2391A2157600 //ln(1/frcpa(1+ 160/256)
511 data8 0x3FDF4AA7EE03192D //ln(1/frcpa(1+ 161/256)
512 data8 0x3FDF71D627C30BB0 //ln(1/frcpa(1+ 162/256)
513 data8 0x3FDF991C6CB3B379 //ln(1/frcpa(1+ 163/256)
514 data8 0x3FDFC07ADA69A910 //ln(1/frcpa(1+ 164/256)
515 data8 0x3FDFE7F18EB03D3E //ln(1/frcpa(1+ 165/256)
516 data8 0x3FE007C053C5002E //ln(1/frcpa(1+ 166/256)
517 data8 0x3FE01B942198A5A1 //ln(1/frcpa(1+ 167/256)
518 data8 0x3FE02F74400C64EB //ln(1/frcpa(1+ 168/256)
519 data8 0x3FE04360BE7603AD //ln(1/frcpa(1+ 169/256)
520 data8 0x3FE05759AC47FE34 //ln(1/frcpa(1+ 170/256)
521 data8 0x3FE06B5F1911CF52 //ln(1/frcpa(1+ 171/256)
522 data8 0x3FE078BF0533C568 //ln(1/frcpa(1+ 172/256)
523 data8 0x3FE08CD9687E7B0E //ln(1/frcpa(1+ 173/256)
524 data8 0x3FE0A10074CF9019 //ln(1/frcpa(1+ 174/256)
525 data8 0x3FE0B5343A234477 //ln(1/frcpa(1+ 175/256)
526 data8 0x3FE0C974C89431CE //ln(1/frcpa(1+ 176/256)
527 data8 0x3FE0DDC2305B9886 //ln(1/frcpa(1+ 177/256)
528 data8 0x3FE0EB524BAFC918 //ln(1/frcpa(1+ 178/256)
529 data8 0x3FE0FFB54213A476 //ln(1/frcpa(1+ 179/256)
530 data8 0x3FE114253DA97D9F //ln(1/frcpa(1+ 180/256)
531 data8 0x3FE128A24F1D9AFF //ln(1/frcpa(1+ 181/256)
532 data8 0x3FE1365252BF0865 //ln(1/frcpa(1+ 182/256)
533 data8 0x3FE14AE558B4A92D //ln(1/frcpa(1+ 183/256)
534 data8 0x3FE15F85A19C765B //ln(1/frcpa(1+ 184/256)
535 data8 0x3FE16D4D38C119FA //ln(1/frcpa(1+ 185/256)
536 data8 0x3FE18203C20DD133 //ln(1/frcpa(1+ 186/256)
537 data8 0x3FE196C7BC4B1F3B //ln(1/frcpa(1+ 187/256)
538 data8 0x3FE1A4A738B7A33C //ln(1/frcpa(1+ 188/256)
539 data8 0x3FE1B981C0C9653D //ln(1/frcpa(1+ 189/256)
540 data8 0x3FE1CE69E8BB106B //ln(1/frcpa(1+ 190/256)
541 data8 0x3FE1DC619DE06944 //ln(1/frcpa(1+ 191/256)
542 data8 0x3FE1F160A2AD0DA4 //ln(1/frcpa(1+ 192/256)
543 data8 0x3FE2066D7740737E //ln(1/frcpa(1+ 193/256)
544 data8 0x3FE2147DBA47A394 //ln(1/frcpa(1+ 194/256)
545 data8 0x3FE229A1BC5EBAC3 //ln(1/frcpa(1+ 195/256)
546 data8 0x3FE237C1841A502E //ln(1/frcpa(1+ 196/256)
547 data8 0x3FE24CFCE6F80D9A //ln(1/frcpa(1+ 197/256)
548 data8 0x3FE25B2C55CD5762 //ln(1/frcpa(1+ 198/256)
549 data8 0x3FE2707F4D5F7C41 //ln(1/frcpa(1+ 199/256)
550 data8 0x3FE285E0842CA384 //ln(1/frcpa(1+ 200/256)
551 data8 0x3FE294294708B773 //ln(1/frcpa(1+ 201/256)
552 data8 0x3FE2A9A2670AFF0C //ln(1/frcpa(1+ 202/256)
553 data8 0x3FE2B7FB2C8D1CC1 //ln(1/frcpa(1+ 203/256)
554 data8 0x3FE2C65A6395F5F5 //ln(1/frcpa(1+ 204/256)
555 data8 0x3FE2DBF557B0DF43 //ln(1/frcpa(1+ 205/256)
556 data8 0x3FE2EA64C3F97655 //ln(1/frcpa(1+ 206/256)
557 data8 0x3FE3001823684D73 //ln(1/frcpa(1+ 207/256)
558 data8 0x3FE30E97E9A8B5CD //ln(1/frcpa(1+ 208/256)
559 data8 0x3FE32463EBDD34EA //ln(1/frcpa(1+ 209/256)
560 data8 0x3FE332F4314AD796 //ln(1/frcpa(1+ 210/256)
561 data8 0x3FE348D90E7464D0 //ln(1/frcpa(1+ 211/256)
562 data8 0x3FE35779F8C43D6E //ln(1/frcpa(1+ 212/256)
563 data8 0x3FE36621961A6A99 //ln(1/frcpa(1+ 213/256)
564 data8 0x3FE37C299F3C366A //ln(1/frcpa(1+ 214/256)
565 data8 0x3FE38AE2171976E7 //ln(1/frcpa(1+ 215/256)
566 data8 0x3FE399A157A603E7 //ln(1/frcpa(1+ 216/256)
567 data8 0x3FE3AFCCFE77B9D1 //ln(1/frcpa(1+ 217/256)
568 data8 0x3FE3BE9D503533B5 //ln(1/frcpa(1+ 218/256)
569 data8 0x3FE3CD7480B4A8A3 //ln(1/frcpa(1+ 219/256)
570 data8 0x3FE3E3C43918F76C //ln(1/frcpa(1+ 220/256)
571 data8 0x3FE3F2ACB27ED6C7 //ln(1/frcpa(1+ 221/256)
572 data8 0x3FE4019C2125CA93 //ln(1/frcpa(1+ 222/256)
573 data8 0x3FE4181061389722 //ln(1/frcpa(1+ 223/256)
574 data8 0x3FE42711518DF545 //ln(1/frcpa(1+ 224/256)
575 data8 0x3FE436194E12B6BF //ln(1/frcpa(1+ 225/256)
576 data8 0x3FE445285D68EA69 //ln(1/frcpa(1+ 226/256)
577 data8 0x3FE45BCC464C893A //ln(1/frcpa(1+ 227/256)
578 data8 0x3FE46AED21F117FC //ln(1/frcpa(1+ 228/256)
579 data8 0x3FE47A1527E8A2D3 //ln(1/frcpa(1+ 229/256)
580 data8 0x3FE489445EFFFCCC //ln(1/frcpa(1+ 230/256)
581 data8 0x3FE4A018BCB69835 //ln(1/frcpa(1+ 231/256)
582 data8 0x3FE4AF5A0C9D65D7 //ln(1/frcpa(1+ 232/256)
583 data8 0x3FE4BEA2A5BDBE87 //ln(1/frcpa(1+ 233/256)
584 data8 0x3FE4CDF28F10AC46 //ln(1/frcpa(1+ 234/256)
585 data8 0x3FE4DD49CF994058 //ln(1/frcpa(1+ 235/256)
586 data8 0x3FE4ECA86E64A684 //ln(1/frcpa(1+ 236/256)
587 data8 0x3FE503C43CD8EB68 //ln(1/frcpa(1+ 237/256)
588 data8 0x3FE513356667FC57 //ln(1/frcpa(1+ 238/256)
589 data8 0x3FE522AE0738A3D8 //ln(1/frcpa(1+ 239/256)
590 data8 0x3FE5322E26867857 //ln(1/frcpa(1+ 240/256)
591 data8 0x3FE541B5CB979809 //ln(1/frcpa(1+ 241/256)
592 data8 0x3FE55144FDBCBD62 //ln(1/frcpa(1+ 242/256)
593 data8 0x3FE560DBC45153C7 //ln(1/frcpa(1+ 243/256)
594 data8 0x3FE5707A26BB8C66 //ln(1/frcpa(1+ 244/256)
595 data8 0x3FE587F60ED5B900 //ln(1/frcpa(1+ 245/256)
596 data8 0x3FE597A7977C8F31 //ln(1/frcpa(1+ 246/256)
597 data8 0x3FE5A760D634BB8B //ln(1/frcpa(1+ 247/256)
598 data8 0x3FE5B721D295F10F //ln(1/frcpa(1+ 248/256)
599 data8 0x3FE5C6EA94431EF9 //ln(1/frcpa(1+ 249/256)
600 data8 0x3FE5D6BB22EA86F6 //ln(1/frcpa(1+ 250/256)
601 data8 0x3FE5E6938645D390 //ln(1/frcpa(1+ 251/256)
602 data8 0x3FE5F673C61A2ED2 //ln(1/frcpa(1+ 252/256)
603 data8 0x3FE6065BEA385926 //ln(1/frcpa(1+ 253/256)
604 data8 0x3FE6164BFA7CC06B //ln(1/frcpa(1+ 254/256)
605 data8 0x3FE62643FECF9743 //ln(1/frcpa(1+ 255/256)
608 data8 0xBEB2CC7A38B9355F,0x3F035F2D1833BF4C // A10,A9
609 data8 0xBFF51BAA7FD27785,0x3FFC9D5D5B6CDEFF // A2,A1
610 data8 0xBF421676F9CB46C7,0x3F7437F2FA1436C6 // A8,A7
611 data8 0xBFD7A7041DE592FE,0x3FE9F107FEE8BD29 // A4,A3
613 data8 0x3F6BBBD68451C0CD,0xBF966EC3272A16F7 // A10,A9
614 data8 0x40022A24A39AD769,0x4014190EDF49C8C5 // A2,A1
615 data8 0x3FB130FD016EE241,0xBFC151B46E635248 // A8,A7
616 data8 0x3FDE8F611965B5FE,0xBFEB5110EB265E3D // A4,A3
618 data8 0x3F736EF93508626A,0xBF9FE5DBADF58AF1 // A10,A9
619 data8 0x40110A9FC5192058,0x40302008A6F96B29 // A2,A1
620 data8 0x3FB8E74E0CE1E4B5,0xBFC9B5DA78873656 // A8,A7
621 data8 0x3FE99D0DF10022DC,0xBFF829C0388F9484 // A4,A3
623 data8 0x3F7FFF9D6D7E9269,0xBFAA780A249AEDB1 // A10,A9
624 data8 0x402082A807AEA080,0x4045ED9868408013 // A2,A1
625 data8 0x3FC4E1E54C2F99B7,0xBFD5DE2D6FFF1490 // A8,A7
626 data8 0x3FF75FC89584AE87,0xC006B4BADD886CAE // A4,A3
628 data8 0x3F8CE54375841A5F,0xBFB801ABCFFA1BE2 // A10,A9
629 data8 0x403040A8B1815BDA,0x405B99A917D24B7A // A2,A1
630 data8 0x3FD30CAB81BFFA03,0xBFE41AEF61ECF48B // A8,A7
631 data8 0x400650CC136BEC43,0xC016022046E8292B // A4,A3
633 data8 0x3F9B69BD22CAA8B8,0xBFC6D48875B7A213 // A10,A9
634 data8 0x40402028CCAA2F6D,0x40709AACEB3CBE0F // A2,A1
635 data8 0x3FE22C6A5924761E,0xBFF342F5F224523D // A8,A7
636 data8 0x4015CD405CCA331F,0xC025AAD10482C769 // A4,A3
638 data8 0x3FAAAD9CD0E40D06,0xBFD63FC8505D80CB // A10,A9
639 data8 0x40501008D56C2648,0x408364794B0F4376 // A2,A1
640 data8 0x3FF1BE0126E00284,0xC002D8E3F6F7F7CA // A8,A7
641 data8 0x40258C757E95D860,0xC0357FA8FD398011 // A4,A3
643 data8 0x3FBA4DAC59D49FEB,0xBFE5F476D1C43A77 // A10,A9
644 data8 0x40600800D890C7C6,0x40962C42AAEC8EF0 // A2,A1
645 data8 0x40018680ECF19B89,0xC012A3EB96FB7BA4 // A8,A7
646 data8 0x40356C4CDD3B60F9,0xC0456A34BF18F440 // A4,A3
648 data8 0x3FCA1B54F6225A5A,0xBFF5CD67BA10E048 // A10,A9
649 data8 0x407003FED94C58C2,0x40A8F30B4ACBCD22 // A2,A1
650 data8 0x40116A135EB66D8C,0xC022891B1CED527E // A8,A7
651 data8 0x40455C4617FDD8BC,0xC0555F82729E59C4 // A4,A3
653 data8 0x3FD9FFF9095C6EC9,0xC005B88CB25D76C9 // A10,A9
654 data8 0x408001FE58FA734D,0x40BBB953BAABB0F3 // A2,A1
655 data8 0x40215B2F9FEB5D87,0xC0327B539DEA5058 // A8,A7
656 data8 0x40555444B3E8D64D,0xC0655A2B26F9FC8A // A4,A3
658 data8 0x3FE9F065A1C3D6B1,0xC015ACF6FAE8D78D // A10,A9
659 data8 0x409000FE383DD2B7,0x40CE7F5C1E8BCB8B // A2,A1
660 data8 0x40315324E5DB2EBE,0xC04274194EF70D18 // A8,A7
661 data8 0x4065504353FF2207,0xC075577FE1BFE7B6 // A4,A3
663 data8 0x3FF9E6FBC6B1C70D,0xC025A62DAF76F85D // A10,A9
664 data8 0x40A0007E2F61EBE8,0x40E0A2A23FB5F6C3 // A2,A1
665 data8 0x40414E9BC0A0141A,0xC0527030F2B69D43 // A8,A7
666 data8 0x40754E417717B45B,0xC085562A447258E5 // A4,A3
668 data8 0xbfdffffffffaea15 // P1
669 data8 0x3FDD8B618D5AF8FE // point of local minimum on [1;2]
670 data8 0x3FED67F1C864BEB5 // ln(sqrt(2*Pi))
671 data8 0x4008000000000000 // 3.0
673 data8 0xBF9E1C289FB224AB,0x3FBF7422445C9460 // A6,A5
674 data8 0xBFF01E76D66F8D8A // A0
675 data8 0xBFE2788CFC6F91DA // A1 [1.0;1.25)
676 data8 0x3FCB8CC69000EB5C,0xBFD41997A0C2C641 // A6,A5
677 data8 0x3FFCAB0BFA0EA462 // A0
678 data8 0xBFBF19B9BCC38A42 // A0 [1.25;1.5)
679 data8 0x3FD51EE4DE0A364C,0xBFE00D7F98A16E4B // A6,A5
680 data8 0x40210CE1F327E9E4 // A0
681 data8 0x4001DB08F9DFA0CC // A0 [1.5;1.75)
682 data8 0x3FE24F606742D252,0xBFEC81D7D12574EC // A6,A5
683 data8 0x403BE636A63A9C27 // A0
684 data8 0x4000A0CB38D6CF0A // A0 [1.75;2.0)
685 data8 0x3FF1029A9DD542B4,0xBFFAD37C209D3B25 // A6,A5
686 data8 0x405385E6FD9BE7EA // A0
687 data8 0x478895F1C0000000 // Overflow boundary
688 data8 0x400062D97D26B523,0xC00A03E1529FF023 // A6,A5
689 data8 0x4069204C51E566CE // A0
690 data8 0x0000000000000000 // pad
691 data8 0x40101476B38FD501,0xC0199DE7B387C0FC // A6,A5
692 data8 0x407EB8DAEC83D759 // A0
693 data8 0x0000000000000000 // pad
694 data8 0x401FDB008D65125A,0xC0296B506E665581 // A6,A5
695 data8 0x409226D93107EF66 // A0
696 data8 0x0000000000000000 // pad
697 data8 0x402FB3EAAF3E7B2D,0xC039521142AD8E0D // A6,A5
698 data8 0x40A4EFA4F072792E // A0
699 data8 0x0000000000000000 // pad
700 data8 0x403FA024C66B2563,0xC0494569F250E691 // A6,A5
701 data8 0x40B7B747C9235BB8 // A0
702 data8 0x0000000000000000 // pad
703 data8 0x404F9607D6DA512C,0xC0593F0B2EDDB4BC // A6,A5
704 data8 0x40CA7E29C5F16DE2 // A0
705 data8 0x0000000000000000 // pad
706 data8 0x405F90C5F613D98D,0xC0693BD130E50AAF // A6,A5
707 data8 0x40DD4495238B190C // A0
708 data8 0x0000000000000000 // pad
710 // polynomial approximation of ln(sin(Pi*x)/(Pi*x)), |x| <= 0.5
711 data8 0xBFD58731A486E820,0xBFA4452CC28E15A9 // S16,S14
712 data8 0xBFD013F6E1B86C4F,0xBFD5B3F19F7A341F // S8,S6
713 data8 0xBFC86A0D5252E778,0xBFC93E08C9EE284B // S12,S10
714 data8 0xBFE15132555C9EDD,0xBFFA51A662480E35 // S4,S2
717 data8 0xBFA697D6775F48EA,0x3FB9894B682A98E7 // A9,A8
718 data8 0xBFCA8969253CFF55,0x3FD15124EFB35D9D // A5,A4
719 data8 0xBFC1B00158AB719D,0x3FC5997D04E7F1C1 // A7,A6
720 data8 0xBFD9A4D50BAFF989,0x3FEA51A661F5176A // A3,A2
722 data8 0x3F838E0D35A6171A,0xBF831BBBD61313B7 // A8,A7
723 data8 0x3FB08B40196425D0,0xBFC2E427A53EB830 // A4,A3
724 data8 0x3F9285DDDC20D6C3,0xBFA0C90C9C223044 // A6,A5
725 data8 0x3FDEF72BC8F5287C,0x3D890B3DAEBC1DFC // A2,A1
727 data8 0x3F65D5A7EB31047F,0xBFA44EAC9BFA7FDE // A8,A7
728 data8 0x40051FEFE7A663D8,0xC012A5CFE00A2522 // A4,A3
729 data8 0x3FD0E1583AB00E08,0xBFF084AF95883BA5 // A6,A5
730 data8 0x40185982877AE0A2,0xC015F83DB73B57B7 // A2,A1
732 data8 0x3F4A9222032EB39A,0xBF8CBC9587EEA5A3 // A8,A7
733 data8 0x3FF795400783BE49,0xC00851BC418B8A25 // A4,A3
734 data8 0x3FBBC992783E8C5B,0xBFDFA67E65E89B29 // A6,A5
735 data8 0x4012B408F02FAF88,0xC013284CE7CB0C39 // A2,A1
738 data8 0xC003A7FC9600F86C // -2.4570247382208005860
739 data8 0xC009260DBC9E59AF // -3.1435808883499798405
740 data8 0xC005FB410A1BD901 // -2.7476826467274126919
741 data8 0xC00FA471547C2FE5 // -3.9552942848585979085
743 // polynomial approximation of ln(GAMMA(x)) near roots
744 // near -2.4570247382208005860
745 data8 0x3FF694A6058D9592,0x40136EEBB003A92B // R3,R2
746 data8 0x3FF83FE966AF5360,0x3C90323B6D1FE86D // R1,R0
747 // near -3.1435808883499798405
748 data8 0x405C11371268DA38,0x4039D4D2977D2C23 // R3,R2
749 data8 0x401F20A65F2FAC62,0x3CDE9605E3AE7A62 // R1,R0
750 // near -2.7476826467274126919
751 data8 0xC034185AC31314FF,0x4023267F3C28DFE3 // R3,R2
752 data8 0xBFFEA12DA904B194,0x3CA8FB8530BA7689 // R1,R0
753 // near -2.7476826467274126919
754 data8 0xC0AD25359E70C888,0x406F76DEAEA1B8C6 // R3,R2
755 data8 0xC034B99D966C5644,0xBCBDDC0336980B58 // R1,R0
756 LOCAL_OBJECT_END(lgammaf_data)
758 //*********************************************************************
761 GLOBAL_LIBM_ENTRY(__libm_lgammaf)
763 getf.exp GR_SignExp = f8
764 frcpa.s1 FR_InvX,p0 = f1,f8
765 mov GR_ExpOf2 = 0x10000
768 addl GR_ad_Data = @ltoff(lgammaf_data),gp
769 fcvt.fx.s1 FR_int_N = f8
770 mov GR_ExpMask = 0x1ffff
774 fclass.m p13,p0 = f8,0x1EF // is x NaTVal, NaN,
775 // +/-0, +/-INF or +/-deno?
776 mov GR_ExpBias = 0xffff
779 ld8 GR_ad_Data = [GR_ad_Data]
780 fma.s1 FR_Xp1 = f8,f1,f1
781 mov GR_StirlBound = 0x1000C
784 setf.exp FR_2 = GR_ExpOf2
785 fmerge.se FR_x = f1,f8
786 dep.z GR_Ind = GR_SignExp,3,4
789 cmp.eq p8,p0 = GR_SignExp,GR_ExpBias
790 fcvt.fx.trunc.s1 FR_int_Ntrunc = f8
791 and GR_Exp = GR_ExpMask,GR_SignExp
794 add GR_ad_C650 = 0xB20,GR_ad_Data
795 fcmp.lt.s1 p14,p15 = f8,f0
796 extr.u GR_Ind4T = GR_Sig,55,8
799 sub GR_PureExp = GR_Exp,GR_ExpBias
800 fnorm.s1 FR_NormX = f8
801 // jump if x is NaTVal, NaN, +/-0, +/-INF or +/-deno
802 (p13) br.cond.spnt lgammaf_spec
806 ldfpd FR_P1,FR_LocalMin = [GR_ad_C650],16
807 fms.s1 FR_xm2 = f8,f1,f1
808 add GR_ad_Co = 0x820,GR_ad_Data
811 ldfpd FR_P3,FR_P2 = [GR_ad_Data],16
812 cmp.ltu p9,p0 = GR_SignExp,GR_ExpBias
813 // jump if x is from the interval [1; 2)
814 (p8) br.cond.spnt lgammaf_1_2
817 setf.sig FR_int_Ln = GR_PureExp
818 fms.s1 FR_r = FR_InvX,f8,f1
819 shladd GR_ad_Co = GR_Ind,3,GR_ad_Co
822 ldfpd FR_LnSqrt2Pi,FR_3 = [GR_ad_C650],16
823 cmp.lt p13,p12 = GR_Exp,GR_StirlBound
824 // jump if x is from the interval (0; 1)
825 (p9) br.cond.spnt lgammaf_0_1
828 ldfpd FR_Ln2,FR_05 = [GR_ad_Data],16
829 fma.s1 FR_Xp2 = f1,f1,FR_Xp1 // (x+2)
830 shladd GR_ad_C650 = GR_Ind,2,GR_ad_C650
833 add GR_ad_Ce = 0x20,GR_ad_Co
835 add GR_ad_C43 = 0x30,GR_ad_Co
838 // load coefficients of polynomial approximation
839 // of ln(GAMMA(x)), 2 <= x < 2^13
840 (p13) ldfpd FR_A10,FR_A9 = [GR_ad_Co],16
841 fcvt.xf FR_N = FR_int_N
842 cmp.eq.unc p6,p7 = GR_ExpOf2,GR_SignExp
845 (p13) ldfpd FR_A8,FR_A7 = [GR_ad_Ce]
846 (p14) cmp.le.unc p9,p0 = GR_StirlBound,GR_Exp
847 // jump if x is less or equal to -2^13
848 (p9) br.cond.spnt lgammaf_negstirling
850 .pred.rel "mutex",p6,p7
852 (p13) ldfpd FR_A6,FR_A5 = [GR_ad_C650],16
853 (p6) fma.s1 FR_x = f0,f0,FR_NormX
854 shladd GR_ad_T = GR_Ind4T,3,GR_ad_Data
857 (p13) ldfpd FR_A4,FR_A3 = [GR_ad_C43]
858 (p7) fms.s1 FR_x = FR_x,f1,f1
859 (p14) mov GR_ReqBound = 0x20005
862 (p13) ldfpd FR_A2,FR_A1 = [GR_ad_Co],16
863 fms.s1 FR_xm2 = FR_xm2,f1,f1
864 (p14) extr.u GR_Arg = GR_Sig,60,4
867 mov GR_SignOfGamma = 1 // set sign of gamma(x) to 1
868 fcvt.xf FR_Ntrunc = FR_int_Ntrunc
872 ldfd FR_T = [GR_ad_T]
873 fma.s1 FR_r2 = FR_r,FR_r,f0
874 shl GR_ReqBound = GR_ReqBound,3
877 add GR_ad_Co = 0xCA0,GR_ad_Data
878 fnma.s1 FR_Req = FR_Xp1,FR_NormX,f0 // -x*(x+1)
879 (p14) shladd GR_Arg = GR_Exp,4,GR_Arg
882 (p13) ldfd FR_A0 = [GR_ad_C650]
883 fma.s1 FR_Xp3 = FR_2,f1,FR_Xp1 // (x+3)
884 (p14) cmp.le.unc p9,p0 = GR_Arg,GR_ReqBound
887 (p14) add GR_ad_Ce = 0x20,GR_ad_Co
888 fma.s1 FR_Xp4 = FR_2,FR_2,FR_NormX // (x+4)
889 (p15) add GR_ad_OvfBound = 0xBB8,GR_ad_Data
892 // load coefficients of polynomial approximation
893 // of ln(sin(Pi*xf)/(Pi*xf)), |xf| <= 0.5
894 (p14) ldfpd FR_S16,FR_S14 = [GR_ad_Co],16
895 (p14) fms.s1 FR_Xf = FR_NormX,f1,FR_N // xf = x - [x]
896 (p14) sub GR_SignOfGamma = r0,GR_SignOfGamma // set sign of
900 (p14) ldfpd FR_S12,FR_S10 = [GR_ad_Ce],16
901 fma.s1 FR_Xp5 = FR_2,FR_2,FR_Xp1 // (x+5)
902 // jump if x is from the interval (-9; 0)
903 (p9) br.cond.spnt lgammaf_negrecursion
906 (p14) ldfpd FR_S8,FR_S6 = [GR_ad_Co],16
907 fma.s1 FR_P32 = FR_P3,FR_r,FR_P2
911 (p14) ldfpd FR_S4,FR_S2 = [GR_ad_Ce],16
912 fma.s1 FR_x2 = FR_x,FR_x,f0
913 // jump if x is from the interval (-2^13; -9)
914 (p14) br.cond.spnt lgammaf_negpoly
917 ldfd FR_OverflowBound = [GR_ad_OvfBound]
918 (p12) fcvt.xf FR_N = FR_int_Ln
919 // set p9 if signgum is 32-bit int
920 // set p10 if signgum is 64-bit int
921 cmp.eq p10,p9 = 8,r34
925 (p12) fma.s1 FR_P10 = FR_P1,FR_r,f1
928 .pred.rel "mutex",p6,p7
929 .pred.rel "mutex",p9,p10
931 // store sign of gamma(x) as 32-bit int
932 (p9) st4 [r33] = GR_SignOfGamma
933 (p6) fma.s1 FR_xx = FR_x,FR_xm2,f0
937 // store sign of gamma(x) as 64-bit int
938 (p10) st8 [r33] = GR_SignOfGamma
939 (p7) fma.s1 FR_xx = f0,f0,FR_x
944 (p13) fma.s1 FR_A9 = FR_A10,FR_x,FR_A9
949 (p13) fma.s1 FR_A7 = FR_A8,FR_x,FR_A7
954 (p13) fma.s1 FR_A5 = FR_A6,FR_x,FR_A5
959 (p13) fma.s1 FR_A3 = FR_A4,FR_x,FR_A3
964 (p15) fcmp.eq.unc.s1 p8,p0 = FR_NormX,FR_2 // is input argument 2.0?
969 (p13) fma.s1 FR_A1 = FR_A2,FR_x,FR_A1
974 (p12) fma.s1 FR_T = FR_N,FR_Ln2,FR_T
979 (p12) fma.s1 FR_P32 = FR_P32,FR_r2,FR_P10
984 (p13) fma.s1 FR_x4 = FR_x2,FR_x2,f0
989 (p13) fma.s1 FR_x3 = FR_x2,FR_xx,f0
994 (p13) fma.s1 FR_A7 = FR_A9,FR_x2,FR_A7
999 (p8) fma.s.s0 f8 = f0,f0,f0
1000 (p8) br.ret.spnt b0 // fast exit for 2.0
1004 (p6) fma.s1 FR_A0 = FR_A0,FR_xm2,f0
1009 (p13) fma.s1 FR_A3 = FR_A5,FR_x2,FR_A3
1014 (p15) fcmp.le.unc.s1 p8,p0 = FR_OverflowBound,FR_NormX // overflow test
1019 (p12) fms.s1 FR_xm05 = FR_NormX,f1,FR_05
1024 (p12) fma.s1 FR_Ln = FR_P32,FR_r,FR_T
1029 (p12) fms.s1 FR_LnSqrt2Pi = FR_LnSqrt2Pi,f1,FR_NormX
1034 (p13) fma.s1 FR_A0 = FR_A1,FR_xx,FR_A0
1039 (p13) fma.s1 FR_A3 = FR_A7,FR_x4,FR_A3
1040 // jump if result overflows
1041 (p8) br.cond.spnt lgammaf_overflow
1043 .pred.rel "mutex",p12,p13
1046 (p12) fma.s.s0 f8 = FR_Ln,FR_xm05,FR_LnSqrt2Pi
1051 (p13) fma.s.s0 f8 = FR_A3,FR_x3,FR_A0
1054 // branch for calculating of ln(GAMMA(x)) for 0 < x < 1
1055 //---------------------------------------------------------------------
1059 getf.sig GR_Ind = FR_Xp1
1060 fma.s1 FR_r2 = FR_r,FR_r,f0
1061 mov GR_fff7 = 0xFFF7
1064 ldfpd FR_Ln2,FR_05 = [GR_ad_Data],16
1065 fma.s1 FR_P32 = FR_P3,FR_r,FR_P2
1066 // input argument can't be equal to 1.0
1067 cmp.eq p0,p14 = r0,r0
1070 getf.exp GR_Exp = FR_w
1071 fcvt.xf FR_N = FR_int_Ln
1072 add GR_ad_Co = 0xCE0,GR_ad_Data
1075 shladd GR_ad_T = GR_Ind4T,3,GR_ad_Data
1076 fma.s1 FR_P10 = FR_P1,FR_r,f1
1077 add GR_ad_Ce = 0xD00,GR_ad_Data
1080 ldfd FR_T = [GR_ad_T]
1081 fma.s1 FR_w2 = FR_w,FR_w,f0
1082 extr.u GR_Ind = GR_Ind,61,2
1086 fma.s1 FR_Q32 = FR_P3,FR_w,FR_P2
1087 //// add GR_ad_C0 = 0xB30,GR_ad_Data
1088 add GR_ad_C0 = 0xB38,GR_ad_Data
1091 and GR_Exp = GR_Exp,GR_ExpMask
1093 shladd GR_IndX8 = GR_Ind,3,r0
1096 shladd GR_IndX2 = GR_Ind,1,r0
1097 fma.s1 FR_Q10 = FR_P1,FR_w,f1
1098 cmp.eq p6,p15 = 0,GR_Ind
1101 shladd GR_ad_Co = GR_IndX8,3,GR_ad_Co
1102 (p6) fma.s1 FR_x = f0,f0,FR_NormX
1103 shladd GR_ad_C0 = GR_IndX2,4,GR_ad_C0
1106 shladd GR_ad_Ce = GR_IndX8,3,GR_ad_Ce
1108 (p15) cmp.eq.unc p7,p8 = 1,GR_Ind
1110 .pred.rel "mutex",p7,p8
1112 ldfpd FR_A8,FR_A7 = [GR_ad_Co],16
1113 (p7) fms.s1 FR_x = FR_NormX,f1,FR_LocalMin
1114 cmp.ge p10,p11 = GR_Exp,GR_fff7
1117 ldfpd FR_A6,FR_A5 = [GR_ad_Ce],16
1118 (p8) fma.s1 FR_x = f1,f1,FR_NormX
1119 br.cond.sptk lgamma_0_2_core
1121 // branch for calculating of ln(GAMMA(x)) for 1 <= x < 2
1122 //---------------------------------------------------------------------
1126 add GR_ad_Co = 0xCF0,GR_ad_Data
1127 fcmp.eq.s1 p14,p0 = f1,FR_NormX // is input argument 1.0?
1128 extr.u GR_Ind = GR_Sig,61,2
1131 add GR_ad_Ce = 0xD10,GR_ad_Data
1133 //// add GR_ad_C0 = 0xB40,GR_ad_Data
1134 add GR_ad_C0 = 0xB48,GR_ad_Data
1137 shladd GR_IndX8 = GR_Ind,3,r0
1139 shladd GR_IndX2 = GR_Ind,1,r0
1142 cmp.eq p6,p15 = 0,GR_Ind // p6 <- x from [1;1.25)
1144 cmp.ne p9,p0 = r0,r0
1147 shladd GR_ad_Co = GR_IndX8,3,GR_ad_Co
1148 (p6) fms.s1 FR_x = FR_NormX,f1,f1 // reduced x for [1;1.25)
1149 shladd GR_ad_C0 = GR_IndX2,4,GR_ad_C0
1152 shladd GR_ad_Ce = GR_IndX8,3,GR_ad_Ce
1153 (p14) fma.s.s0 f8 = f0,f0,f0
1154 (p15) cmp.eq.unc p7,p8 = 1,GR_Ind // p7 <- x from [1.25;1.5)
1156 .pred.rel "mutex",p7,p8
1158 ldfpd FR_A8,FR_A7 = [GR_ad_Co],16
1159 (p7) fms.s1 FR_x = FR_xm2,f1,FR_LocalMin
1163 ldfpd FR_A6,FR_A5 = [GR_ad_Ce],16
1164 (p8) fma.s1 FR_x = f0,f0,FR_NormX
1165 (p9) cmp.eq.unc p10,p11 = r0,r0
1169 ldfpd FR_A4,FR_A3 = [GR_ad_Co],16
1170 ldfpd FR_A2,FR_A1 = [GR_ad_Ce],16
1171 mov GR_SignOfGamma = 1 // set sign of gamma(x) to 1
1174 // add GR_ad_C0 = 8,GR_ad_C0
1175 ldfd FR_A0 = [GR_ad_C0]
1177 // set p13 if signgum is 32-bit int
1178 // set p15 if signgum is 64-bit int
1179 cmp.eq p15,p13 = 8,r34
1181 .pred.rel "mutex",p13,p15
1183 // store sign of gamma(x)
1184 (p13) st4 [r33] = GR_SignOfGamma // as 32-bit int
1185 (p15) st8 [r33] = GR_SignOfGamma // as 64-bit int
1186 (p11) fma.s1 FR_Q32 = FR_Q32,FR_w2,FR_Q10
1190 (p10) fma.s1 FR_P32 = FR_P32,FR_r2,FR_P10
1191 (p14) br.ret.spnt b0 // fast exit for 1.0
1195 (p10) fma.s1 FR_T = FR_N,FR_Ln2,FR_T
1196 cmp.eq p6,p7 = 0,GR_Ind // p6 <- x from [1;1.25)
1200 fma.s1 FR_x2 = FR_x,FR_x,f0
1201 cmp.eq p8,p0 = r0,r0 // set p8 to 1 that means we on [1;2]
1205 (p11) fma.s1 FR_Ln = FR_Q32,FR_w,f0
1213 .pred.rel "mutex",p6,p7
1216 (p6) fma.s1 FR_xx = f0,f0,FR_x
1221 (p7) fma.s1 FR_xx = f0,f0,f1
1226 fma.s1 FR_A7 = FR_A8,FR_x,FR_A7
1231 fma.s1 FR_A5 = FR_A6,FR_x,FR_A5
1232 (p9) cmp.ne p8,p0 = r0,r0 // set p8 to 0 that means we on [0;1]
1236 fma.s1 FR_A3 = FR_A4,FR_x,FR_A3
1241 fma.s1 FR_A1 = FR_A2,FR_x,FR_A1
1246 fma.s1 FR_x4 = FR_x2,FR_x2,f0
1251 (p10) fma.s1 FR_Ln = FR_P32,FR_r,FR_T
1256 fma.s1 FR_A5 = FR_A7,FR_x2,FR_A5
1261 fma.s1 FR_A1 = FR_A3,FR_x2,FR_A1
1264 .pred.rel "mutex",p9,p8
1267 (p9) fms.d.s1 FR_A0 = FR_A0,FR_xx,FR_Ln
1272 (p8) fms.s1 FR_A0 = FR_A0,FR_xx,f0
1277 fma.d.s1 FR_A1 = FR_A5,FR_x4,FR_A1
1285 .pred.rel "mutex",p6,p7
1288 (p6) fma.s.s0 f8 = FR_A1,FR_x2,FR_A0
1293 (p7) fma.s.s0 f8 = FR_A1,FR_x,FR_A0
1296 // branch for calculating of ln(GAMMA(x)) for -9 < x < 1
1297 //---------------------------------------------------------------------
1299 lgammaf_negrecursion:
1301 getf.sig GR_N = FR_int_Ntrunc
1302 fms.s1 FR_1pXf = FR_Xp2,f1,FR_Ntrunc // 1 + (x+1) - [x]
1306 add GR_ad_Co = 0xCE0,GR_ad_Data
1307 fms.s1 FR_Xf = FR_Xp1,f1,FR_Ntrunc // (x+1) - [x]
1311 add GR_ad_Ce = 0xD00,GR_ad_Data
1312 fma.s1 FR_Xp6 = FR_2,FR_2,FR_Xp2 // (x+6)
1313 add GR_ad_C0 = 0xB30,GR_ad_Data
1316 sub GR_Neg2 = r0,GR_Neg2
1317 fma.s1 FR_Xp7 = FR_2,FR_3,FR_Xp1 // (x+7)
1318 sub GR_Neg4 = r0,GR_Neg4
1321 cmp.ne p8,p0 = r0,GR_N
1322 fcmp.eq.s1 p13,p0 = FR_NormX,FR_Ntrunc
1323 and GR_IntNum = 0xF,GR_N
1326 cmp.lt p6,p0 = GR_N,GR_Neg2
1327 fma.s1 FR_Xp8 = FR_2,FR_3,FR_Xp2 // (x+8)
1328 cmp.lt p7,p0 = GR_N,GR_Neg4
1331 getf.d GR_Arg = FR_NormX
1332 (p6) fma.s1 FR_Xp2 = FR_Xp2,FR_Xp3,f0
1333 (p8) tbit.z.unc p14,p15 = GR_IntNum,0
1336 sub GR_RootInd = 0xE,GR_IntNum
1337 (p7) fma.s1 FR_Xp4 = FR_Xp4,FR_Xp5,f0
1338 add GR_ad_Root = 0xDE0,GR_ad_Data
1341 shladd GR_ad_Root = GR_RootInd,3,GR_ad_Root
1342 fms.s1 FR_x = FR_Xp1,f1,FR_Ntrunc // (x+1) - [x]
1348 (p13) br.cond.spnt lgammaf_singularity
1350 .pred.rel "mutex",p14,p15
1352 cmp.gt p6,p0 = 0xA,GR_IntNum
1353 (p14) fma.s1 FR_Req = FR_Req,FR_Xf,f0
1354 cmp.gt p7,p0 = 0xD,GR_IntNum
1357 (p15) mov GR_SignOfGamma = 1 // set sign of gamma(x) to 1
1358 (p15) fnma.s1 FR_Req = FR_Req,FR_Xf,f0
1359 cmp.leu p0,p13 = 2,GR_RootInd
1363 (p6) fma.s1 FR_Xp6 = FR_Xp6,FR_Xp7,f0
1364 (p13) add GR_ad_RootCo = 0xE00,GR_ad_Data
1368 fcmp.eq.s1 p12,p11 = FR_1pXf,FR_2
1372 getf.sig GR_Sig = FR_1pXf
1373 fcmp.le.s1 p9,p0 = FR_05,FR_Xf
1377 (p13) shladd GR_RootInd = GR_RootInd,4,r0
1378 (p7) fma.s1 FR_Xp2 = FR_Xp2,FR_Xp4,f0
1379 (p8) cmp.gt.unc p10,p0 = 0x9,GR_IntNum
1381 .pred.rel "mutex",p11,p12
1384 (p10) fma.s1 FR_Req = FR_Req,FR_Xp8,f0
1385 (p11) extr.u GR_Ind = GR_Sig,61,2
1388 (p13) add GR_RootInd = GR_RootInd,GR_RootInd
1390 (p12) mov GR_Ind = 3
1393 shladd GR_IndX2 = GR_Ind,1,r0
1395 cmp.gt p14,p0 = 2,GR_Ind
1398 shladd GR_IndX8 = GR_Ind,3,r0
1400 cmp.eq p6,p0 = 1,GR_Ind
1402 .pred.rel "mutex",p6,p9
1404 shladd GR_ad_Co = GR_IndX8,3,GR_ad_Co
1405 (p6) fms.s1 FR_x = FR_Xf,f1,FR_LocalMin
1406 cmp.gt p10,p0 = 0xB,GR_IntNum
1409 shladd GR_ad_Ce = GR_IndX8,3,GR_ad_Ce
1410 (p9) fma.s1 FR_x = f0,f0,FR_1pXf
1411 shladd GR_ad_C0 = GR_IndX2,4,GR_ad_C0
1414 // load coefficients of polynomial approximation
1415 // of ln(GAMMA(x)), 1 <= x < 2
1416 ldfpd FR_A8,FR_A7 = [GR_ad_Co],16
1417 (p10) fma.s1 FR_Xp2 = FR_Xp2,FR_Xp6,f0
1418 add GR_ad_C0 = 8,GR_ad_C0
1421 ldfpd FR_A6,FR_A5 = [GR_ad_Ce],16
1423 (p14) add GR_ad_Root = 0x10,GR_ad_Root
1426 ldfpd FR_A4,FR_A3 = [GR_ad_Co],16
1428 add GR_ad_RootCe = 0xE10,GR_ad_Data
1431 ldfpd FR_A2,FR_A1 = [GR_ad_Ce],16
1433 (p14) add GR_RootInd = 0x40,GR_RootInd
1436 ldfd FR_A0 = [GR_ad_C0]
1437 (p13) add GR_ad_RootCo = GR_ad_RootCo,GR_RootInd
1438 (p13) add GR_ad_RootCe = GR_ad_RootCe,GR_RootInd
1441 (p13) ld8 GR_Root = [GR_ad_Root]
1442 (p13) ldfd FR_Root = [GR_ad_Root]
1443 mov GR_ExpBias = 0xffff
1447 fma.s1 FR_x2 = FR_x,FR_x,f0
1451 (p8) cmp.gt.unc p10,p0 = 0xF,GR_IntNum
1452 movl GR_Dx = 0x000000014F8B588E
1455 // load coefficients of polynomial approximation
1456 // of ln(GAMMA(x)), x is close to one of negative roots
1457 (p13) ldfpd FR_R3,FR_R2 = [GR_ad_RootCo]
1458 // arguments for logarithm
1459 (p10) fma.s1 FR_Req = FR_Req,FR_Xp2,f0
1460 mov GR_ExpMask = 0x1ffff
1463 (p13) ldfpd FR_R1,FR_R0 = [GR_ad_RootCe]
1465 // set p9 if signgum is 32-bit int
1466 // set p8 if signgum is 64-bit int
1467 cmp.eq p8,p9 = 8,r34
1469 .pred.rel "mutex",p9,p8
1471 (p9) st4 [r33] = GR_SignOfGamma // as 32-bit int
1472 fma.s1 FR_A7 = FR_A8,FR_x,FR_A7
1473 (p13) sub GR_Root = GR_Arg,GR_Root
1476 (p8) st8 [r33] = GR_SignOfGamma // as 64-bit int
1477 fma.s1 FR_A5 = FR_A6,FR_x,FR_A5
1482 fms.s1 FR_w = FR_Req,f1,f1
1483 (p13) add GR_Root = GR_Root,GR_Dx
1488 (p13) add GR_2xDx = GR_Dx,GR_Dx
1492 fma.s1 FR_A3 = FR_A4,FR_x,FR_A3
1497 fma.s1 FR_A1 = FR_A2,FR_x,FR_A1
1498 (p13) cmp.leu.unc p10,p0 = GR_Root,GR_2xDx
1502 frcpa.s1 FR_InvX,p0 = f1,FR_Req
1507 (p10) fms.s1 FR_rx = FR_NormX,f1,FR_Root
1511 getf.exp GR_SignExp = FR_Req
1512 fma.s1 FR_x4 = FR_x2,FR_x2,f0
1516 getf.sig GR_Sig = FR_Req
1517 fma.s1 FR_A5 = FR_A7,FR_x2,FR_A5
1521 sub GR_PureExp = GR_SignExp,GR_ExpBias
1522 fma.s1 FR_w2 = FR_w,FR_w,f0
1527 fma.s1 FR_Q32 = FR_P3,FR_w,FR_P2
1531 setf.sig FR_int_Ln = GR_PureExp
1532 fma.s1 FR_A1 = FR_A3,FR_x2,FR_A1
1533 extr.u GR_Ind4T = GR_Sig,55,8
1537 fma.s1 FR_Q10 = FR_P1,FR_w,f1
1541 shladd GR_ad_T = GR_Ind4T,3,GR_ad_Data
1542 fms.s1 FR_r = FR_InvX,FR_Req,f1
1547 (p10) fms.s1 FR_rx2 = FR_rx,FR_rx,f0
1551 ldfd FR_T = [GR_ad_T]
1552 (p10) fma.s1 FR_R2 = FR_R3,FR_rx,FR_R2
1557 (p10) fma.s1 FR_R0 = FR_R1,FR_rx,FR_R0
1561 getf.exp GR_Exp = FR_w
1562 fma.s1 FR_A1 = FR_A5,FR_x4,FR_A1
1563 mov GR_ExpMask = 0x1ffff
1567 fma.s1 FR_Q32 = FR_Q32, FR_w2,FR_Q10
1572 fma.s1 FR_r2 = FR_r,FR_r,f0
1573 mov GR_fff7 = 0xFFF7
1577 fma.s1 FR_P32 = FR_P3,FR_r,FR_P2
1582 fma.s1 FR_P10 = FR_P1,FR_r,f1
1583 and GR_Exp = GR_ExpMask,GR_Exp
1587 (p10) fma.s.s0 f8 = FR_R2,FR_rx2,FR_R0
1588 (p10) br.ret.spnt b0 // exit for arguments close to negative roots
1592 fcvt.xf FR_N = FR_int_Ln
1596 cmp.ge p14,p15 = GR_Exp,GR_fff7
1602 fma.s1 FR_A0 = FR_A1,FR_x,FR_A0
1607 (p15) fma.s1 FR_Ln = FR_Q32,FR_w,f0
1612 (p14) fma.s1 FR_P32 = FR_P32,FR_r2,FR_P10
1613 cmp.eq p6,p7 = 0,GR_Ind
1617 (p14) fma.s1 FR_T = FR_N,FR_Ln2,FR_T
1622 (p14) fma.s1 FR_Ln = FR_P32,FR_r,FR_T
1625 .pred.rel "mutex",p6,p7
1628 (p6) fms.s.s0 f8 = FR_A0,FR_x,FR_Ln
1633 (p7) fms.s.s0 f8 = FR_A0,f1,FR_Ln
1637 // branch for calculating of ln(GAMMA(x)) for x < -2^13
1638 //---------------------------------------------------------------------
1640 lgammaf_negstirling:
1642 shladd GR_ad_T = GR_Ind4T,3,GR_ad_Data
1643 fms.s1 FR_Xf = FR_NormX,f1,FR_N // xf = x - [x]
1644 mov GR_SingBound = 0x10016
1647 add GR_ad_Co = 0xCA0,GR_ad_Data
1648 fma.s1 FR_P32 = FR_P3,FR_r,FR_P2
1652 ldfd FR_T = [GR_ad_T]
1653 fcvt.xf FR_int_Ln = FR_int_Ln
1654 cmp.le p6,p0 = GR_SingBound,GR_Exp
1657 add GR_ad_Ce = 0x20,GR_ad_Co
1658 fma.s1 FR_r2 = FR_r,FR_r,f0
1659 (p6) br.cond.spnt lgammaf_singularity
1662 // load coefficients of polynomial approximation
1663 // of ln(sin(Pi*xf)/(Pi*xf)), |xf| <= 0.5
1664 ldfpd FR_S16,FR_S14 = [GR_ad_Co],16
1665 fma.s1 FR_P10 = FR_P1,FR_r,f1
1669 ldfpd FR_S12,FR_S10 = [GR_ad_Ce],16
1670 fms.s1 FR_xm05 = FR_NormX,f1,FR_05
1674 ldfpd FR_S8,FR_S6 = [GR_ad_Co],16
1675 ldfpd FR_S4,FR_S2 = [GR_ad_Ce],16
1679 getf.sig GR_N = FR_int_Ntrunc // signgam calculation
1680 fma.s1 FR_Xf2 = FR_Xf,FR_Xf,f0
1685 frcpa.s1 FR_InvXf,p0 = f1,FR_Xf
1689 getf.d GR_Arg = FR_Xf
1690 fcmp.eq.s1 p6,p0 = FR_NormX,FR_N
1691 mov GR_ExpBias = 0x3FF
1695 fma.s1 FR_T = FR_int_Ln,FR_Ln2,FR_T
1696 extr.u GR_Exp = GR_Arg,52,11
1700 fma.s1 FR_P32 = FR_P32,FR_r2,FR_P10
1704 sub GR_PureExp = GR_Exp,GR_ExpBias
1705 fma.s1 FR_S14 = FR_S16,FR_Xf2,FR_S14
1706 extr.u GR_Ind4T = GR_Arg,44,8
1709 mov GR_SignOfGamma = 1 // set signgam to -1
1710 fma.s1 FR_S10 = FR_S12,FR_Xf2,FR_S10
1711 (p6) br.cond.spnt lgammaf_singularity
1714 setf.sig FR_int_Ln = GR_PureExp
1715 fms.s1 FR_rf = FR_InvXf,FR_Xf,f1
1716 // set p14 if GR_N is even
1717 tbit.z p14,p0 = GR_N,0
1720 shladd GR_ad_T = GR_Ind4T,3,GR_ad_Data
1721 fma.s1 FR_Xf4 = FR_Xf2,FR_Xf2,f0
1725 (p14) sub GR_SignOfGamma = r0,GR_SignOfGamma // set signgam to -1
1726 fma.s1 FR_S6 = FR_S8,FR_Xf2,FR_S6
1730 // set p9 if signgum is 32-bit int
1731 // set p10 if signgum is 64-bit int
1732 cmp.eq p10,p9 = 8,r34
1733 fma.s1 FR_S2 = FR_S4,FR_Xf2,FR_S2
1737 ldfd FR_Tf = [GR_ad_T]
1738 fma.s1 FR_Ln = FR_P32,FR_r,FR_T
1743 fma.s1 FR_LnSqrt2Pi = FR_LnSqrt2Pi,f1,FR_NormX
1746 .pred.rel "mutex",p9,p10
1748 (p9) st4 [r33] = GR_SignOfGamma // as 32-bit int
1749 fma.s1 FR_rf2 = FR_rf,FR_rf,f0
1753 (p10) st8 [r33] = GR_SignOfGamma // as 64-bit int
1754 fma.s1 FR_S10 = FR_S14,FR_Xf4,FR_S10
1759 fma.s1 FR_P32f = FR_P3,FR_rf,FR_P2
1764 fma.s1 FR_Xf8 = FR_Xf4,FR_Xf4,f0
1769 fma.s1 FR_P10f = FR_P1,FR_rf,f1
1774 fma.s1 FR_S2 = FR_S6,FR_Xf4,FR_S2
1779 fms.s1 FR_Ln = FR_Ln,FR_xm05,FR_LnSqrt2Pi
1784 fcvt.xf FR_Nf = FR_int_Ln
1789 fma.s1 FR_S2 = FR_S10,FR_Xf8,FR_S2
1794 fma.s1 FR_Tf = FR_Nf,FR_Ln2,FR_Tf
1799 fma.s1 FR_P32f = FR_P32f,FR_rf2,FR_P10f // ??????
1804 fnma.s1 FR_Ln = FR_S2,FR_Xf2,FR_Ln
1809 fma.s1 FR_Lnf = FR_P32f,FR_rf,FR_Tf
1814 fms.s.s0 f8 = FR_Ln,f1,FR_Lnf
1817 // branch for calculating of ln(GAMMA(x)) for -2^13 < x < -9
1818 //---------------------------------------------------------------------
1822 getf.d GR_Arg = FR_Xf
1823 frcpa.s1 FR_InvXf,p0 = f1,FR_Xf
1824 mov GR_ExpBias = 0x3FF
1828 fma.s1 FR_Xf2 = FR_Xf,FR_Xf,f0
1832 getf.sig GR_N = FR_int_Ntrunc
1833 fcvt.xf FR_N = FR_int_Ln
1834 mov GR_SignOfGamma = 1
1838 fma.s1 FR_A9 = FR_A10,FR_x,FR_A9
1843 fma.s1 FR_P10 = FR_P1,FR_r,f1
1844 extr.u GR_Exp = GR_Arg,52,11
1848 fma.s1 FR_x4 = FR_x2,FR_x2,f0
1852 sub GR_PureExp = GR_Exp,GR_ExpBias
1853 fma.s1 FR_A7 = FR_A8,FR_x,FR_A7
1854 tbit.z p14,p0 = GR_N,0
1858 fma.s1 FR_A5 = FR_A6,FR_x,FR_A5
1862 setf.sig FR_int_Ln = GR_PureExp
1863 fma.s1 FR_A3 = FR_A4,FR_x,FR_A3
1868 fma.s1 FR_A1 = FR_A2,FR_x,FR_A1
1869 (p14) sub GR_SignOfGamma = r0,GR_SignOfGamma
1873 fms.s1 FR_rf = FR_InvXf,FR_Xf,f1
1878 fma.s1 FR_Xf4 = FR_Xf2,FR_Xf2,f0
1883 fma.s1 FR_S14 = FR_S16,FR_Xf2,FR_S14
1888 fma.s1 FR_S10 = FR_S12,FR_Xf2,FR_S10
1893 fma.s1 FR_T = FR_N,FR_Ln2,FR_T
1898 fma.s1 FR_P32 = FR_P32,FR_r2,FR_P10
1903 fma.s1 FR_S6 = FR_S8,FR_Xf2,FR_S6
1904 extr.u GR_Ind4T = GR_Arg,44,8
1908 fma.s1 FR_S2 = FR_S4,FR_Xf2,FR_S2
1913 fma.s1 FR_A7 = FR_A9,FR_x2,FR_A7
1917 shladd GR_ad_T = GR_Ind4T,3,GR_ad_Data
1918 fma.s1 FR_A3 = FR_A5,FR_x2,FR_A3
1923 fma.s1 FR_Xf8 = FR_Xf4,FR_Xf4,f0
1928 fma.s1 FR_rf2 = FR_rf,FR_rf,f0
1933 fma.s1 FR_P32f = FR_P3,FR_rf,FR_P2
1938 fma.s1 FR_P10f = FR_P1,FR_rf,f1
1942 ldfd FR_Tf = [GR_ad_T]
1943 fma.s1 FR_Ln = FR_P32,FR_r,FR_T
1948 fma.s1 FR_A0 = FR_A1,FR_x,FR_A0
1953 fma.s1 FR_S10 = FR_S14,FR_Xf4,FR_S10
1958 fma.s1 FR_S2 = FR_S6,FR_Xf4,FR_S2
1963 fcvt.xf FR_Nf = FR_int_Ln
1968 fma.s1 FR_A3 = FR_A7,FR_x4,FR_A3
1973 fcmp.eq.s1 p13,p0 = FR_NormX,FR_Ntrunc
1978 fnma.s1 FR_x3 = FR_x2,FR_x,f0 // -x^3
1983 fma.s1 FR_P32f = FR_P32f,FR_rf2,FR_P10f
1987 // set p9 if signgum is 32-bit int
1988 // set p10 if signgum is 64-bit int
1989 cmp.eq p10,p9 = 8,r34
1990 fma.s1 FR_S2 = FR_S10,FR_Xf8,FR_S2
1991 (p13) br.cond.spnt lgammaf_singularity
1993 .pred.rel "mutex",p9,p10
1995 (p9) st4 [r33] = GR_SignOfGamma // as 32-bit int
1996 (p10) st8 [r33] = GR_SignOfGamma // as 64-bit int
1997 fms.s1 FR_A0 = FR_A3,FR_x3,FR_A0 // -A3*x^3-A0
2001 fma.s1 FR_Tf = FR_Nf,FR_Ln2,FR_Tf
2006 fma.s1 FR_Ln = FR_S2,FR_Xf2,FR_Ln // S2*Xf^2+Ln
2011 fma.s1 FR_Lnf = FR_P32f,FR_rf,FR_Tf
2016 fms.s1 FR_Ln = FR_A0,f1,FR_Ln
2021 fms.s.s0 f8 = FR_Ln,f1,FR_Lnf
2024 // branch for handling +/-0, NaT, QNaN, +/-INF and denormalised numbers
2025 //---------------------------------------------------------------------
2029 getf.exp GR_SignExp = FR_NormX
2030 fclass.m p6,p0 = f8,0x21 // is arg +INF?
2031 mov GR_SignOfGamma = 1 // set signgam to 1
2034 getf.sig GR_Sig = FR_NormX
2035 fclass.m p7,p0 = f8,0xB // is x deno?
2036 // set p11 if signgum is 32-bit int
2037 // set p12 if signgum is 64-bit int
2038 cmp.eq p12,p11 = 8,r34
2040 .pred.rel "mutex",p11,p12
2042 // store sign of gamma(x) as 32-bit int
2043 (p11) st4 [r33] = GR_SignOfGamma
2044 fclass.m p8,p0 = f8,0x1C0 // is arg NaT or NaN?
2045 dep.z GR_Ind = GR_SignExp,3,4
2048 // store sign of gamma(x) as 64-bit int
2049 (p12) st8 [r33] = GR_SignOfGamma
2050 and GR_Exp = GR_ExpMask,GR_SignExp
2051 (p6) br.ret.spnt b0 // exit for +INF
2054 sub GR_PureExp = GR_Exp,GR_ExpBias
2055 fclass.m p9,p0 = f8,0x22 // is arg -INF?
2056 extr.u GR_Ind4T = GR_Sig,55,8
2060 (p7) fma.s0 FR_tmp = f1,f1,f8
2061 (p7) br.cond.sptk lgammaf_core
2065 (p8) fms.s.s0 f8 = f8,f1,f8
2066 (p8) br.ret.spnt b0 // exit for NaT and NaN
2070 (p9) fmerge.s f8 = f1,f8
2071 (p9) br.ret.spnt b0 // exit -INF
2073 // branch for handling negative integers and +/-0
2074 //---------------------------------------------------------------------
2076 lgammaf_singularity:
2078 mov GR_SignOfGamma = 1 // set signgam to 1
2079 fclass.m p6,p0 = f8,0x6 // is x -0?
2080 mov GR_TAG = 109 // negative
2083 mov GR_ad_SignGam = r33
2084 fma.s1 FR_X = f0,f0,f8
2089 frcpa.s0 f8,p0 = f1,f0
2090 // set p9 if signgum is 32-bit int
2091 // set p10 if signgum is 64-bit int
2092 cmp.eq p10,p9 = 8,r34
2096 (p6) sub GR_SignOfGamma = r0,GR_SignOfGamma
2097 br.cond.sptk lgammaf_libm_err
2099 // overflow (x > OVERFLOV_BOUNDARY)
2100 //---------------------------------------------------------------------
2110 fmerge.s FR_X = f8,f8
2111 mov GR_TAG = 108 // overflow
2114 mov GR_ad_SignGam = r33
2116 // set p9 if signgum is 32-bit int
2117 // set p10 if signgum is 64-bit int
2118 cmp.eq p10,p9 = 8,r34
2122 fma.s.s0 f8 = f9,f9,f0 // Set I,O and +INF result
2125 // gate to __libm_error_support#
2126 //---------------------------------------------------------------------
2130 alloc r32 = ar.pfs,1,4,4,0
2131 mov GR_Parameter_TAG = GR_TAG
2134 .pred.rel "mutex",p9,p10
2136 // store sign of gamma(x) as 32-bit int
2137 (p9) st4 [GR_ad_SignGam] = GR_SignOfGamma
2138 // store sign of gamma(x) as 64-bit int
2139 (p10) st8 [GR_ad_SignGam] = GR_SignOfGamma
2142 GLOBAL_LIBM_END(__libm_lgammaf)
2145 LOCAL_LIBM_ENTRY(__libm_error_region)
2148 add GR_Parameter_Y=-32,sp // Parameter 2 value
2150 .save ar.pfs,GR_SAVE_PFS
2151 mov GR_SAVE_PFS=ar.pfs // Save ar.pfs
2155 add sp=-64,sp // Create new stack
2157 mov GR_SAVE_GP=gp // Save gp
2160 stfs [GR_Parameter_Y] = FR_Y,16 // STORE Parameter 2 on stack
2161 add GR_Parameter_X = 16,sp // Parameter 1 address
2162 .save b0, GR_SAVE_B0
2163 mov GR_SAVE_B0=b0 // Save b0
2167 stfs [GR_Parameter_X] = FR_X // STORE Parameter 1
2169 add GR_Parameter_RESULT = 0,GR_Parameter_Y // Parameter 3 address
2173 stfs [GR_Parameter_Y] = FR_RESULT // STORE Parameter 3
2175 add GR_Parameter_Y = -16,GR_Parameter_Y
2176 br.call.sptk b0=__libm_error_support# // Call error handling
2182 add GR_Parameter_RESULT = 48,sp
2185 ldfs f8 = [GR_Parameter_RESULT] // Get return result off stack
2187 add sp = 64,sp // Restore stack pointer
2188 mov b0 = GR_SAVE_B0 // Restore return address
2191 mov gp = GR_SAVE_GP // Restore gp
2192 mov ar.pfs = GR_SAVE_PFS // Restore ar.pfs
2193 br.ret.sptk b0 // Return
2196 LOCAL_LIBM_END(__libm_error_region)
2197 .type __libm_error_support#,@function
2198 .global __libm_error_support#