Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

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

        PR middle-end/66759
        * match.pd: Add missing constraint of y to REAL_CST in
        REAL_CST - x CMP y to y - CST CMP x simplification.

        * gcc.dg/torture/pr66759.c: New testcase.

Index: gcc/match.pd
===================================================================
--- gcc/match.pd        (revision 225443)
+++ gcc/match.pd        (working copy)
@@ -1496,7 +1513,7 @@ (define_operator_list CBRT BUILT_IN_CBRT
     floating-point types only if -fassociative-math is set.  */
  (if (flag_associative_math)
   (simplify
-   (cmp (minus REAL_CST@0 @1) @2)
+   (cmp (minus REAL_CST@0 @1) REAL_CST@2)
    (with { tree tem = const_binop (MINUS_EXPR, TREE_TYPE (@1), @0, @2); }
     (if (!TREE_OVERFLOW (tem))
      (cmp { tem; } @1)))))
Index: gcc/testsuite/gcc.dg/torture/pr66759.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr66759.c      (revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr66759.c      (working copy)
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-ffast-math" } */
+
+int a, b;
+float c;
+int fn2();
+void fn1()
+{
+  if (fn2() <= 1. - c)
+    b = a;
+}

Reply via email to