Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard.
2015-08-05 Richard Biener <rguent...@suse.de> PR middle-end/67107 * match.pd: Guard const_binop result checking against NULL_TREE result. * gcc.dg/pr67107.c: New testcase. Index: gcc/match.pd =================================================================== --- gcc/match.pd (revision 226551) +++ gcc/match.pd (working copy) @@ -1594,7 +1639,7 @@ (define_operator_list CBRT BUILT_IN_CBRT 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 @@ -1605,7 +1650,7 @@ (define_operator_list CBRT BUILT_IN_CBRT (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. */ Index: gcc/testsuite/gcc.dg/pr67107.c =================================================================== --- gcc/testsuite/gcc.dg/pr67107.c (revision 0) +++ gcc/testsuite/gcc.dg/pr67107.c (working copy) @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-frounding-math -funsafe-math-optimizations" } */ + +int test () +{ + return 5.0 < 5.0 - 0.1; +}