[PATCHv2][PR 57371] Remove useless floating point casts in comparisons

Joseph Myers joseph@codesourcery.com
Fri Jul 7 17:07:00 GMT 2017


On Fri, 7 Jul 2017, Yuri Gribov wrote:

> Hi all,
> 
> This is an updated version of patch in
> https://gcc.gnu.org/ml/gcc-patches/2017-07/msg00034.html . It should
> be much more complete, both in functionality and in tests.

I think there should be tests when the constant is an infinity (of either 
sign) or NaN (quiet or signaling).

I suspect infinities would already work with the patch as-is (the logic 
dealing with constants outside the range of the integer type).  I'm less 
clear that NaNs would work properly.  (If the comparison is == or != you 
can optimize it for quiet NaNs, to false and true respectively.  If it's a 
signaling NaN, or < <= > >=, optimizing to false is only valid with 
-fno-trapping-math, as it would lose an "invalid" exception.)

-- 
Joseph S. Myers
joseph@codesourcery.com



More information about the Gcc-patches mailing list