]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[PR106967] Set known NANs to undefined for flag_finite_math_only.
authorAldy Hernandez <aldyh@redhat.com>
Wed, 21 Sep 2022 09:18:48 +0000 (11:18 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Wed, 21 Sep 2022 11:33:40 +0000 (13:33 +0200)
Explicit NANs in the IL can be treated as undefined for
flag_finite_math_only.  This causes all the right things to happen wrt
threading, folding, etc.  It also saves us special casing throughout.

PR tree-optimization/106967

gcc/ChangeLog:

* value-range.cc (frange::set): Set known NANs to undefined for
flag_finite_math_only.

gcc/value-range.cc

index 505eb9211a793f8c9cb355cb9acf60dfb8b07118..7e8028eced2a72e57225555e88f3ea28145d1313 100644 (file)
@@ -313,8 +313,13 @@ frange::set (tree min, tree max, value_range_kind kind)
       gcc_checking_assert (real_identical (TREE_REAL_CST_PTR (min),
                                           TREE_REAL_CST_PTR (max)));
       tree type = TREE_TYPE (min);
-      bool sign = real_isneg (TREE_REAL_CST_PTR (min));
-      set_nan (type, sign);
+      if (HONOR_NANS (type))
+       {
+         bool sign = real_isneg (TREE_REAL_CST_PTR (min));
+         set_nan (type, sign);
+       }
+      else
+       set_undefined ();
       return;
     }