4 // Copyright (c) 2000 - 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.
40 //==============================================================
41 // 02/02/00 Initial version
42 // 04/02/00 Unwind support added.
43 // 06/16/00 Updated tables to enforce symmetry
44 // 08/31/00 Saved 2 cycles in main path, and 9 in other paths.
45 // 09/20/00 The updated tables regressed to an old version, so reinstated them
46 // 10/18/00 Changed one table entry to ensure symmetry
47 // 01/03/01 Improved speed, fixed flag settings for small arguments.
48 // 02/18/02 Large arguments processing routine excluded
49 // 05/20/02 Cleaned up namespace and sf0 syntax
50 // 06/03/02 Insure inexact flag set for large arg result
51 // 09/05/02 Work range is widened by reduction strengthen (3 parts of Pi/16)
52 // 02/10/03 Reordered header: .section, .global, .proc, .align
53 // 08/08/03 Improved performance
54 // 10/28/04 Saved sincos_r_sincos to avoid clobber by dynamic loader
55 // 03/31/05 Reformatted delimiters between data tables
58 //==============================================================
59 // double sin( double x);
60 // double cos( double x);
62 // Overview of operation
63 //==============================================================
67 // Reduce x to region -1/2*pi/2^k ===== 0 ===== +1/2*pi/2^k where k=4
68 // divide x by pi/2^k.
69 // Multiply by 2^k/pi.
70 // nfloat = Round result to integer (round-to-nearest)
72 // r = x - nfloat * pi/2^k
73 // Do this as ((((x - nfloat * HIGH(pi/2^k))) -
74 // nfloat * LOW(pi/2^k)) -
75 // nfloat * LOWEST(pi/2^k) for increased accuracy.
76 // pi/2^k is stored as two numbers that when added make pi/2^k.
77 // pi/2^k = HIGH(pi/2^k) + LOW(pi/2^k)
78 // HIGH and LOW parts are rounded to zero values,
79 // and LOWEST is rounded to nearest one.
81 // x = (nfloat * pi/2^k) + r
82 // r is small enough that we can use a polynomial approximation
83 // and is referred to as the reduced argument.
87 // Take the unreduced part and remove the multiples of 2pi.
88 // So nfloat = nfloat (with lower k+1 bits cleared) + lower k+1 bits
90 // nfloat (with lower k+1 bits cleared) is a multiple of 2^(k+1)
92 // nfloat * pi/2^k = N * 2^(k+1) * pi/2^k + (lower k+1 bits) * pi/2^k
93 // nfloat * pi/2^k = N * 2 * pi + (lower k+1 bits) * pi/2^k
94 // nfloat * pi/2^k = N2pi + M * pi/2^k
97 // Sin(x) = Sin((nfloat * pi/2^k) + r)
98 // = Sin(nfloat * pi/2^k) * Cos(r) + Cos(nfloat * pi/2^k) * Sin(r)
100 // Sin(nfloat * pi/2^k) = Sin(N2pi + Mpi/2^k)
101 // = Sin(N2pi)Cos(Mpi/2^k) + Cos(N2pi)Sin(Mpi/2^k)
104 // Cos(nfloat * pi/2^k) = Cos(N2pi + Mpi/2^k)
105 // = Cos(N2pi)Cos(Mpi/2^k) + Sin(N2pi)Sin(Mpi/2^k)
108 // Sin(x) = Sin(Mpi/2^k) Cos(r) + Cos(Mpi/2^k) Sin(r)
114 // There are 2^(k+1) Sin entries in a table.
115 // There are 2^(k+1) Cos entries in a table.
117 // Get Sin(Mpi/2^k) and Cos(Mpi/2^k) by table lookup.
122 // Calculate Cos(r) and Sin(r) by polynomial approximation.
124 // Cos(r) = 1 + r^2 q1 + r^4 q2 + r^6 q3 + ... = Series for Cos
125 // Sin(r) = r + r^3 p1 + r^5 p2 + r^7 p3 + ... = Series for Sin
127 // and the coefficients q1, q2, ... and p1, p2, ... are stored in a table
131 // Sin(x) = Sin(Mpi/2^k) Cos(r) + Cos(Mpi/2^k) Sin(r)
135 // S[m] = Sin(Mpi/2^k) and C[m] = Cos(Mpi/2^k)
139 // P = p1 + r^2p2 + r^4p3 + r^6p4
140 // Q = q1 + r^2q2 + r^4q3 + r^6q4
143 // Sin(r) = r + rcub * P
144 // = r + r^3p1 + r^5p2 + r^7p3 + r^9p4 + ... = Sin(r)
146 // The coefficients are not exactly these values, but almost.
150 // p3 = -1/5040 = -1/7!
151 // p4 = 1/362889 = 1/9!
155 // Answer = S[m] Cos(r) + [Cm] P
157 // Cos(r) = 1 + rsq Q
158 // Cos(r) = 1 + r^2 Q
159 // Cos(r) = 1 + r^2 (q1 + r^2q2 + r^4q3 + r^6q4)
160 // Cos(r) = 1 + r^2q1 + r^4q2 + r^6q3 + r^8q4 + ...
162 // S[m] Cos(r) = S[m](1 + rsq Q)
163 // S[m] Cos(r) = S[m] + Sm rsq Q
164 // S[m] Cos(r) = S[m] + s_rsq Q
165 // Q = S[m] + s_rsq Q
169 // Answer = Q + C[m] P
173 //==============================================================
174 // general input registers:
178 // predicate registers used:
181 // floating-point registers used
186 //==============================================================
189 sincos_int_Nfloat = f11
195 sincos_save_tmp = f15
197 sincos_Inv_Pi_by_16 = f32
198 sincos_Pi_by_16_1 = f33
199 sincos_Pi_by_16_2 = f34
201 sincos_Inv_Pi_by_64 = f35
203 sincos_Pi_by_16_3 = f36
230 sincos_SIG_INV_PI_BY_16_2TO61 = f55
231 sincos_RSHF_2TO61 = f56
235 sincos_W_2TO61_RSH = f60
239 /////////////////////////////////////////////////////////////
241 sincos_GR_sig_inv_pi_by_16 = r14
242 sincos_GR_rshf_2to61 = r15
244 sincos_GR_exp_2tom61 = r17
248 sincos_GR_all_ones = r19
251 sincos_exp_limit = r22
252 sincos_r_signexp = r23
253 sincos_r_17_ones = r24
254 sincos_r_sincos = r25
260 GR_SAVE_r_sincos = r36
267 LOCAL_OBJECT_START(double_sincos_pi)
268 data8 0xC90FDAA22168C234, 0x00003FFC // pi/16 1st part
269 data8 0xC4C6628B80DC1CD1, 0x00003FBC // pi/16 2nd part
270 data8 0xA4093822299F31D0, 0x00003F7A // pi/16 3rd part
271 LOCAL_OBJECT_END(double_sincos_pi)
273 // Coefficients for polynomials
274 LOCAL_OBJECT_START(double_sincos_pq_k4)
275 data8 0x3EC71C963717C63A // P4
276 data8 0x3EF9FFBA8F191AE6 // Q4
277 data8 0xBF2A01A00F4E11A8 // P3
278 data8 0xBF56C16C05AC77BF // Q3
279 data8 0x3F8111111110F167 // P2
280 data8 0x3FA555555554DD45 // Q2
281 data8 0xBFC5555555555555 // P1
282 data8 0xBFDFFFFFFFFFFFFC // Q1
283 LOCAL_OBJECT_END(double_sincos_pq_k4)
285 // Sincos table (S[m], C[m])
286 LOCAL_OBJECT_START(double_sin_cos_beta_k4)
288 data8 0x0000000000000000 , 0x00000000 // sin( 0 pi/16) S0
289 data8 0x8000000000000000 , 0x00003fff // cos( 0 pi/16) C0
291 data8 0xc7c5c1e34d3055b3 , 0x00003ffc // sin( 1 pi/16) S1
292 data8 0xfb14be7fbae58157 , 0x00003ffe // cos( 1 pi/16) C1
294 data8 0xc3ef1535754b168e , 0x00003ffd // sin( 2 pi/16) S2
295 data8 0xec835e79946a3146 , 0x00003ffe // cos( 2 pi/16) C2
297 data8 0x8e39d9cd73464364 , 0x00003ffe // sin( 3 pi/16) S3
298 data8 0xd4db3148750d181a , 0x00003ffe // cos( 3 pi/16) C3
300 data8 0xb504f333f9de6484 , 0x00003ffe // sin( 4 pi/16) S4
301 data8 0xb504f333f9de6484 , 0x00003ffe // cos( 4 pi/16) C4
303 data8 0xd4db3148750d181a , 0x00003ffe // sin( 5 pi/16) C3
304 data8 0x8e39d9cd73464364 , 0x00003ffe // cos( 5 pi/16) S3
306 data8 0xec835e79946a3146 , 0x00003ffe // sin( 6 pi/16) C2
307 data8 0xc3ef1535754b168e , 0x00003ffd // cos( 6 pi/16) S2
309 data8 0xfb14be7fbae58157 , 0x00003ffe // sin( 7 pi/16) C1
310 data8 0xc7c5c1e34d3055b3 , 0x00003ffc // cos( 7 pi/16) S1
312 data8 0x8000000000000000 , 0x00003fff // sin( 8 pi/16) C0
313 data8 0x0000000000000000 , 0x00000000 // cos( 8 pi/16) S0
315 data8 0xfb14be7fbae58157 , 0x00003ffe // sin( 9 pi/16) C1
316 data8 0xc7c5c1e34d3055b3 , 0x0000bffc // cos( 9 pi/16) -S1
318 data8 0xec835e79946a3146 , 0x00003ffe // sin(10 pi/16) C2
319 data8 0xc3ef1535754b168e , 0x0000bffd // cos(10 pi/16) -S2
321 data8 0xd4db3148750d181a , 0x00003ffe // sin(11 pi/16) C3
322 data8 0x8e39d9cd73464364 , 0x0000bffe // cos(11 pi/16) -S3
324 data8 0xb504f333f9de6484 , 0x00003ffe // sin(12 pi/16) S4
325 data8 0xb504f333f9de6484 , 0x0000bffe // cos(12 pi/16) -S4
327 data8 0x8e39d9cd73464364 , 0x00003ffe // sin(13 pi/16) S3
328 data8 0xd4db3148750d181a , 0x0000bffe // cos(13 pi/16) -C3
330 data8 0xc3ef1535754b168e , 0x00003ffd // sin(14 pi/16) S2
331 data8 0xec835e79946a3146 , 0x0000bffe // cos(14 pi/16) -C2
333 data8 0xc7c5c1e34d3055b3 , 0x00003ffc // sin(15 pi/16) S1
334 data8 0xfb14be7fbae58157 , 0x0000bffe // cos(15 pi/16) -C1
336 data8 0x0000000000000000 , 0x00000000 // sin(16 pi/16) S0
337 data8 0x8000000000000000 , 0x0000bfff // cos(16 pi/16) -C0
339 data8 0xc7c5c1e34d3055b3 , 0x0000bffc // sin(17 pi/16) -S1
340 data8 0xfb14be7fbae58157 , 0x0000bffe // cos(17 pi/16) -C1
342 data8 0xc3ef1535754b168e , 0x0000bffd // sin(18 pi/16) -S2
343 data8 0xec835e79946a3146 , 0x0000bffe // cos(18 pi/16) -C2
345 data8 0x8e39d9cd73464364 , 0x0000bffe // sin(19 pi/16) -S3
346 data8 0xd4db3148750d181a , 0x0000bffe // cos(19 pi/16) -C3
348 data8 0xb504f333f9de6484 , 0x0000bffe // sin(20 pi/16) -S4
349 data8 0xb504f333f9de6484 , 0x0000bffe // cos(20 pi/16) -S4
351 data8 0xd4db3148750d181a , 0x0000bffe // sin(21 pi/16) -C3
352 data8 0x8e39d9cd73464364 , 0x0000bffe // cos(21 pi/16) -S3
354 data8 0xec835e79946a3146 , 0x0000bffe // sin(22 pi/16) -C2
355 data8 0xc3ef1535754b168e , 0x0000bffd // cos(22 pi/16) -S2
357 data8 0xfb14be7fbae58157 , 0x0000bffe // sin(23 pi/16) -C1
358 data8 0xc7c5c1e34d3055b3 , 0x0000bffc // cos(23 pi/16) -S1
360 data8 0x8000000000000000 , 0x0000bfff // sin(24 pi/16) -C0
361 data8 0x0000000000000000 , 0x00000000 // cos(24 pi/16) S0
363 data8 0xfb14be7fbae58157 , 0x0000bffe // sin(25 pi/16) -C1
364 data8 0xc7c5c1e34d3055b3 , 0x00003ffc // cos(25 pi/16) S1
366 data8 0xec835e79946a3146 , 0x0000bffe // sin(26 pi/16) -C2
367 data8 0xc3ef1535754b168e , 0x00003ffd // cos(26 pi/16) S2
369 data8 0xd4db3148750d181a , 0x0000bffe // sin(27 pi/16) -C3
370 data8 0x8e39d9cd73464364 , 0x00003ffe // cos(27 pi/16) S3
372 data8 0xb504f333f9de6484 , 0x0000bffe // sin(28 pi/16) -S4
373 data8 0xb504f333f9de6484 , 0x00003ffe // cos(28 pi/16) S4
375 data8 0x8e39d9cd73464364 , 0x0000bffe // sin(29 pi/16) -S3
376 data8 0xd4db3148750d181a , 0x00003ffe // cos(29 pi/16) C3
378 data8 0xc3ef1535754b168e , 0x0000bffd // sin(30 pi/16) -S2
379 data8 0xec835e79946a3146 , 0x00003ffe // cos(30 pi/16) C2
381 data8 0xc7c5c1e34d3055b3 , 0x0000bffc // sin(31 pi/16) -S1
382 data8 0xfb14be7fbae58157 , 0x00003ffe // cos(31 pi/16) C1
384 data8 0x0000000000000000 , 0x00000000 // sin(32 pi/16) S0
385 data8 0x8000000000000000 , 0x00003fff // cos(32 pi/16) C0
386 LOCAL_OBJECT_END(double_sin_cos_beta_k4)
390 ////////////////////////////////////////////////////////
391 // There are two entry points: sin and cos
394 // If from sin, p8 is true
395 // If from cos, p9 is true
397 GLOBAL_IEEE754_ENTRY(sin)
400 getf.exp sincos_r_signexp = f8
401 movl sincos_GR_sig_inv_pi_by_16 = 0xA2F9836E4E44152A // signd of 16/pi
404 addl sincos_AD_1 = @ltoff(double_sincos_pi), gp
405 movl sincos_GR_rshf_2to61 = 0x47b8000000000000 // 1.1 2^(63+63-2)
410 ld8 sincos_AD_1 = [sincos_AD_1]
411 fnorm.s0 sincos_NORM_f8 = f8 // Normalize argument
412 cmp.eq p8,p9 = r0, r0 // set p8 (clear p9) for sin
415 mov sincos_GR_exp_2tom61 = 0xffff-61 // exponent of scale 2^-61
416 mov sincos_r_sincos = 0x0 // sincos_r_sincos = 0 for sin
417 br.cond.sptk _SINCOS_COMMON // go to common part
421 GLOBAL_IEEE754_END(sin)
422 libm_alias_double_other (__sin, sin)
424 GLOBAL_IEEE754_ENTRY(cos)
427 getf.exp sincos_r_signexp = f8
428 movl sincos_GR_sig_inv_pi_by_16 = 0xA2F9836E4E44152A // signd of 16/pi
431 addl sincos_AD_1 = @ltoff(double_sincos_pi), gp
432 movl sincos_GR_rshf_2to61 = 0x47b8000000000000 // 1.1 2^(63+63-2)
437 ld8 sincos_AD_1 = [sincos_AD_1]
438 fnorm.s1 sincos_NORM_f8 = f8 // Normalize argument
439 cmp.eq p9,p8 = r0, r0 // set p9 (clear p8) for cos
442 mov sincos_GR_exp_2tom61 = 0xffff-61 // exp of scale 2^-61
443 mov sincos_r_sincos = 0x8 // sincos_r_sincos = 8 for cos
448 ////////////////////////////////////////////////////////
449 // All entry points end up here.
450 // If from sin, sincos_r_sincos is 0 and p8 is true
451 // If from cos, sincos_r_sincos is 8 = 2^(k-1) and p9 is true
452 // We add sincos_r_sincos to N
454 ///////////// Common sin and cos part //////////////////
458 // Form two constants we need
459 // 16/pi * 2^-2 * 2^63, scaled by 2^61 since we just loaded the significand
460 // 1.1000...000 * 2^(63+63-2) to right shift int(W) into the low significand
462 setf.sig sincos_SIG_INV_PI_BY_16_2TO61 = sincos_GR_sig_inv_pi_by_16
463 fclass.m p6,p0 = f8, 0xe7 // if x = 0,inf,nan
464 mov sincos_exp_limit = 0x1001a
467 setf.d sincos_RSHF_2TO61 = sincos_GR_rshf_2to61
468 movl sincos_GR_rshf = 0x43e8000000000000 // 1.1 2^63
472 // Form another constant
473 // 2^-61 for scaling Nfloat
474 // 0x1001a is register_bias + 27.
475 // So if f8 >= 2^27, go to large argument routines
477 alloc r32 = ar.pfs, 1, 4, 0, 0
478 fclass.m p11,p0 = f8, 0x0b // Test for x=unorm
479 mov sincos_GR_all_ones = -1 // For "inexect" constant create
482 setf.exp sincos_2TOM61 = sincos_GR_exp_2tom61
484 (p6) br.cond.spnt _SINCOS_SPECIAL_ARGS
488 // Load the two pieces of pi/16
489 // Form another constant
490 // 1.1000...000 * 2^63, the right shift constant
492 ldfe sincos_Pi_by_16_1 = [sincos_AD_1],16
493 setf.d sincos_RSHF = sincos_GR_rshf
494 (p11) br.cond.spnt _SINCOS_UNORM // Branch if x=unorm
499 // Return here if x=unorm
500 // Create constant used to set inexact
502 ldfe sincos_Pi_by_16_2 = [sincos_AD_1],16
503 setf.sig fp_tmp = sincos_GR_all_ones
507 // Select exponent (17 lsb)
509 ldfe sincos_Pi_by_16_3 = [sincos_AD_1],16
511 dep.z sincos_r_exp = sincos_r_signexp, 0, 17
514 // Polynomial coefficients (Q4, P4, Q3, P3, Q2, Q1, P2, P1) loading
515 // p10 is true if we must call routines to handle larger arguments
516 // p10 is true if f8 exp is >= 0x1001a (2^27)
518 ldfpd sincos_P4,sincos_Q4 = [sincos_AD_1],16
519 cmp.ge p10,p0 = sincos_r_exp,sincos_exp_limit
520 (p10) br.cond.spnt _SINCOS_LARGE_ARGS // Go to "large args" routine
523 // sincos_W = x * sincos_Inv_Pi_by_16
524 // Multiply x by scaled 16/pi and add large const to shift integer part of W to
525 // rightmost bits of significand
527 ldfpd sincos_P3,sincos_Q3 = [sincos_AD_1],16
528 fma.s1 sincos_W_2TO61_RSH = sincos_NORM_f8,sincos_SIG_INV_PI_BY_16_2TO61,sincos_RSHF_2TO61
532 // get N = (int)sincos_int_Nfloat
533 // sincos_NFLOAT = Round_Int_Nearest(sincos_W)
534 // This is done by scaling back by 2^-61 and subtracting the shift constant
536 getf.sig sincos_GR_n = sincos_W_2TO61_RSH
537 ldfpd sincos_P2,sincos_Q2 = [sincos_AD_1],16
538 fms.s1 sincos_NFLOAT = sincos_W_2TO61_RSH,sincos_2TOM61,sincos_RSHF
541 // sincos_r = -sincos_Nfloat * sincos_Pi_by_16_1 + x
543 ldfpd sincos_P1,sincos_Q1 = [sincos_AD_1],16
544 fnma.s1 sincos_r = sincos_NFLOAT, sincos_Pi_by_16_1, sincos_NORM_f8
548 // Add 2^(k-1) (which is in sincos_r_sincos) to N
550 add sincos_GR_n = sincos_GR_n, sincos_r_sincos
552 // Get M (least k+1 bits of N)
553 and sincos_GR_m = 0x1f,sincos_GR_n
557 // sincos_r = sincos_r -sincos_Nfloat * sincos_Pi_by_16_2
560 fnma.s1 sincos_r = sincos_NFLOAT, sincos_Pi_by_16_2, sincos_r
561 shl sincos_GR_32m = sincos_GR_m,5
564 // Add 32*M to address of sin_cos_beta table
565 // For sin denorm. - set uflow
567 add sincos_AD_2 = sincos_GR_32m, sincos_AD_1
568 (p8) fclass.m.unc p10,p0 = f8,0x0b
572 // Load Sin and Cos table value using obtained index m (sincosf_AD_2)
574 ldfe sincos_Sm = [sincos_AD_2],16
581 ldfe sincos_Cm = [sincos_AD_2]
582 fma.s1 sincos_rsq = sincos_r, sincos_r, f0 // r^2 = r*r
587 fmpy.s0 fp_tmp = fp_tmp,fp_tmp // forces inexact flag
591 // sincos_r_exact = sincos_r -sincos_Nfloat * sincos_Pi_by_16_3
594 fnma.s1 sincos_r_exact = sincos_NFLOAT, sincos_Pi_by_16_3, sincos_r
598 // Polynomials calculation
603 fma.s1 sincos_P_temp1 = sincos_rsq, sincos_P4, sincos_P3
608 fma.s1 sincos_Q_temp1 = sincos_rsq, sincos_Q4, sincos_Q3
612 // get rcube = r^3 and S[m]*r^2
615 fmpy.s1 sincos_srsq = sincos_Sm,sincos_rsq
620 fmpy.s1 sincos_rcub = sincos_r_exact, sincos_rsq
624 // Polynomials calculation
625 // Q_2 = Q_1*r^2 + Q2
626 // P_1 = P_1*r^2 + P2
629 fma.s1 sincos_Q_temp2 = sincos_rsq, sincos_Q_temp1, sincos_Q2
634 fma.s1 sincos_P_temp2 = sincos_rsq, sincos_P_temp1, sincos_P2
638 // Polynomials calculation
643 fma.s1 sincos_Q = sincos_rsq, sincos_Q_temp2, sincos_Q1
648 fma.s1 sincos_P = sincos_rsq, sincos_P_temp2, sincos_P1
653 // Q = Q*S[m]*r^2 + S[m]
657 fma.s1 sincos_Q = sincos_srsq,sincos_Q, sincos_Sm
662 fma.s1 sincos_P = sincos_rcub,sincos_P, sincos_r_exact
666 // If sin(denormal), force underflow to be set
669 (p10) fmpy.d.s0 fp_tmp = sincos_NORM_f8,sincos_NORM_f8
674 // result = C[m]*P + Q
677 fma.d.s0 f8 = sincos_Cm, sincos_P, sincos_Q
678 br.ret.sptk b0 // Exit for common path
681 ////////// x = 0/Inf/NaN path //////////////////
682 _SINCOS_SPECIAL_ARGS:
683 .pred.rel "mutex",p8,p9
689 (p8) fma.d.s0 f8 = f8, f0, f0 // sin(+/-0,NaN,Inf)
697 (p9) fma.d.s0 f8 = f8, f0, f1 // cos(+/-0,NaN,Inf)
698 br.ret.sptk b0 // Exit for x = 0/Inf/NaN path
704 getf.exp sincos_r_signexp = sincos_NORM_f8 // Get signexp of x
705 fcmp.eq.s0 p11,p0 = f8, f0 // Dummy op to set denorm flag
706 br.cond.sptk _SINCOS_COMMON2 // Return to main path
709 GLOBAL_IEEE754_END(cos)
710 libm_alias_double_other (__cos, cos)
712 //////////// x >= 2^27 - large arguments routine call ////////////
713 LOCAL_LIBM_ENTRY(__libm_callout_sincos)
717 mov GR_SAVE_r_sincos = sincos_r_sincos // Save sin or cos
719 .save ar.pfs,GR_SAVE_PFS
720 mov GR_SAVE_PFS = ar.pfs
733 setf.sig sincos_save_tmp = sincos_GR_all_ones// inexact set
735 (p8) br.call.sptk.many b0 = __libm_sin_large# // sin(large_X)
740 cmp.ne p9,p0 = GR_SAVE_r_sincos, r0 // set p9 if cos
742 (p9) br.call.sptk.many b0 = __libm_cos_large# // cos(large_X)
747 fma.d.s0 f8 = f8, f1, f0 // Round result to double
753 fmpy.s0 sincos_save_tmp = sincos_save_tmp, sincos_save_tmp
759 mov ar.pfs = GR_SAVE_PFS
760 br.ret.sptk b0 // Exit for large arguments routine call
763 LOCAL_LIBM_END(__libm_callout_sincos)
765 .type __libm_sin_large#,@function
766 .global __libm_sin_large#
767 .type __libm_cos_large#,@function
768 .global __libm_cos_large#