https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93871
--- Comment #30 from Steve Kargl <sgk at troutmask dot apl.washington.edu> --- On Thu, Feb 27, 2020 at 07:31:43AM +0000, thenlich at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93871 > > --- Comment #29 from Thomas Henlich <thenlich at gcc dot gnu.org> --- > (In reply to Steve Kargl from comment #28) > > ! Fold into [0,90] range > ... > > if (arg == 180) then > > I don't understand how (arg == 180) could be true after folding into [0,90] > range. > Whoops. I quickly threw that code together to investigate the symmetry needed to fold [0,360] into [0:90]. My guess is that I did a last minute edit and moved the (arg == 180) condition without checking or there is a subtle rounding issue with (180 - nearest(180,+-1)). That code certainly isn't production quality as there is no special handling of +-Inf or NaN or tiny x. We should also consider the upper normal x limit where x > xmax=2**(p-e) where p is the precision and e is some value where modulo(x,360) is always integral. This is similar to the radian sin(x) for REAL x and x > 2.**22. I suppose that the point is that it is likely that gfortran should not in-line the sind(x) function. Creating the if-statement is doable in trans-intrinsic.c, but may drive someone nuts to get right. For cosd(x), your suggestion of cosd(x) = sind(90 - module(x,360)) looks promising and could be in-lined.