diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9c8e1765d31..09a89eef409 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-08-05 Richard Biener + + PR middle-end/67107 + * match.pd: Guard const_binop result checking against NULL_TREE + result. + 2015-08-05 Kugan Vivekanandarajah * cse.c (cse_insn): Restoring old behaviour for src_eqv diff --git a/gcc/match.pd b/gcc/match.pd index 3e9100e81f0..2a4f7d698e4 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1599,7 +1599,7 @@ along with GCC; see the file COPYING3. If not see tree tem = const_binop (op == PLUS_EXPR ? MINUS_EXPR : PLUS_EXPR, TREE_TYPE (@1), @2, @1); } - (if (!TREE_OVERFLOW (tem)) + (if (tem && !TREE_OVERFLOW (tem)) (cmp @0 { tem; })))))) /* Likewise, we can simplify a comparison of a real constant with @@ -1610,7 +1610,7 @@ along with GCC; see the file COPYING3. If not see (simplify (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)) + (if (tem && !TREE_OVERFLOW (tem)) (cmp { tem; } @1))))) /* Fold comparisons against built-in math functions. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8471c040c66..1a5d6f932ae 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-08-05 Richard Biener + + PR middle-end/67107 + * gcc.dg/pr67107.c: New testcase. + 2015-08-04 Paolo Carlini PR c++/66197 diff --git a/gcc/testsuite/gcc.dg/pr67107.c b/gcc/testsuite/gcc.dg/pr67107.c new file mode 100644 index 00000000000..e2e11c0f9e2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr67107.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-frounding-math -funsafe-math-optimizations" } */ + +int test () +{ + return 5.0 < 5.0 - 0.1; +}