[Bug rtl-optimization/82153] missed optimization: double rounding

joseph at codesourcery dot com gcc-bugzilla@gcc.gnu.org
Fri Sep 8 22:24:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82153

--- Comment #1 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
floor rounds towards -inf.  Conversion to int rounds towards 0.  That is, 
it wouldn't be valid to omit the roundsd because results would be 
different for integer arguments.  That said, if you replace floor by 
trunc, the optimization should be valid (given the default 
-ffp-int-builtin-inexact, anyway, or -fno-trapping-math; as I understand 
it, cvttsd2si raises "inexact" for noninteger arguments, whereas with 
-fno-fp-int-builtin-inexact, trunc isn't allowed to and neither is a 
conversion of an integer floating-point value to an integer type).


More information about the Gcc-bugs mailing list