diff mbox

Fix PR81297

Message ID alpine.LSU.2.20.1708010900270.10808@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Aug. 1, 2017, 7:01 a.m. UTC
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.
diff mbox

Patch

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