This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR81297


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_;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]