This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR81297
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 1 Aug 2017 09:01:20 +0200 (CEST)
- Subject: [PATCH] Fix PR81297
- Authentication-results: sourceware.org; auth=none
The assert I added with the -fstrict-overflow transition is too strict
when facing with generic folding thus the following removes it again.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard.
2017-08-01 Richard Biener <rguenther@suse.de>
PR tree-optimization/81297
* tree-vrp.c (get_single_symbol): Remove assert, instead drop
TREE_OVERFLOW from INTEGER_CSTs.
* gcc.dg/torture/pr81297.c: New testcase.
Index: gcc/testsuite/gcc.dg/torture/pr81297.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr81297.c (nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr81297.c (working copy)
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+int
+nf (int gy, int x0)
+{
+ while (gy < 1)
+ ++x0;
+
+ gy += !!gy;
+ if (gy < 0)
+ {
+ x0 += gy;
+ return (x0 > (gy + x0)) ? (1 / 0) : 1; /* { dg-warning "division by zero" } */
+ }
+}
+
Index: gcc/tree-vrp.c
===================================================================
--- gcc/tree-vrp.c (revision 250725)
+++ gcc/tree-vrp.c (working copy)
@@ -796,7 +796,8 @@ get_single_symbol (tree t, bool *neg, tr
if (TREE_CODE (t) != SSA_NAME)
return NULL_TREE;
- gcc_assert (! inv_ || ! TREE_OVERFLOW_P (inv_));
+ if (inv_ && TREE_OVERFLOW_P (inv_))
+ inv_ = drop_tree_overflow (inv_);
*neg = neg_;
*inv = inv_;