+2014-04-16 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/60844
+ * tree-ssa-reassoc.c (reassoc_remove_stmt): New function.
+ (propagate_op_to_single_use, remove_visited_stmt_chain,
+ linearize_expr, repropagate_negates, reassociate_bb): Use it
+ instead of gsi_remove.
+
2014-04-16 Martin Jambor <mjambor@suse.cz>
* cgraphclones.c (cgraph_create_virtual_clone): Duplicate
--- /dev/null
+/* PR tree-optimization/60844 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -g" } */
+/* { dg-additional-options "-mtune=atom" { target { i?86-*-* x86_64-*-* } } } */
+
+void
+foo (int *x, int y, int z)
+{
+ int b, c = x[0], d = x[1];
+ for (b = 0; b < 1; b++)
+ {
+ int e = (y ? 1 : 0) | (d ? 2 : 0) | (z ? 1 : 0);
+ e |= (c ? 2 : 0) | ((1 >> b) ? 1 : 0);
+ x[2 + b] = e;
+ }
+}
static long get_rank (tree);
static bool reassoc_stmt_dominates_stmt_p (gimple, gimple);
+/* Wrapper around gsi_remove, which adjusts gimple_uid of debug stmts
+ possibly added by gsi_remove. */
+
+bool
+reassoc_remove_stmt (gimple_stmt_iterator *gsi)
+{
+ gimple stmt = gsi_stmt (*gsi);
+
+ if (!MAY_HAVE_DEBUG_STMTS || gimple_code (stmt) == GIMPLE_PHI)
+ return gsi_remove (gsi, true);
+
+ gimple_stmt_iterator prev = *gsi;
+ gsi_prev (&prev);
+ unsigned uid = gimple_uid (stmt);
+ basic_block bb = gimple_bb (stmt);
+ bool ret = gsi_remove (gsi, true);
+ if (!gsi_end_p (prev))
+ gsi_next (&prev);
+ else
+ prev = gsi_start_bb (bb);
+ gimple end_stmt = gsi_stmt (*gsi);
+ while ((stmt = gsi_stmt (prev)) != end_stmt)
+ {
+ gcc_assert (stmt && is_gimple_debug (stmt) && gimple_uid (stmt) == 0);
+ gimple_set_uid (stmt, uid);
+ gsi_next (&prev);
+ }
+ return ret;
+}
/* Bias amount for loop-carried phis. We want this to be larger than
the depth of any reassociation tree we can see, but not larger than
update_stmt (use_stmt);
gsi = gsi_for_stmt (stmt);
unlink_stmt_vdef (stmt);
- gsi_remove (&gsi, true);
+ reassoc_remove_stmt (&gsi);
release_defs (stmt);
}
{
var = gimple_assign_rhs1 (stmt);
gsi = gsi_for_stmt (stmt);
- gsi_remove (&gsi, true);
+ reassoc_remove_stmt (&gsi);
release_defs (stmt);
}
else
update_stmt (stmt);
gsi = gsi_for_stmt (oldbinrhs);
- gsi_remove (&gsi, true);
+ reassoc_remove_stmt (&gsi);
release_defs (oldbinrhs);
gimple_set_visited (stmt, true);
gimple_assign_set_rhs_with_ops (&gsi2, NEGATE_EXPR, x, NULL);
user = gsi_stmt (gsi2);
update_stmt (user);
- gsi_remove (&gsi, true);
+ reassoc_remove_stmt (&gsi);
release_defs (feed);
plus_negates.safe_push (gimple_assign_lhs (user));
}
reassociations. */
if (has_zero_uses (gimple_get_lhs (stmt)))
{
- gsi_remove (&gsi, true);
+ reassoc_remove_stmt (&gsi);
release_defs (stmt);
/* We might end up removing the last stmt above which
places the iterator to the end of the sequence.