The following patch avoids folding NaN < 0 to false if -ftrapping-math
is in effect.

Bootstrap & regtest pending on x86_64-unknown-linux-gnu.

Richard.

2015-07-30  Richard Biener  <rguent...@suse.de>

        PR middle-end/67052
        * fold-const.c (fold_binary_loc): Do not fold NaN < 0 to false
        if FP math can trap.

Index: gcc/fold-const.c
===================================================================
--- gcc/fold-const.c    (revision 226387)
+++ gcc/fold-const.c    (working copy)
@@ -11634,7 +11455,9 @@ fold_binary_loc (location_t loc,
       /* Convert ABS_EXPR<x> < 0 to false.  */
       strict_overflow_p = false;
       if (code == LT_EXPR
-         && (integer_zerop (arg1) || real_zerop (arg1))
+         && (integer_zerop (arg1)
+             || ((! HONOR_NANS (arg0) || !flag_trapping_math)
+                 && real_zerop (arg1)))
          && tree_expr_nonnegative_warnv_p (arg0, &strict_overflow_p))
        {
          if (strict_overflow_p)

Reply via email to