https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112873
--- Comment #7 from Steve Kargl <sgk at troutmask dot apl.washington.edu> --- On Thu, Dec 07, 2023 at 07:59:25PM +0000, anlauf at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112873 > > --- Comment #6 from anlauf at gcc dot gnu.org --- > (In reply to Steve Kargl from comment #5) > > On Wed, Dec 06, 2023 at 09:58:18PM +0000, anlauf at gcc dot gnu.org wrote: > > > In your experience, how good (or bad) is a naive inline version > > > like we do for the degree versions? > > > > It would be possible to use a naive version, but it will > > likely not approach the requirements placed on these functions > > by at least the IEEE 754 and C23 standards. > > I see. The naive version would have done only range reduction and scaling, > maybe good enough for F2023 ("SINPI (X) is approximately equal to SIN (X×π)") > but not more. > > Also, one needs mpfr-4.2.0 or higher for simple simplification, or do more > work. Correct. A newer version of MPFR contains these functions. In fact, the MPFR developer and I cross-checked each other. We can probably use a naive implementation with high precision if an older MPFR is used. > > I think gfortran > > should test with configure for these functions in libm and > > use those if available (e.g., HAVE_COSPI, etc). In libgfortran, > > we'll need fallbacks if not available. To see the complexity > > of the implementation details see > > > > https://cgit.freebsd.org/src/tree/lib/msun/src/s_cospi.c > > > > Header files defining computation kernels and these use > > the computation kernels for sin() and cos() from fdlibm. > > > > https://cgit.freebsd.org/src/tree/lib/msun/src/k_cospi.h > > https://cgit.freebsd.org/src/tree/lib/msun/src/k_sinpi.h > > > > Note, AFAIK, glibc does not implement these functions. > > Right. > > Would you like to open a separate PR for dealing with the half-cycle > trigonometric functions? Yes, I'll add a new PR for the half-cycle functions, and point to here for the initial discussion.