This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR67107
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 5 Aug 2015 09:38:18 +0200 (CEST)
- Subject: [PATCH] Fix PR67107
- Authentication-results: sourceware.org; auth=none
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.
Richard.
2015-08-05 Richard Biener <rguenther@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;
+}