https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64811
Bug ID: 64811 Summary: fold_inf_compare bogus for NaNs (given -ftrapping-math) Product: gcc Version: 4.9.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: jsm28 at gcc dot gnu.org Various optimizations in fold_inf_compare can cause "invalid" floating-point exceptions to be present when they should be absent, or vice versa. Folding x > +Inf to 0 should not be about HONOR_SNANS - ordered comparisons of both quiet and signaling NaNs should raise invalid. So if -ftrapping-math and HONOR_NANS, this is invalid (given a strict interpretation of -ftrapping-math, anyway). x <= +Inf is not the same as x == x, because again that loses an exception (equality comparisons don't raise exceptions except for signaling NaNs). x == +Inf is not the same as x > DBL_MAX, and a similar issue applies with the x != +Inf case - that transformation causes a spurious exception (in particular, I've seen this in __gcc_qadd for powerpc-linux-gnu soft-float, causing glibc testsuite failures, which is how I found this bug), not just a missing exception. (The existing HONOR_NANS code for NE_EXPR is only about the result, not the exceptions raised.)