middle-end/103193 - avoid canonicalizing <= and >= to == for floats
authorRichard Biener <rguenther@suse.de>
Mon, 15 Nov 2021 11:13:40 +0000 (12:13 +0100)
committerRichard Biener <rguenther@suse.de>
Wed, 24 Nov 2021 10:02:13 +0000 (11:02 +0100)
This avoids doing aforementioned canoncalization when -ftrapping-math
is in effect and we honor NaNs.

2021-11-15  Richard Biener  <rguenther@suse.de>

PR middle-end/103193
* match.pd: Avoid canonicalizing (le/ge @0 @0) to (eq @0 @0)
with NaNs and -ftrapping-math.

gcc/match.pd

index 3e54e2c..5adcd6b 100644 (file)
@@ -4671,7 +4671,10 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
   (if (! FLOAT_TYPE_P (TREE_TYPE (@0))
        || ! HONOR_NANS (@0))
    { constant_boolean_node (true, type); }
-   (if (cmp != EQ_EXPR)
+   (if (cmp != EQ_EXPR
+       /* With -ftrapping-math conversion to EQ loses an exception.  */
+       && (! FLOAT_TYPE_P (TREE_TYPE (@0))
+           || ! flag_trapping_math))
     (eq @0 @0)))))
 (for cmp (ne gt lt)
  (simplify