4 // Copyright (c) 2000 - 2005, Intel Corporation
5 // All rights reserved.
7 // Contributed 2000 by the Intel Numerics Group, Intel Corporation
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are
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
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.
41 //==============================================================
42 // 02/02/00 Initial version
43 // 04/02/00 Unwind support added.
44 // 06/16/00 Updated tables to enforce symmetry
45 // 08/31/00 Saved 2 cycles in main path, and 9 in other paths.
46 // 09/20/00 The updated tables regressed to an old version, so reinstated them
47 // 10/18/00 Changed one table entry to ensure symmetry
48 // 01/03/01 Improved speed, fixed flag settings for small arguments.
49 // 02/18/02 Large arguments processing routine excluded
50 // 05/20/02 Cleaned up namespace and sf0 syntax
51 // 06/03/02 Insure inexact flag set for large arg result
52 // 09/05/02 Work range is widened by reduction strengthen (3 parts of Pi/16)
53 // 02/10/03 Reordered header: .section, .global, .proc, .align
54 // 08/08/03 Improved performance
55 // 10/28/04 Saved sincos_r_sincos to avoid clobber by dynamic loader
56 // 03/31/05 Reformatted delimiters between data tables
59 //==============================================================
60 // double sin( double x);
61 // double cos( double x);
63 // Overview of operation
64 //==============================================================
68 // Reduce x to region -1/2*pi/2^k ===== 0 ===== +1/2*pi/2^k where k=4
69 // divide x by pi/2^k.
70 // Multiply by 2^k/pi.
71 // nfloat = Round result to integer (round-to-nearest)
73 // r = x - nfloat * pi/2^k
74 // Do this as ((((x - nfloat * HIGH(pi/2^k))) -
75 // nfloat * LOW(pi/2^k)) -
76 // nfloat * LOWEST(pi/2^k) for increased accuracy.
77 // pi/2^k is stored as two numbers that when added make pi/2^k.
78 // pi/2^k = HIGH(pi/2^k) + LOW(pi/2^k)
79 // HIGH and LOW parts are rounded to zero values,
80 // and LOWEST is rounded to nearest one.
82 // x = (nfloat * pi/2^k) + r
83 // r is small enough that we can use a polynomial approximation
84 // and is referred to as the reduced argument.
88 // Take the unreduced part and remove the multiples of 2pi.
89 // So nfloat = nfloat (with lower k+1 bits cleared) + lower k+1 bits
91 // nfloat (with lower k+1 bits cleared) is a multiple of 2^(k+1)
93 // nfloat * pi/2^k = N * 2^(k+1) * pi/2^k + (lower k+1 bits) * pi/2^k
94 // nfloat * pi/2^k = N * 2 * pi + (lower k+1 bits) * pi/2^k
95 // nfloat * pi/2^k = N2pi + M * pi/2^k
98 // Sin(x) = Sin((nfloat * pi/2^k) + r)
99 // = Sin(nfloat * pi/2^k) * Cos(r) + Cos(nfloat * pi/2^k) * Sin(r)
101 // Sin(nfloat * pi/2^k) = Sin(N2pi + Mpi/2^k)
102 // = Sin(N2pi)Cos(Mpi/2^k) + Cos(N2pi)Sin(Mpi/2^k)
105 // Cos(nfloat * pi/2^k) = Cos(N2pi + Mpi/2^k)
106 // = Cos(N2pi)Cos(Mpi/2^k) + Sin(N2pi)Sin(Mpi/2^k)
109 // Sin(x) = Sin(Mpi/2^k) Cos(r) + Cos(Mpi/2^k) Sin(r)
115 // There are 2^(k+1) Sin entries in a table.
116 // There are 2^(k+1) Cos entries in a table.
118 // Get Sin(Mpi/2^k) and Cos(Mpi/2^k) by table lookup.
123 // Calculate Cos(r) and Sin(r) by polynomial approximation.
125 // Cos(r) = 1 + r^2 q1 + r^4 q2 + r^6 q3 + ... = Series for Cos
126 // Sin(r) = r + r^3 p1 + r^5 p2 + r^7 p3 + ... = Series for Sin
128 // and the coefficients q1, q2, ... and p1, p2, ... are stored in a table
132 // Sin(x) = Sin(Mpi/2^k) Cos(r) + Cos(Mpi/2^k) Sin(r)
136 // S[m] = Sin(Mpi/2^k) and C[m] = Cos(Mpi/2^k)
140 // P = p1 + r^2p2 + r^4p3 + r^6p4
141 // Q = q1 + r^2q2 + r^4q3 + r^6q4
144 // Sin(r) = r + rcub * P
145 // = r + r^3p1 + r^5p2 + r^7p3 + r^9p4 + ... = Sin(r)
147 // The coefficients are not exactly these values, but almost.
151 // p3 = -1/5040 = -1/7!
152 // p4 = 1/362889 = 1/9!
156 // Answer = S[m] Cos(r) + [Cm] P
158 // Cos(r) = 1 + rsq Q
159 // Cos(r) = 1 + r^2 Q
160 // Cos(r) = 1 + r^2 (q1 + r^2q2 + r^4q3 + r^6q4)
161 // Cos(r) = 1 + r^2q1 + r^4q2 + r^6q3 + r^8q4 + ...
163 // S[m] Cos(r) = S[m](1 + rsq Q)
164 // S[m] Cos(r) = S[m] + Sm rsq Q
165 // S[m] Cos(r) = S[m] + s_rsq Q
166 // Q = S[m] + s_rsq Q
170 // Answer = Q + C[m] P
174 //==============================================================
175 // general input registers:
179 // predicate registers used:
182 // floating-point registers used
187 //==============================================================
190 sincos_int_Nfloat = f11
196 sincos_save_tmp = f15
198 sincos_Inv_Pi_by_16 = f32
199 sincos_Pi_by_16_1 = f33
200 sincos_Pi_by_16_2 = f34
202 sincos_Inv_Pi_by_64 = f35
204 sincos_Pi_by_16_3 = f36
231 sincos_SIG_INV_PI_BY_16_2TO61 = f55
232 sincos_RSHF_2TO61 = f56
236 sincos_W_2TO61_RSH = f60
240 /////////////////////////////////////////////////////////////
242 sincos_GR_sig_inv_pi_by_16 = r14
243 sincos_GR_rshf_2to61 = r15
245 sincos_GR_exp_2tom61 = r17
249 sincos_GR_all_ones = r19
252 sincos_exp_limit = r22
253 sincos_r_signexp = r23
254 sincos_r_17_ones = r24
255 sincos_r_sincos = r25
261 GR_SAVE_r_sincos = r36
268 LOCAL_OBJECT_START(double_sincos_pi)
269 data8 0xC90FDAA22168C234, 0x00003FFC // pi/16 1st part
270 data8 0xC4C6628B80DC1CD1, 0x00003FBC // pi/16 2nd part
271 data8 0xA4093822299F31D0, 0x00003F7A // pi/16 3rd part
272 LOCAL_OBJECT_END(double_sincos_pi)
274 // Coefficients for polynomials
275 LOCAL_OBJECT_START(double_sincos_pq_k4)
276 data8 0x3EC71C963717C63A // P4
277 data8 0x3EF9FFBA8F191AE6 // Q4
278 data8 0xBF2A01A00F4E11A8 // P3
279 data8 0xBF56C16C05AC77BF // Q3
280 data8 0x3F8111111110F167 // P2
281 data8 0x3FA555555554DD45 // Q2
282 data8 0xBFC5555555555555 // P1
283 data8 0xBFDFFFFFFFFFFFFC // Q1
284 LOCAL_OBJECT_END(double_sincos_pq_k4)
286 // Sincos table (S[m], C[m])
287 LOCAL_OBJECT_START(double_sin_cos_beta_k4)
289 data8 0x0000000000000000 , 0x00000000 // sin( 0 pi/16) S0
290 data8 0x8000000000000000 , 0x00003fff // cos( 0 pi/16) C0
292 data8 0xc7c5c1e34d3055b3 , 0x00003ffc // sin( 1 pi/16) S1
293 data8 0xfb14be7fbae58157 , 0x00003ffe // cos( 1 pi/16) C1
295 data8 0xc3ef1535754b168e , 0x00003ffd // sin( 2 pi/16) S2
296 data8 0xec835e79946a3146 , 0x00003ffe // cos( 2 pi/16) C2
298 data8 0x8e39d9cd73464364 , 0x00003ffe // sin( 3 pi/16) S3
299 data8 0xd4db3148750d181a , 0x00003ffe // cos( 3 pi/16) C3
301 data8 0xb504f333f9de6484 , 0x00003ffe // sin( 4 pi/16) S4
302 data8 0xb504f333f9de6484 , 0x00003ffe // cos( 4 pi/16) C4
304 data8 0xd4db3148750d181a , 0x00003ffe // sin( 5 pi/16) C3
305 data8 0x8e39d9cd73464364 , 0x00003ffe // cos( 5 pi/16) S3
307 data8 0xec835e79946a3146 , 0x00003ffe // sin( 6 pi/16) C2
308 data8 0xc3ef1535754b168e , 0x00003ffd // cos( 6 pi/16) S2
310 data8 0xfb14be7fbae58157 , 0x00003ffe // sin( 7 pi/16) C1
311 data8 0xc7c5c1e34d3055b3 , 0x00003ffc // cos( 7 pi/16) S1
313 data8 0x8000000000000000 , 0x00003fff // sin( 8 pi/16) C0
314 data8 0x0000000000000000 , 0x00000000 // cos( 8 pi/16) S0
316 data8 0xfb14be7fbae58157 , 0x00003ffe // sin( 9 pi/16) C1
317 data8 0xc7c5c1e34d3055b3 , 0x0000bffc // cos( 9 pi/16) -S1
319 data8 0xec835e79946a3146 , 0x00003ffe // sin(10 pi/16) C2
320 data8 0xc3ef1535754b168e , 0x0000bffd // cos(10 pi/16) -S2
322 data8 0xd4db3148750d181a , 0x00003ffe // sin(11 pi/16) C3
323 data8 0x8e39d9cd73464364 , 0x0000bffe // cos(11 pi/16) -S3
325 data8 0xb504f333f9de6484 , 0x00003ffe // sin(12 pi/16) S4
326 data8 0xb504f333f9de6484 , 0x0000bffe // cos(12 pi/16) -S4
328 data8 0x8e39d9cd73464364 , 0x00003ffe // sin(13 pi/16) S3
329 data8 0xd4db3148750d181a , 0x0000bffe // cos(13 pi/16) -C3
331 data8 0xc3ef1535754b168e , 0x00003ffd // sin(14 pi/16) S2
332 data8 0xec835e79946a3146 , 0x0000bffe // cos(14 pi/16) -C2
334 data8 0xc7c5c1e34d3055b3 , 0x00003ffc // sin(15 pi/16) S1
335 data8 0xfb14be7fbae58157 , 0x0000bffe // cos(15 pi/16) -C1
337 data8 0x0000000000000000 , 0x00000000 // sin(16 pi/16) S0
338 data8 0x8000000000000000 , 0x0000bfff // cos(16 pi/16) -C0
340 data8 0xc7c5c1e34d3055b3 , 0x0000bffc // sin(17 pi/16) -S1
341 data8 0xfb14be7fbae58157 , 0x0000bffe // cos(17 pi/16) -C1
343 data8 0xc3ef1535754b168e , 0x0000bffd // sin(18 pi/16) -S2
344 data8 0xec835e79946a3146 , 0x0000bffe // cos(18 pi/16) -C2
346 data8 0x8e39d9cd73464364 , 0x0000bffe // sin(19 pi/16) -S3
347 data8 0xd4db3148750d181a , 0x0000bffe // cos(19 pi/16) -C3
349 data8 0xb504f333f9de6484 , 0x0000bffe // sin(20 pi/16) -S4
350 data8 0xb504f333f9de6484 , 0x0000bffe // cos(20 pi/16) -S4
352 data8 0xd4db3148750d181a , 0x0000bffe // sin(21 pi/16) -C3
353 data8 0x8e39d9cd73464364 , 0x0000bffe // cos(21 pi/16) -S3
355 data8 0xec835e79946a3146 , 0x0000bffe // sin(22 pi/16) -C2
356 data8 0xc3ef1535754b168e , 0x0000bffd // cos(22 pi/16) -S2
358 data8 0xfb14be7fbae58157 , 0x0000bffe // sin(23 pi/16) -C1
359 data8 0xc7c5c1e34d3055b3 , 0x0000bffc // cos(23 pi/16) -S1
361 data8 0x8000000000000000 , 0x0000bfff // sin(24 pi/16) -C0
362 data8 0x0000000000000000 , 0x00000000 // cos(24 pi/16) S0
364 data8 0xfb14be7fbae58157 , 0x0000bffe // sin(25 pi/16) -C1
365 data8 0xc7c5c1e34d3055b3 , 0x00003ffc // cos(25 pi/16) S1
367 data8 0xec835e79946a3146 , 0x0000bffe // sin(26 pi/16) -C2
368 data8 0xc3ef1535754b168e , 0x00003ffd // cos(26 pi/16) S2
370 data8 0xd4db3148750d181a , 0x0000bffe // sin(27 pi/16) -C3
371 data8 0x8e39d9cd73464364 , 0x00003ffe // cos(27 pi/16) S3
373 data8 0xb504f333f9de6484 , 0x0000bffe // sin(28 pi/16) -S4
374 data8 0xb504f333f9de6484 , 0x00003ffe // cos(28 pi/16) S4
376 data8 0x8e39d9cd73464364 , 0x0000bffe // sin(29 pi/16) -S3
377 data8 0xd4db3148750d181a , 0x00003ffe // cos(29 pi/16) C3
379 data8 0xc3ef1535754b168e , 0x0000bffd // sin(30 pi/16) -S2
380 data8 0xec835e79946a3146 , 0x00003ffe // cos(30 pi/16) C2
382 data8 0xc7c5c1e34d3055b3 , 0x0000bffc // sin(31 pi/16) -S1
383 data8 0xfb14be7fbae58157 , 0x00003ffe // cos(31 pi/16) C1
385 data8 0x0000000000000000 , 0x00000000 // sin(32 pi/16) S0
386 data8 0x8000000000000000 , 0x00003fff // cos(32 pi/16) C0
387 LOCAL_OBJECT_END(double_sin_cos_beta_k4)
391 ////////////////////////////////////////////////////////
392 // There are two entry points: sin and cos
395 // If from sin, p8 is true
396 // If from cos, p9 is true
398 GLOBAL_IEEE754_ENTRY(sin)
401 getf.exp sincos_r_signexp = f8
402 movl sincos_GR_sig_inv_pi_by_16 = 0xA2F9836E4E44152A // signd of 16/pi
405 addl sincos_AD_1 = @ltoff(double_sincos_pi), gp
406 movl sincos_GR_rshf_2to61 = 0x47b8000000000000 // 1.1 2^(63+63-2)
411 ld8 sincos_AD_1 = [sincos_AD_1]
412 fnorm.s0 sincos_NORM_f8 = f8 // Normalize argument
413 cmp.eq p8,p9 = r0, r0 // set p8 (clear p9) for sin
416 mov sincos_GR_exp_2tom61 = 0xffff-61 // exponent of scale 2^-61
417 mov sincos_r_sincos = 0x0 // sincos_r_sincos = 0 for sin
418 br.cond.sptk _SINCOS_COMMON // go to common part
422 GLOBAL_IEEE754_END(sin)
423 libm_alias_double_other (__sin, sin)
425 GLOBAL_IEEE754_ENTRY(cos)
428 getf.exp sincos_r_signexp = f8
429 movl sincos_GR_sig_inv_pi_by_16 = 0xA2F9836E4E44152A // signd of 16/pi
432 addl sincos_AD_1 = @ltoff(double_sincos_pi), gp
433 movl sincos_GR_rshf_2to61 = 0x47b8000000000000 // 1.1 2^(63+63-2)
438 ld8 sincos_AD_1 = [sincos_AD_1]
439 fnorm.s1 sincos_NORM_f8 = f8 // Normalize argument
440 cmp.eq p9,p8 = r0, r0 // set p9 (clear p8) for cos
443 mov sincos_GR_exp_2tom61 = 0xffff-61 // exp of scale 2^-61
444 mov sincos_r_sincos = 0x8 // sincos_r_sincos = 8 for cos
449 ////////////////////////////////////////////////////////
450 // All entry points end up here.
451 // If from sin, sincos_r_sincos is 0 and p8 is true
452 // If from cos, sincos_r_sincos is 8 = 2^(k-1) and p9 is true
453 // We add sincos_r_sincos to N
455 ///////////// Common sin and cos part //////////////////
459 // Form two constants we need
460 // 16/pi * 2^-2 * 2^63, scaled by 2^61 since we just loaded the significand
461 // 1.1000...000 * 2^(63+63-2) to right shift int(W) into the low significand
463 setf.sig sincos_SIG_INV_PI_BY_16_2TO61 = sincos_GR_sig_inv_pi_by_16
464 fclass.m p6,p0 = f8, 0xe7 // if x = 0,inf,nan
465 mov sincos_exp_limit = 0x1001a
468 setf.d sincos_RSHF_2TO61 = sincos_GR_rshf_2to61
469 movl sincos_GR_rshf = 0x43e8000000000000 // 1.1 2^63
473 // Form another constant
474 // 2^-61 for scaling Nfloat
475 // 0x1001a is register_bias + 27.
476 // So if f8 >= 2^27, go to large argument routines
478 alloc r32 = ar.pfs, 1, 4, 0, 0
479 fclass.m p11,p0 = f8, 0x0b // Test for x=unorm
480 mov sincos_GR_all_ones = -1 // For "inexect" constant create
483 setf.exp sincos_2TOM61 = sincos_GR_exp_2tom61
485 (p6) br.cond.spnt _SINCOS_SPECIAL_ARGS
489 // Load the two pieces of pi/16
490 // Form another constant
491 // 1.1000...000 * 2^63, the right shift constant
493 ldfe sincos_Pi_by_16_1 = [sincos_AD_1],16
494 setf.d sincos_RSHF = sincos_GR_rshf
495 (p11) br.cond.spnt _SINCOS_UNORM // Branch if x=unorm
500 // Return here if x=unorm
501 // Create constant used to set inexact
503 ldfe sincos_Pi_by_16_2 = [sincos_AD_1],16
504 setf.sig fp_tmp = sincos_GR_all_ones
508 // Select exponent (17 lsb)
510 ldfe sincos_Pi_by_16_3 = [sincos_AD_1],16
512 dep.z sincos_r_exp = sincos_r_signexp, 0, 17
515 // Polynomial coefficients (Q4, P4, Q3, P3, Q2, Q1, P2, P1) loading
516 // p10 is true if we must call routines to handle larger arguments
517 // p10 is true if f8 exp is >= 0x1001a (2^27)
519 ldfpd sincos_P4,sincos_Q4 = [sincos_AD_1],16
520 cmp.ge p10,p0 = sincos_r_exp,sincos_exp_limit
521 (p10) br.cond.spnt _SINCOS_LARGE_ARGS // Go to "large args" routine
524 // sincos_W = x * sincos_Inv_Pi_by_16
525 // Multiply x by scaled 16/pi and add large const to shift integer part of W to
526 // rightmost bits of significand
528 ldfpd sincos_P3,sincos_Q3 = [sincos_AD_1],16
529 fma.s1 sincos_W_2TO61_RSH = sincos_NORM_f8,sincos_SIG_INV_PI_BY_16_2TO61,sincos_RSHF_2TO61
533 // get N = (int)sincos_int_Nfloat
534 // sincos_NFLOAT = Round_Int_Nearest(sincos_W)
535 // This is done by scaling back by 2^-61 and subtracting the shift constant
537 getf.sig sincos_GR_n = sincos_W_2TO61_RSH
538 ldfpd sincos_P2,sincos_Q2 = [sincos_AD_1],16
539 fms.s1 sincos_NFLOAT = sincos_W_2TO61_RSH,sincos_2TOM61,sincos_RSHF
542 // sincos_r = -sincos_Nfloat * sincos_Pi_by_16_1 + x
544 ldfpd sincos_P1,sincos_Q1 = [sincos_AD_1],16
545 fnma.s1 sincos_r = sincos_NFLOAT, sincos_Pi_by_16_1, sincos_NORM_f8
549 // Add 2^(k-1) (which is in sincos_r_sincos) to N
551 add sincos_GR_n = sincos_GR_n, sincos_r_sincos
553 // Get M (least k+1 bits of N)
554 and sincos_GR_m = 0x1f,sincos_GR_n
558 // sincos_r = sincos_r -sincos_Nfloat * sincos_Pi_by_16_2
561 fnma.s1 sincos_r = sincos_NFLOAT, sincos_Pi_by_16_2, sincos_r
562 shl sincos_GR_32m = sincos_GR_m,5
565 // Add 32*M to address of sin_cos_beta table
566 // For sin denorm. - set uflow
568 add sincos_AD_2 = sincos_GR_32m, sincos_AD_1
569 (p8) fclass.m.unc p10,p0 = f8,0x0b
573 // Load Sin and Cos table value using obtained index m (sincosf_AD_2)
575 ldfe sincos_Sm = [sincos_AD_2],16
582 ldfe sincos_Cm = [sincos_AD_2]
583 fma.s1 sincos_rsq = sincos_r, sincos_r, f0 // r^2 = r*r
588 fmpy.s0 fp_tmp = fp_tmp,fp_tmp // forces inexact flag
592 // sincos_r_exact = sincos_r -sincos_Nfloat * sincos_Pi_by_16_3
595 fnma.s1 sincos_r_exact = sincos_NFLOAT, sincos_Pi_by_16_3, sincos_r
599 // Polynomials calculation
604 fma.s1 sincos_P_temp1 = sincos_rsq, sincos_P4, sincos_P3
609 fma.s1 sincos_Q_temp1 = sincos_rsq, sincos_Q4, sincos_Q3
613 // get rcube = r^3 and S[m]*r^2
616 fmpy.s1 sincos_srsq = sincos_Sm,sincos_rsq
621 fmpy.s1 sincos_rcub = sincos_r_exact, sincos_rsq
625 // Polynomials calculation
626 // Q_2 = Q_1*r^2 + Q2
627 // P_1 = P_1*r^2 + P2
630 fma.s1 sincos_Q_temp2 = sincos_rsq, sincos_Q_temp1, sincos_Q2
635 fma.s1 sincos_P_temp2 = sincos_rsq, sincos_P_temp1, sincos_P2
639 // Polynomials calculation
644 fma.s1 sincos_Q = sincos_rsq, sincos_Q_temp2, sincos_Q1
649 fma.s1 sincos_P = sincos_rsq, sincos_P_temp2, sincos_P1
654 // Q = Q*S[m]*r^2 + S[m]
658 fma.s1 sincos_Q = sincos_srsq,sincos_Q, sincos_Sm
663 fma.s1 sincos_P = sincos_rcub,sincos_P, sincos_r_exact
667 // If sin(denormal), force underflow to be set
670 (p10) fmpy.d.s0 fp_tmp = sincos_NORM_f8,sincos_NORM_f8
675 // result = C[m]*P + Q
678 fma.d.s0 f8 = sincos_Cm, sincos_P, sincos_Q
679 br.ret.sptk b0 // Exit for common path
682 ////////// x = 0/Inf/NaN path //////////////////
683 _SINCOS_SPECIAL_ARGS:
684 .pred.rel "mutex",p8,p9
690 (p8) fma.d.s0 f8 = f8, f0, f0 // sin(+/-0,NaN,Inf)
698 (p9) fma.d.s0 f8 = f8, f0, f1 // cos(+/-0,NaN,Inf)
699 br.ret.sptk b0 // Exit for x = 0/Inf/NaN path
705 getf.exp sincos_r_signexp = sincos_NORM_f8 // Get signexp of x
706 fcmp.eq.s0 p11,p0 = f8, f0 // Dummy op to set denorm flag
707 br.cond.sptk _SINCOS_COMMON2 // Return to main path
710 GLOBAL_IEEE754_END(cos)
711 libm_alias_double_other (__cos, cos)
713 //////////// x >= 2^27 - large arguments routine call ////////////
714 LOCAL_LIBM_ENTRY(__libm_callout_sincos)
718 mov GR_SAVE_r_sincos = sincos_r_sincos // Save sin or cos
720 .save ar.pfs,GR_SAVE_PFS
721 mov GR_SAVE_PFS = ar.pfs
734 setf.sig sincos_save_tmp = sincos_GR_all_ones// inexact set
736 (p8) br.call.sptk.many b0 = __libm_sin_large# // sin(large_X)
741 cmp.ne p9,p0 = GR_SAVE_r_sincos, r0 // set p9 if cos
743 (p9) br.call.sptk.many b0 = __libm_cos_large# // cos(large_X)
748 fma.d.s0 f8 = f8, f1, f0 // Round result to double
754 fmpy.s0 sincos_save_tmp = sincos_save_tmp, sincos_save_tmp
760 mov ar.pfs = GR_SAVE_PFS
761 br.ret.sptk b0 // Exit for large arguments routine call
764 LOCAL_LIBM_END(__libm_callout_sincos)
766 .type __libm_sin_large#,@function
767 .global __libm_sin_large#
768 .type __libm_cos_large#,@function
769 .global __libm_cos_large#