4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
30 #include <sys/isa_defs.h>
31 #include <sys/ccompile.h>
34 #define HI(x) *(1+(int*)x)
35 #define LO(x) *(unsigned*)x
37 #define HI(x) *(int*)x
38 #define LO(x) *(1+(unsigned*)x)
42 #define restrict _Restrict
50 * Vector cosine function. Just slight modifications to vsin.8.c, mainly
51 * in the primary range part.
53 * Modification to primary range processing. If an argument that does not
54 * fall in the primary range is encountered, then processing is continued
55 * in the medium range.
59 extern const double __vlibm_TBL_sincos_hi
[], __vlibm_TBL_sincos_lo
[];
62 half
[2] = { 0.5, -0.5 },
64 invpio2
= 0.636619772367581343075535, /* 53 bits of pi/2 */
65 pio2_1
= 1.570796326734125614166, /* first 33 bits of pi/2 */
66 pio2_2
= 6.077100506303965976596e-11, /* second 33 bits of pi/2 */
67 pio2_3
= 2.022266248711166455796e-21, /* third 33 bits of pi/2 */
68 pio2_3t
= 8.478427660368899643959e-32, /* pi/2 - pio2_3 */
69 pp1
= -1.666666666605760465276263943134982554676e-0001,
70 pp2
= 8.333261209690963126718376566146180944442e-0003,
71 qq1
= -4.999999999977710986407023955908711557870e-0001,
72 qq2
= 4.166654863857219350645055881018842089580e-0002,
73 poly1
[2]= { -1.666666666666629669805215138920301589656e-0001,
74 -4.999999999999931701464060878888294524481e-0001 },
75 poly2
[2]= { 8.333333332390951295683993455280336376663e-0003,
76 4.166666666394861917535640593963708222319e-0002 },
77 poly3
[2]= { -1.984126237997976692791551778230098403960e-0004,
78 -1.388888552656142867832756687736851681462e-0003 },
79 poly4
[2]= { 2.753403624854277237649987622848330351110e-0006,
80 2.478519423681460796618128289454530524759e-0005 };
82 static const unsigned thresh
[2] = { 0x3fc90000, 0x3fc40000 };
84 /* Don't __ the following; acomp will handle it */
85 extern double fabs(double);
86 extern void __vlibm_vcos_big(int, double *, int, double *, int, int);
89 * y[i*stridey] := cos( x[i*stridex] ), for i = 0..n.
91 * Calls __vlibm_vcos_big to handle all elts which have abs >~ 1.647e+06.
92 * Argument reduction is done here for elts pi/4 < arg < 1.647e+06.
94 * elts < 2^-27 use the approximation 1.0 ~ cos(x).
97 __vcos(int n
, double * restrict x
, int stridex
, double * restrict y
,
100 double x0_or_one
[4], x1_or_one
[4], x2_or_one
[4];
101 double y0_or_zero
[4], y1_or_zero
[4], y2_or_zero
[4];
102 double x0
, x1
, x2
, *py0
= 0, *py1
= 0, *py2
, *xsave
, *ysave
;
103 unsigned hx0
, hx1
, hx2
, xsb0
, xsb1
= 0, xsb2
;
104 int i
, biguns
, nsave
, sxsave
, sysave
;
105 volatile int v __unused
;
113 x0
= *x
; /* 'x0' may be used uninitialized */
116 /* Gotos here so _break_ exits MAIN LOOP. */
117 LOOP0
: /* Find first arg in right range. */
118 xsb0
= HI(x
); /* get most significant word */
119 hx0
= xsb0
& ~0x80000000; /* mask off sign bit */
120 if (hx0
> 0x3fe921fb) {
121 /* Too big: arg reduction needed, so leave for second part */
125 if (hx0
< 0x3e400000) {
126 /* Too small. cos x ~ 1. */
144 LOOP1
: /* Get second arg, same as above. */
146 hx1
= xsb1
& ~0x80000000;
147 if (hx1
> 0x3fe921fb)
152 if (hx1
< 0x3e400000)
171 LOOP2
: /* Get third arg, same as above. */
173 hx2
= xsb2
& ~0x80000000;
174 if (hx2
> 0x3fe921fb)
179 if (hx2
< 0x3e400000)
194 * 0x3fc40000 = 5/32 ~ 0.15625
195 * Get msb after subtraction. Will be 1 only if
196 * hx0 - 5/32 is negative.
198 i
= (hx0
- 0x3fc40000) >> 31;
199 i
|= ((hx1
- 0x3fc40000) >> 30) & 2;
200 i
|= ((hx2
- 0x3fc40000) >> 29) & 4;
203 double a0
, a1
, a2
, w0
, w1
, w2
;
204 double t0
, t1
, t2
, z0
, z1
, z2
;
207 case 0: /* All are > 5/32 */
208 j0
= (xsb0
+ 0x4000) & 0xffff8000;
209 j1
= (xsb1
+ 0x4000) & 0xffff8000;
210 j2
= (xsb2
+ 0x4000) & 0xffff8000;
223 t0
= z0
* (qq1
+ z0
* qq2
);
224 t1
= z1
* (qq1
+ z1
* qq2
);
225 t2
= z2
* (qq1
+ z2
* qq2
);
226 w0
= x0
* (one
+ z0
* (pp1
+ z0
* pp2
));
227 w1
= x1
* (one
+ z1
* (pp1
+ z1
* pp2
));
228 w2
= x2
* (one
+ z2
* (pp1
+ z2
* pp2
));
229 j0
= (((j0
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
230 j1
= (((j1
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
231 j2
= (((j2
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
232 xsb0
= (xsb0
>> 30) & 2;
233 xsb1
= (xsb1
>> 30) & 2;
234 xsb2
= (xsb2
>> 30) & 2;
235 a0
= __vlibm_TBL_sincos_hi
[j0
+1]; /* cos_hi(t) */
236 a1
= __vlibm_TBL_sincos_hi
[j1
+1];
237 a2
= __vlibm_TBL_sincos_hi
[j2
+1];
238 /* cos_lo(t) sin_hi(t) */
239 t0
= __vlibm_TBL_sincos_lo
[j0
+1] - (__vlibm_TBL_sincos_hi
[j0
+xsb0
]*w0
- a0
*t0
);
240 t1
= __vlibm_TBL_sincos_lo
[j1
+1] - (__vlibm_TBL_sincos_hi
[j1
+xsb1
]*w1
- a1
*t1
);
241 t2
= __vlibm_TBL_sincos_lo
[j2
+1] - (__vlibm_TBL_sincos_hi
[j2
+xsb2
]*w2
- a2
*t2
);
249 j1
= (xsb1
+ 0x4000) & 0xffff8000;
250 j2
= (xsb2
+ 0x4000) & 0xffff8000;
260 t0
= z0
* (poly3
[1] + z0
* poly4
[1]);
261 t1
= z1
* (qq1
+ z1
* qq2
);
262 t2
= z2
* (qq1
+ z2
* qq2
);
263 t0
= z0
* (poly1
[1] + z0
* (poly2
[1] + t0
));
264 w1
= x1
* (one
+ z1
* (pp1
+ z1
* pp2
));
265 w2
= x2
* (one
+ z2
* (pp1
+ z2
* pp2
));
266 j1
= (((j1
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
267 j2
= (((j2
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
268 xsb1
= (xsb1
>> 30) & 2;
269 xsb2
= (xsb2
>> 30) & 2;
270 a1
= __vlibm_TBL_sincos_hi
[j1
+1];
271 a2
= __vlibm_TBL_sincos_hi
[j2
+1];
272 t1
= __vlibm_TBL_sincos_lo
[j1
+1] - (__vlibm_TBL_sincos_hi
[j1
+xsb1
]*w1
- a1
*t1
);
273 t2
= __vlibm_TBL_sincos_lo
[j2
+1] - (__vlibm_TBL_sincos_hi
[j2
+xsb2
]*w2
- a2
*t2
);
280 j0
= (xsb0
+ 0x4000) & 0xffff8000;
281 j2
= (xsb2
+ 0x4000) & 0xffff8000;
291 t0
= z0
* (qq1
+ z0
* qq2
);
292 t1
= z1
* (poly3
[1] + z1
* poly4
[1]);
293 t2
= z2
* (qq1
+ z2
* qq2
);
294 w0
= x0
* (one
+ z0
* (pp1
+ z0
* pp2
));
295 t1
= z1
* (poly1
[1] + z1
* (poly2
[1] + t1
));
296 w2
= x2
* (one
+ z2
* (pp1
+ z2
* pp2
));
297 j0
= (((j0
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
298 j2
= (((j2
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
299 xsb0
= (xsb0
>> 30) & 2;
300 xsb2
= (xsb2
>> 30) & 2;
301 a0
= __vlibm_TBL_sincos_hi
[j0
+1];
302 a2
= __vlibm_TBL_sincos_hi
[j2
+1];
303 t0
= __vlibm_TBL_sincos_lo
[j0
+1] - (__vlibm_TBL_sincos_hi
[j0
+xsb0
]*w0
- a0
*t0
);
304 t2
= __vlibm_TBL_sincos_lo
[j2
+1] - (__vlibm_TBL_sincos_hi
[j2
+xsb2
]*w2
- a2
*t2
);
311 j2
= (xsb2
+ 0x4000) & 0xffff8000;
318 t0
= z0
* (poly3
[1] + z0
* poly4
[1]);
319 t1
= z1
* (poly3
[1] + z1
* poly4
[1]);
320 t2
= z2
* (qq1
+ z2
* qq2
);
321 t0
= z0
* (poly1
[1] + z0
* (poly2
[1] + t0
));
322 t1
= z1
* (poly1
[1] + z1
* (poly2
[1] + t1
));
323 w2
= x2
* (one
+ z2
* (pp1
+ z2
* pp2
));
324 j2
= (((j2
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
325 xsb2
= (xsb2
>> 30) & 2;
326 a2
= __vlibm_TBL_sincos_hi
[j2
+1];
327 t2
= __vlibm_TBL_sincos_lo
[j2
+1] - (__vlibm_TBL_sincos_hi
[j2
+xsb2
]*w2
- a2
*t2
);
334 j0
= (xsb0
+ 0x4000) & 0xffff8000;
335 j1
= (xsb1
+ 0x4000) & 0xffff8000;
345 t0
= z0
* (qq1
+ z0
* qq2
);
346 t1
= z1
* (qq1
+ z1
* qq2
);
347 t2
= z2
* (poly3
[1] + z2
* poly4
[1]);
348 w0
= x0
* (one
+ z0
* (pp1
+ z0
* pp2
));
349 w1
= x1
* (one
+ z1
* (pp1
+ z1
* pp2
));
350 t2
= z2
* (poly1
[1] + z2
* (poly2
[1] + t2
));
351 j0
= (((j0
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
352 j1
= (((j1
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
353 xsb0
= (xsb0
>> 30) & 2;
354 xsb1
= (xsb1
>> 30) & 2;
355 a0
= __vlibm_TBL_sincos_hi
[j0
+1];
356 a1
= __vlibm_TBL_sincos_hi
[j1
+1];
357 t0
= __vlibm_TBL_sincos_lo
[j0
+1] - (__vlibm_TBL_sincos_hi
[j0
+xsb0
]*w0
- a0
*t0
);
358 t1
= __vlibm_TBL_sincos_lo
[j1
+1] - (__vlibm_TBL_sincos_hi
[j1
+xsb1
]*w1
- a1
*t1
);
365 j1
= (xsb1
+ 0x4000) & 0xffff8000;
372 t0
= z0
* (poly3
[1] + z0
* poly4
[1]);
373 t1
= z1
* (qq1
+ z1
* qq2
);
374 t2
= z2
* (poly3
[1] + z2
* poly4
[1]);
375 t0
= z0
* (poly1
[1] + z0
* (poly2
[1] + t0
));
376 w1
= x1
* (one
+ z1
* (pp1
+ z1
* pp2
));
377 t2
= z2
* (poly1
[1] + z2
* (poly2
[1] + t2
));
378 j1
= (((j1
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
379 xsb1
= (xsb1
>> 30) & 2;
380 a1
= __vlibm_TBL_sincos_hi
[j1
+1];
381 t1
= __vlibm_TBL_sincos_lo
[j1
+1] - (__vlibm_TBL_sincos_hi
[j1
+xsb1
]*w1
- a1
*t1
);
388 j0
= (xsb0
+ 0x4000) & 0xffff8000;
395 t0
= z0
* (qq1
+ z0
* qq2
);
396 t1
= z1
* (poly3
[1] + z1
* poly4
[1]);
397 t2
= z2
* (poly3
[1] + z2
* poly4
[1]);
398 w0
= x0
* (one
+ z0
* (pp1
+ z0
* pp2
));
399 t1
= z1
* (poly1
[1] + z1
* (poly2
[1] + t1
));
400 t2
= z2
* (poly1
[1] + z2
* (poly2
[1] + t2
));
401 j0
= (((j0
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
402 xsb0
= (xsb0
>> 30) & 2;
403 a0
= __vlibm_TBL_sincos_hi
[j0
+1];
404 t0
= __vlibm_TBL_sincos_lo
[j0
+1] - (__vlibm_TBL_sincos_hi
[j0
+xsb0
]*w0
- a0
*t0
);
410 case 7: /* All are < 5/32 */
414 t0
= z0
* (poly3
[1] + z0
* poly4
[1]);
415 t1
= z1
* (poly3
[1] + z1
* poly4
[1]);
416 t2
= z2
* (poly3
[1] + z2
* poly4
[1]);
417 t0
= z0
* (poly1
[1] + z0
* (poly2
[1] + t0
));
418 t1
= z1
* (poly1
[1] + z1
* (poly2
[1] + t1
));
419 t2
= z2
* (poly1
[1] + z2
* (poly2
[1] + t2
));
429 } while (--n
> 0); /* END MAIN LOOP */
432 * CLEAN UP last 0, 1, or 2 elts.
434 if (i
> 0) /* Clean up elts at tail. i < 3. */
436 double a0
, a1
, w0
, w1
;
437 double t0
, t1
, z0
, z1
;
442 if (hx1
< 0x3fc40000)
445 t1
= z1
* (poly3
[1] + z1
* poly4
[1]);
446 t1
= z1
* (poly1
[1] + z1
* (poly2
[1] + t1
));
452 j1
= (xsb1
+ 0x4000) & 0xffff8000;
457 t1
= z1
* (qq1
+ z1
* qq2
);
458 w1
= x1
* (one
+ z1
* (pp1
+ z1
* pp2
));
459 j1
= (((j1
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
460 xsb1
= (xsb1
>> 30) & 2;
461 a1
= __vlibm_TBL_sincos_hi
[j1
+1];
462 t1
= __vlibm_TBL_sincos_lo
[j1
+1]
463 - (__vlibm_TBL_sincos_hi
[j1
+xsb1
]*w1
- a1
*t1
);
467 if (hx0
< 0x3fc40000)
470 t0
= z0
* (poly3
[1] + z0
* poly4
[1]);
471 t0
= z0
* (poly1
[1] + z0
* (poly2
[1] + t0
));
477 j0
= (xsb0
+ 0x4000) & 0xffff8000;
482 t0
= z0
* (qq1
+ z0
* qq2
);
483 w0
= x0
* (one
+ z0
* (pp1
+ z0
* pp2
));
484 j0
= (((j0
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
485 xsb0
= (xsb0
>> 30) & 2;
486 a0
= __vlibm_TBL_sincos_hi
[j0
+1];
487 t0
= __vlibm_TBL_sincos_lo
[j0
+1] - (__vlibm_TBL_sincos_hi
[j0
+xsb0
]*w0
- a0
*t0
);
495 * Take care of BIGUNS.
497 * We have jumped here in the middle of processing after having
498 * encountered a medium range argument. Therefore things are in a
524 else if (biguns
== 2)
534 double fn0
, fn1
, fn2
, a0
, a1
, a2
, w0
, w1
, w2
, y0
, y1
, y2
;
539 * Find 3 more to work on: Not already done, not too big.
546 if (hx
> 0x413921fb) /* (1.6471e+06) Too big: leave it. */
548 if (hx
>= 0x7ff00000) /* Inf or NaN */
576 if (hx
>= 0x7ff00000)
604 if (hx
>= 0x7ff00000)
621 n0
= (int) (x0
* invpio2
+ half
[xsb0
]);
622 n1
= (int) (x1
* invpio2
+ half
[xsb1
]);
623 n2
= (int) (x2
* invpio2
+ half
[xsb2
]);
627 n0
= (n0
+ 1) & 3; /* Add 1 (before the mod) to make sin into cos */
630 a0
= x0
- fn0
* pio2_1
;
631 a1
= x1
- fn1
* pio2_1
;
632 a2
= x2
- fn2
* pio2_1
;
645 w0
= fn0
* pio2_3
- y0
;
646 w1
= fn1
* pio2_3
- y1
;
647 w2
= fn2
* pio2_3
- y2
;
657 w0
= fn0
* pio2_3t
- y0
;
658 w1
= fn1
* pio2_3t
- y1
;
659 w2
= fn2
* pio2_3t
- y2
;
667 i
= ((xsb0
& ~0x80000000) - thresh
[n0
&1]) >> 31;
669 i
|= (((xsb1
& ~0x80000000) - thresh
[n1
&1]) >> 30) & 2;
671 i
|= (((xsb2
& ~0x80000000) - thresh
[n2
&1]) >> 29) & 4;
674 double t0
, t1
, t2
, z0
, z1
, z2
;
678 j0
= (xsb0
+ 0x4000) & 0xffff8000;
679 j1
= (xsb1
+ 0x4000) & 0xffff8000;
680 j2
= (xsb2
+ 0x4000) & 0xffff8000;
693 t0
= z0
* (qq1
+ z0
* qq2
);
694 t1
= z1
* (qq1
+ z1
* qq2
);
695 t2
= z2
* (qq1
+ z2
* qq2
);
696 w0
= x0
* (one
+ z0
* (pp1
+ z0
* pp2
));
697 w1
= x1
* (one
+ z1
* (pp1
+ z1
* pp2
));
698 w2
= x2
* (one
+ z2
* (pp1
+ z2
* pp2
));
699 j0
= (((j0
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
700 j1
= (((j1
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
701 j2
= (((j2
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
702 xsb0
= (xsb0
>> 30) & 2;
703 xsb1
= (xsb1
>> 30) & 2;
704 xsb2
= (xsb2
>> 30) & 2;
705 n0
^= (xsb0
& ~(n0
<< 1));
706 n1
^= (xsb1
& ~(n1
<< 1));
707 n2
^= (xsb2
& ~(n2
<< 1));
711 a0
= __vlibm_TBL_sincos_hi
[j0
+n0
];
712 a1
= __vlibm_TBL_sincos_hi
[j1
+n1
];
713 a2
= __vlibm_TBL_sincos_hi
[j2
+n2
];
714 t0
= (__vlibm_TBL_sincos_hi
[j0
+((n0
+xsb0
)&3)] * w0
+ a0
* t0
) + __vlibm_TBL_sincos_lo
[j0
+n0
];
715 t1
= (__vlibm_TBL_sincos_hi
[j1
+((n1
+xsb1
)&3)] * w1
+ a1
* t1
) + __vlibm_TBL_sincos_lo
[j1
+n1
];
716 t2
= (__vlibm_TBL_sincos_hi
[j2
+((n2
+xsb2
)&3)] * w2
+ a2
* t2
) + __vlibm_TBL_sincos_lo
[j2
+n2
];
724 j1
= (xsb1
+ 0x4000) & 0xffff8000;
725 j2
= (xsb2
+ 0x4000) & 0xffff8000;
739 t0
= z0
* (poly3
[j0
] + z0
* poly4
[j0
]);
740 t1
= z1
* (qq1
+ z1
* qq2
);
741 t2
= z2
* (qq1
+ z2
* qq2
);
742 t0
= z0
* (poly1
[j0
] + z0
* (poly2
[j0
] + t0
));
743 w1
= x1
* (one
+ z1
* (pp1
+ z1
* pp2
));
744 w2
= x2
* (one
+ z2
* (pp1
+ z2
* pp2
));
745 j1
= (((j1
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
746 j2
= (((j2
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
747 xsb1
= (xsb1
>> 30) & 2;
748 xsb2
= (xsb2
>> 30) & 2;
749 n1
^= (xsb1
& ~(n1
<< 1));
750 n2
^= (xsb2
& ~(n2
<< 1));
753 a1
= __vlibm_TBL_sincos_hi
[j1
+n1
];
754 a2
= __vlibm_TBL_sincos_hi
[j2
+n2
];
755 t0
= x0_or_one
[n0
] + (y0_or_zero
[n0
] + x0_or_one
[n0
] * t0
);
756 t1
= (__vlibm_TBL_sincos_hi
[j1
+((n1
+xsb1
)&3)] * w1
+ a1
* t1
) + __vlibm_TBL_sincos_lo
[j1
+n1
];
757 t2
= (__vlibm_TBL_sincos_hi
[j2
+((n2
+xsb2
)&3)] * w2
+ a2
* t2
) + __vlibm_TBL_sincos_lo
[j2
+n2
];
764 j0
= (xsb0
+ 0x4000) & 0xffff8000;
766 j2
= (xsb2
+ 0x4000) & 0xffff8000;
780 t0
= z0
* (qq1
+ z0
* qq2
);
781 t1
= z1
* (poly3
[j1
] + z1
* poly4
[j1
]);
782 t2
= z2
* (qq1
+ z2
* qq2
);
783 w0
= x0
* (one
+ z0
* (pp1
+ z0
* pp2
));
784 t1
= z1
* (poly1
[j1
] + z1
* (poly2
[j1
] + t1
));
785 w2
= x2
* (one
+ z2
* (pp1
+ z2
* pp2
));
786 j0
= (((j0
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
787 j2
= (((j2
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
788 xsb0
= (xsb0
>> 30) & 2;
789 xsb2
= (xsb2
>> 30) & 2;
790 n0
^= (xsb0
& ~(n0
<< 1));
791 n2
^= (xsb2
& ~(n2
<< 1));
794 a0
= __vlibm_TBL_sincos_hi
[j0
+n0
];
795 a2
= __vlibm_TBL_sincos_hi
[j2
+n2
];
796 t0
= (__vlibm_TBL_sincos_hi
[j0
+((n0
+xsb0
)&3)] * w0
+ a0
* t0
) + __vlibm_TBL_sincos_lo
[j0
+n0
];
797 t1
= x1_or_one
[n1
] + (y1_or_zero
[n1
] + x1_or_one
[n1
] * t1
);
798 t2
= (__vlibm_TBL_sincos_hi
[j2
+((n2
+xsb2
)&3)] * w2
+ a2
* t2
) + __vlibm_TBL_sincos_lo
[j2
+n2
];
807 j2
= (xsb2
+ 0x4000) & 0xffff8000;
822 t0
= z0
* (poly3
[j0
] + z0
* poly4
[j0
]);
823 t1
= z1
* (poly3
[j1
] + z1
* poly4
[j1
]);
824 t2
= z2
* (qq1
+ z2
* qq2
);
825 t0
= z0
* (poly1
[j0
] + z0
* (poly2
[j0
] + t0
));
826 t1
= z1
* (poly1
[j1
] + z1
* (poly2
[j1
] + t1
));
827 w2
= x2
* (one
+ z2
* (pp1
+ z2
* pp2
));
828 j2
= (((j2
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
829 xsb2
= (xsb2
>> 30) & 2;
830 n2
^= (xsb2
& ~(n2
<< 1));
832 a2
= __vlibm_TBL_sincos_hi
[j2
+n2
];
833 t0
= x0_or_one
[n0
] + (y0_or_zero
[n0
] + x0_or_one
[n0
] * t0
);
834 t1
= x1_or_one
[n1
] + (y1_or_zero
[n1
] + x1_or_one
[n1
] * t1
);
835 t2
= (__vlibm_TBL_sincos_hi
[j2
+((n2
+xsb2
)&3)] * w2
+ a2
* t2
) + __vlibm_TBL_sincos_lo
[j2
+n2
];
842 j0
= (xsb0
+ 0x4000) & 0xffff8000;
843 j1
= (xsb1
+ 0x4000) & 0xffff8000;
858 t0
= z0
* (qq1
+ z0
* qq2
);
859 t1
= z1
* (qq1
+ z1
* qq2
);
860 t2
= z2
* (poly3
[j2
] + z2
* poly4
[j2
]);
861 w0
= x0
* (one
+ z0
* (pp1
+ z0
* pp2
));
862 w1
= x1
* (one
+ z1
* (pp1
+ z1
* pp2
));
863 t2
= z2
* (poly1
[j2
] + z2
* (poly2
[j2
] + t2
));
864 j0
= (((j0
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
865 j1
= (((j1
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
866 xsb0
= (xsb0
>> 30) & 2;
867 xsb1
= (xsb1
>> 30) & 2;
868 n0
^= (xsb0
& ~(n0
<< 1));
869 n1
^= (xsb1
& ~(n1
<< 1));
872 a0
= __vlibm_TBL_sincos_hi
[j0
+n0
];
873 a1
= __vlibm_TBL_sincos_hi
[j1
+n1
];
874 t0
= (__vlibm_TBL_sincos_hi
[j0
+((n0
+xsb0
)&3)] * w0
+ a0
* t0
) + __vlibm_TBL_sincos_lo
[j0
+n0
];
875 t1
= (__vlibm_TBL_sincos_hi
[j1
+((n1
+xsb1
)&3)] * w1
+ a1
* t1
) + __vlibm_TBL_sincos_lo
[j1
+n1
];
876 t2
= x2_or_one
[n2
] + (y2_or_zero
[n2
] + x2_or_one
[n2
] * t2
);
884 j1
= (xsb1
+ 0x4000) & 0xffff8000;
900 t0
= z0
* (poly3
[j0
] + z0
* poly4
[j0
]);
901 t1
= z1
* (qq1
+ z1
* qq2
);
902 t2
= z2
* (poly3
[j2
] + z2
* poly4
[j2
]);
903 t0
= z0
* (poly1
[j0
] + z0
* (poly2
[j0
] + t0
));
904 w1
= x1
* (one
+ z1
* (pp1
+ z1
* pp2
));
905 t2
= z2
* (poly1
[j2
] + z2
* (poly2
[j2
] + t2
));
906 j1
= (((j1
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
907 xsb1
= (xsb1
>> 30) & 2;
908 n1
^= (xsb1
& ~(n1
<< 1));
910 a1
= __vlibm_TBL_sincos_hi
[j1
+n1
];
911 t0
= x0_or_one
[n0
] + (y0_or_zero
[n0
] + x0_or_one
[n0
] * t0
);
912 t1
= (__vlibm_TBL_sincos_hi
[j1
+((n1
+xsb1
)&3)] * w1
+ a1
* t1
) + __vlibm_TBL_sincos_lo
[j1
+n1
];
913 t2
= x2_or_one
[n2
] + (y2_or_zero
[n2
] + x2_or_one
[n2
] * t2
);
920 j0
= (xsb0
+ 0x4000) & 0xffff8000;
937 t0
= z0
* (qq1
+ z0
* qq2
);
938 t1
= z1
* (poly3
[j1
] + z1
* poly4
[j1
]);
939 t2
= z2
* (poly3
[j2
] + z2
* poly4
[j2
]);
940 w0
= x0
* (one
+ z0
* (pp1
+ z0
* pp2
));
941 t1
= z1
* (poly1
[j1
] + z1
* (poly2
[j1
] + t1
));
942 t2
= z2
* (poly1
[j2
] + z2
* (poly2
[j2
] + t2
));
943 j0
= (((j0
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
944 xsb0
= (xsb0
>> 30) & 2;
945 n0
^= (xsb0
& ~(n0
<< 1));
947 a0
= __vlibm_TBL_sincos_hi
[j0
+n0
];
948 t0
= (__vlibm_TBL_sincos_hi
[j0
+((n0
+xsb0
)&3)] * w0
+ a0
* t0
) + __vlibm_TBL_sincos_lo
[j0
+n0
];
949 t1
= x1_or_one
[n1
] + (y1_or_zero
[n1
] + x1_or_one
[n1
] * t1
);
950 t2
= x2_or_one
[n2
] + (y2_or_zero
[n2
] + x2_or_one
[n2
] * t2
);
975 t0
= z0
* (poly3
[j0
] + z0
* poly4
[j0
]);
976 t1
= z1
* (poly3
[j1
] + z1
* poly4
[j1
]);
977 t2
= z2
* (poly3
[j2
] + z2
* poly4
[j2
]);
978 t0
= z0
* (poly1
[j0
] + z0
* (poly2
[j0
] + t0
));
979 t1
= z1
* (poly1
[j1
] + z1
* (poly2
[j1
] + t1
));
980 t2
= z2
* (poly1
[j2
] + z2
* (poly2
[j2
] + t2
));
981 t0
= x0_or_one
[n0
] + (y0_or_zero
[n0
] + x0_or_one
[n0
] * t0
);
982 t1
= x1_or_one
[n1
] + (y1_or_zero
[n1
] + x1_or_one
[n1
] * t1
);
983 t2
= x2_or_one
[n2
] + (y2_or_zero
[n2
] + x2_or_one
[n2
] * t2
);
997 double fn0
, fn1
, a0
, a1
, w0
, w1
, y0
, y1
;
998 double t0
, t1
, z0
, z1
;
1004 n1
= (int) (x1
* invpio2
+ half
[xsb1
]);
1006 n1
= (n1
+ 1) & 3; /* Add 1 (before the mod) to make sin into cos */
1007 a1
= x1
- fn1
* pio2_1
;
1010 y1
= (a1
- x1
) - w1
;
1012 w1
= fn1
* pio2_3
- y1
;
1014 y1
= (a1
- x1
) - w1
;
1016 w1
= fn1
* pio2_3t
- y1
;
1018 y1
= (a1
- x1
) - w1
;
1020 if ((xsb1
& ~0x80000000) < thresh
[n1
&1])
1026 y1_or_zero
[2] = -y1
;
1028 t1
= z1
* (poly3
[j1
] + z1
* poly4
[j1
]);
1029 t1
= z1
* (poly1
[j1
] + z1
* (poly2
[j1
] + t1
));
1030 t1
= x1_or_one
[n1
] + (y1_or_zero
[n1
] + x1_or_one
[n1
] * t1
);
1035 j1
= (xsb1
+ 0x4000) & 0xffff8000;
1038 x1
= (x1
- t1
) + y1
;
1040 t1
= z1
* (qq1
+ z1
* qq2
);
1041 w1
= x1
* (one
+ z1
* (pp1
+ z1
* pp2
));
1042 j1
= (((j1
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
1043 xsb1
= (xsb1
>> 30) & 2;
1044 n1
^= (xsb1
& ~(n1
<< 1));
1046 a1
= __vlibm_TBL_sincos_hi
[j1
+n1
];
1047 t1
= (__vlibm_TBL_sincos_hi
[j1
+((n1
+xsb1
)&3)] * w1
+ a1
* t1
) + __vlibm_TBL_sincos_lo
[j1
+n1
];
1051 n0
= (int) (x0
* invpio2
+ half
[xsb0
]);
1053 n0
= (n0
+ 1) & 3; /* Add 1 (before the mod) to make sin into cos */
1054 a0
= x0
- fn0
* pio2_1
;
1057 y0
= (a0
- x0
) - w0
;
1059 w0
= fn0
* pio2_3
- y0
;
1061 y0
= (a0
- x0
) - w0
;
1063 w0
= fn0
* pio2_3t
- y0
;
1065 y0
= (a0
- x0
) - w0
;
1067 if ((xsb0
& ~0x80000000) < thresh
[n0
&1])
1073 y0_or_zero
[2] = -y0
;
1075 t0
= z0
* (poly3
[j0
] + z0
* poly4
[j0
]);
1076 t0
= z0
* (poly1
[j0
] + z0
* (poly2
[j0
] + t0
));
1077 t0
= x0_or_one
[n0
] + (y0_or_zero
[n0
] + x0_or_one
[n0
] * t0
);
1082 j0
= (xsb0
+ 0x4000) & 0xffff8000;
1085 x0
= (x0
- t0
) + y0
;
1087 t0
= z0
* (qq1
+ z0
* qq2
);
1088 w0
= x0
* (one
+ z0
* (pp1
+ z0
* pp2
));
1089 j0
= (((j0
& ~0x80000000) - 0x3fc40000) >> 13) & ~0x3;
1090 xsb0
= (xsb0
>> 30) & 2;
1091 n0
^= (xsb0
& ~(n0
<< 1));
1093 a0
= __vlibm_TBL_sincos_hi
[j0
+n0
];
1094 t0
= (__vlibm_TBL_sincos_hi
[j0
+((n0
+xsb0
)&3)] * w0
+ a0
* t0
) + __vlibm_TBL_sincos_lo
[j0
+n0
];
1100 __vlibm_vcos_big(nsave
, xsave
, sxsave
, ysave
, sysave
, 0x413921fb);