https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121652
--- Comment #18 from Aurelien Jarno <aurelien at aurel32 dot net> --- Created attachment 62345 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62345&action=edit Patch / Proof of concept In case we want to keep the condition unchanged, here is a patch to correctly handle the sNaN case. It checks for NaN using feq, and jump to a code adding the two arguments in case flag_trapping_math is active to convert the sNaN into a qNan. This is similar to what is done on the GLIVC side. This means there is no need to save and restore the fflags anymore, as this is allowed by -ffp-int-builtin-inexact. Note that it is my first changes in that area of GCC, and I am not fully sure I have done things correctly with the jumps, and especially with the emit_barrier() call. That's why it's maybe only a proof of concept. That said I have however checked and tested the generated code for various combinaison of -f(no-)fp-int-builtin-inexact and -f(no-)signaling-nans. I also checked that the GLIBC testsuite fully passes with this change.
