Glibc proposes CORE-MATH sin, cos, and sincos with correct rounding
Adhemerval Zanella's series drops the IBM double-precision routines, which often miss by a unit in the last place outside round-to-nearest, and reports large gains on slow paths with a few fast-path regressions.
Adhemerval Zanella has posted a glibc patch series that replaces the IBM double-precision sin, cos, and sincos with CORE-MATH implementations that are correctly rounded in every rounding mode.
The IBM code always computes in round-to-nearest. In directed modes, Zanella's sampling of more than four billion inputs found about half of the results off by one unit in the last place, and three quarters of paired sincos results wrong in at least one value. Even in round-to-nearest, the IBM functions misround hundreds of thousands of CORE-MATH's hard-to-round cases. That gap matters beyond the functions themselves: compilers routinely rewrite a sin and a cos of the same argument into a single sincos call, so the three have to agree. The new sincos is built on the sin and cos code and produces bitwise identical results.
Switching rounding modes is not free for the rest of libm. For arguments of magnitude at least 2, the Bessel functions j0, j1, y0, and y1 combine sin and cos in sums that cancel near the zeros, and use cos of twice the argument for the worse of those terms. With CORE-MATH rounding in the current mode, j1 and y1 exceed glibc's 9 ulp test threshold in directed modes. The series forces those trigonometric terms back to round-to-nearest, the same approach already used for the higher-order Bessel functions, which keeps the previous accuracy.
On the machines Zanella measured, reciprocal throughput on the slow path (arguments from 2^27 up toward the largest finite doubles) improves by roughly five to eleven times. Moderate arguments are faster on every architecture he tried. The notable regressions are the fast path, inputs in about [-pi, pi], which covers the sincos calls in the SPEC CPU2017 rate suite: sin is about 10 percent slower on AArch64, and sincos about 28 percent slower there. Power10 is the largest winner, with fast-path gains from about double to triple.
The series also shares one copy of the tables among sin, cos, sincos, and the x86_64 ifunc variants, and drops the AVX-only variants. Those no longer beat the SSE2 builds once software fused multiply-add dominates; FMA and FMA4 variants stay.