https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112873
--- Comment #5 from Steve Kargl <sgk at troutmask dot apl.washington.edu> --- On Wed, Dec 06, 2023 at 09:58:18PM +0000, anlauf at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112873 > > anlauf at gcc dot gnu.org changed: > > What |Removed |Added > ---------------------------------------------------------------------------- > Ever confirmed|0 |1 > Last reconfirmed| |2023-12-06 > Status|UNCONFIRMED |NEW > > --- Comment #4 from anlauf at gcc dot gnu.org --- > (In reply to Steve Kargl from comment #3) > > PS: I implemented the half-cycle trig functions (e.g., sinpi, ...) for > > FreeBSD a few years ago. These have a 2-clause BSD license. I'm > > willing to dual-license the code with LGPL if you think these might > > be good fallback routines. > > Thanks for the offer. But do we actually need fallback routines? > > 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 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. Finally, for FreeBSD's cospif(x), here's exhaustive testing for its floating accuracy: % tlibm cospi -x 0x1p-9 -X 0x2p23 -fDE cospi Interval tested for cospif: [0.00195312,1.67772e+07] count: 276824064 (276824064) xm = 6.66955039e-02f, /* 0x3d8897a7 */ flt = 9.78128791e-01f, /* 0x3f7a66a6 */ dbl = 9.7812876099954837e-01, /* 0x3fef4cd4, 0xaff8a456 */ ULP = 0.50090