https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91690
Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |fxcoudert at gcc dot gnu.org --- Comment #8 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> --- I think things are a little more complicated that they appear. The function IEEE_IS_NAN, in itself, is not the problem: it is not slow, and does not store/restore the floating-point state. If you take the demo program, and replace the call to the contained function IS_NAN_IEEE directly by the IEEE_IS_NAN function, you will actually see that it is faster (50% faster) than the bit-checking function. The problem is in the contained function IS_NAN_IEEE. By my reading of the Fortran standard, that function is required to save its floating-point state on entry, and restore it on exit. This is regardless of what happens inside the function, and this is what is slowing things done. Of course, we can still consider this a "missed optimisation": the compiler could in theory determine that absolutely no floating-point operation is being done, and optimise away the save/restore calls. But it is a tricky thing to do, and would have no value for "real" functions, that actually perform floating-point operations.