+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
+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.
--- /dev/null
+// { 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 (...)
+ {}
+}
+
/* 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);
/* We can't reassociate at all for saturating types. */
if (TYPE_SATURATING (TREE_TYPE (rhs1)))
- return;
+ return false;
/* First contract negates. */
do
{
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. */
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