https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121652
--- Comment #15 from Aurelien Jarno <aurelien at aurel32 dot net> --- (In reply to Xi Ruoyao from comment #14) > (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. Indeed you are correct that there is no need to check for the two. That said my comment still stands, I believe the original code was not intended to handle all cases and that the way to fix that is just to fix the condition as you proposed. Otherwise I find strange that flag_fp_int_builtin_inexact is mentioned in the condition while not having the corresponding code to handle that.
