https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121652
--- Comment #14 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to Aurelien Jarno from comment #13)
> I am starting to wonder if it is really worth inlining so much code compared
> to a call to round(), and if it is not better to not try to handle NaN and
> fflags, requiring both !flag_trapping_math and flag_trapping_math. I even
> wonder if that wasn't the intent in the original code, just the condition
> was wrong and should have been:
> - && (TARGET_ZFA || flag_fp_int_builtin_inexact || !flag_trapping_math)
> + && (TARGET_ZFA || (flag_fp_int_builtin_inexact && !flag_trapping_math))
It's not wrong: the GCC documentation clearly says:
The default is -ffp-int-builtin-inexact, allowing the exception to
be raised, unless C23 or a later C standard is selected. This
option does nothing unless -ftrapping-math is in effect.
So if -fno-trapping-math, we should completely ignore
flag_fp_int_builtin_exact.
(Also the word above seems a little outdated as now GCC defaults to
-std=gnu23.)
If you'd make the expand only work for -fno-trapping-math you should just write
TARGET_CFA || !flag_trapping_math instead.