Commit 42fae17c by Jakub Jelinek Committed by Jakub Jelinek

re PR tree-optimization/60844 (ICE in reassoc_stmt_dominates_stmt_p)

	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.

	* gcc.dg/pr60844.c: New test.

From-SVN: r209442
parent ca860d03
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> 2014-04-16 Martin Jambor <mjambor@suse.cz>
* cgraphclones.c (cgraph_create_virtual_clone): Duplicate * cgraphclones.c (cgraph_create_virtual_clone): Duplicate
......
2014-04-16 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/60844
* gcc.dg/pr60844.c: New test.
2014-04-15 Richard Biener <rguenther@suse.de> 2014-04-15 Richard Biener <rguenther@suse.de>
PR rtl-optimization/56965 PR rtl-optimization/56965
......
/* 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;
}
}
...@@ -221,6 +221,35 @@ static struct pointer_map_t *operand_rank; ...@@ -221,6 +221,35 @@ static struct pointer_map_t *operand_rank;
static long get_rank (tree); static long get_rank (tree);
static bool reassoc_stmt_dominates_stmt_p (gimple, gimple); 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 /* 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 the depth of any reassociation tree we can see, but not larger than
...@@ -1123,7 +1152,7 @@ propagate_op_to_single_use (tree op, gimple stmt, tree *def) ...@@ -1123,7 +1152,7 @@ propagate_op_to_single_use (tree op, gimple stmt, tree *def)
update_stmt (use_stmt); update_stmt (use_stmt);
gsi = gsi_for_stmt (stmt); gsi = gsi_for_stmt (stmt);
unlink_stmt_vdef (stmt); unlink_stmt_vdef (stmt);
gsi_remove (&gsi, true); reassoc_remove_stmt (&gsi);
release_defs (stmt); release_defs (stmt);
} }
...@@ -3072,7 +3101,7 @@ remove_visited_stmt_chain (tree var) ...@@ -3072,7 +3101,7 @@ remove_visited_stmt_chain (tree var)
{ {
var = gimple_assign_rhs1 (stmt); var = gimple_assign_rhs1 (stmt);
gsi = gsi_for_stmt (stmt); gsi = gsi_for_stmt (stmt);
gsi_remove (&gsi, true); reassoc_remove_stmt (&gsi);
release_defs (stmt); release_defs (stmt);
} }
else else
...@@ -3494,7 +3523,7 @@ linearize_expr (gimple stmt) ...@@ -3494,7 +3523,7 @@ linearize_expr (gimple stmt)
update_stmt (stmt); update_stmt (stmt);
gsi = gsi_for_stmt (oldbinrhs); gsi = gsi_for_stmt (oldbinrhs);
gsi_remove (&gsi, true); reassoc_remove_stmt (&gsi);
release_defs (oldbinrhs); release_defs (oldbinrhs);
gimple_set_visited (stmt, true); gimple_set_visited (stmt, true);
...@@ -3896,7 +3925,7 @@ repropagate_negates (void) ...@@ -3896,7 +3925,7 @@ repropagate_negates (void)
gimple_assign_set_rhs_with_ops (&gsi2, NEGATE_EXPR, x, NULL); gimple_assign_set_rhs_with_ops (&gsi2, NEGATE_EXPR, x, NULL);
user = gsi_stmt (gsi2); user = gsi_stmt (gsi2);
update_stmt (user); update_stmt (user);
gsi_remove (&gsi, true); reassoc_remove_stmt (&gsi);
release_defs (feed); release_defs (feed);
plus_negates.safe_push (gimple_assign_lhs (user)); plus_negates.safe_push (gimple_assign_lhs (user));
} }
...@@ -4413,7 +4442,7 @@ reassociate_bb (basic_block bb) ...@@ -4413,7 +4442,7 @@ reassociate_bb (basic_block bb)
reassociations. */ reassociations. */
if (has_zero_uses (gimple_get_lhs (stmt))) if (has_zero_uses (gimple_get_lhs (stmt)))
{ {
gsi_remove (&gsi, true); reassoc_remove_stmt (&gsi);
release_defs (stmt); release_defs (stmt);
/* We might end up removing the last stmt above which /* We might end up removing the last stmt above which
places the iterator to the end of the sequence. places the iterator to the end of the sequence.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment