re PR tree-optimization/47280 (ICE: verify_stmts failed: statement marked for throw...
authorRichard Guenther <rguenther@suse.de>
Fri, 14 Jan 2011 13:20:22 +0000 (13:20 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 14 Jan 2011 13:20:22 +0000 (13:20 +0000)
2011-01-14  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/47280
* tree-ssa-forwprop.c (associate_plusminus): Cleanup EH and
return CFG changes.
(tree_ssa_forward_propagate_single_use_vars): Deal with
CFG changes from associate_plusminus.

* g++.dg/opt/pr47280.C: New testcase.

From-SVN: r168784

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr47280.C [new file with mode: 0644]
gcc/tree-ssa-forwprop.c

index ad614d31cc0de6af8991b012d014a14dcb811647..fab41be25de77b0197fbef468857aef6f83a5946 100644 (file)
@@ -1,3 +1,11 @@
+2011-01-14  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/47280
+       * tree-ssa-forwprop.c (associate_plusminus): Cleanup EH and
+       return CFG changes.
+       (tree_ssa_forward_propagate_single_use_vars): Deal with
+       CFG changes from associate_plusminus.
+
 2011-01-14  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/47281
index fa8f110964fc2946e70ef0f1d4ae1d8af7e38953..ed3676813b4fc069bd408d616dc41f01650e94e5 100644 (file)
@@ -1,3 +1,8 @@
+2011-01-14  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/47280
+       * g++.dg/opt/pr47280.C: New testcase.
+
 2011-01-14  Jason Merrill  <jason@redhat.com>
 
        * g++.dg/cpp0x/constexpr-regress1.C: New.
diff --git a/gcc/testsuite/g++.dg/opt/pr47280.C b/gcc/testsuite/g++.dg/opt/pr47280.C
new file mode 100644 (file)
index 0000000..01ca484
--- /dev/null
@@ -0,0 +1,15 @@
+// { dg-do compile }
+// { dg-options "-O -fnon-call-exceptions -ftrapv" }
+
+void bar (int n, char *p)
+{
+  try
+    {
+      n++;
+      for (int i = 0; i < n - 1; i++)
+       p[i];
+    }
+  catch (...)
+    {}
+}
+
index f68395a57c9a942641497132ff4dbfb77de30614..64c8e88e26e125b93a8db4c5223026bf5db71fa1 100644 (file)
@@ -1658,9 +1658,9 @@ simplify_bitwise_and (gimple_stmt_iterator *gsi, gimple stmt)
 
 
 /* Perform re-associations of the plus or minus statement STMT that are
-   always permitted.  */
+   always permitted.  Returns true if the CFG was changed.  */
 
-static void
+static bool
 associate_plusminus (gimple stmt)
 {
   tree rhs1 = gimple_assign_rhs1 (stmt);
@@ -1671,7 +1671,7 @@ associate_plusminus (gimple stmt)
 
   /* We can't reassociate at all for saturating types.  */
   if (TYPE_SATURATING (TREE_TYPE (rhs1)))
-    return;
+    return false;
 
   /* First contract negates.  */
   do
@@ -1934,7 +1934,12 @@ out:
     {
       fold_stmt_inplace (stmt);
       update_stmt (stmt);
+      if (maybe_clean_or_replace_eh_stmt (stmt, stmt)
+         && gimple_purge_dead_eh_edges (gimple_bb (stmt)))
+       return true;
     }
+
+  return false;
 }
 
 /* Main entry point for the forward propagation optimizer.  */
@@ -2062,7 +2067,7 @@ tree_ssa_forward_propagate_single_use_vars (void)
              else if (gimple_assign_rhs_code (stmt) == PLUS_EXPR
                       || gimple_assign_rhs_code (stmt) == MINUS_EXPR)
                {
-                 associate_plusminus (stmt);
+                 cfg_changed |= associate_plusminus (stmt);
                  gsi_next (&gsi);
                }
              else