Commit be7493ca by Richard Guenther Committed by Richard Biener

re PR tree-optimization/53774 (Reassociator generates non-canonical addition)

2012-06-27  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/53774
	* tree-ssa-reassoc.c (get_rank): All default defs have
	precomputed rank.
	(init_reassoc): Precompute rank for all SSA default defs.

From-SVN: r189012
parent d3f7b31e
2012-06-27 Richard Guenther <rguenther@suse.de>
PR tree-optimization/53774
* tree-ssa-reassoc.c (get_rank): All default defs have
precomputed rank.
(init_reassoc): Precompute rank for all SSA default defs.
2012-06-27 Nick Clifton <nickc@redhat.com> 2012-06-27 Nick Clifton <nickc@redhat.com>
* config/rx/rx.md (simple_return): Use the simple_return rtx. * config/rx/rx.md (simple_return): Use the simple_return rtx.
......
...@@ -383,14 +383,10 @@ get_rank (tree e) ...@@ -383,14 +383,10 @@ get_rank (tree e)
int i, n; int i, n;
tree op; tree op;
if (TREE_CODE (SSA_NAME_VAR (e)) == PARM_DECL if (SSA_NAME_IS_DEFAULT_DEF (e))
&& SSA_NAME_IS_DEFAULT_DEF (e))
return find_operand_rank (e); return find_operand_rank (e);
stmt = SSA_NAME_DEF_STMT (e); stmt = SSA_NAME_DEF_STMT (e);
if (gimple_bb (stmt) == NULL)
return 0;
if (gimple_code (stmt) == GIMPLE_PHI) if (gimple_code (stmt) == GIMPLE_PHI)
return phi_rank (stmt); return phi_rank (stmt);
...@@ -484,7 +480,7 @@ sort_by_operand_rank (const void *pa, const void *pb) ...@@ -484,7 +480,7 @@ sort_by_operand_rank (const void *pa, const void *pb)
/* It's nicer for optimize_expression if constants that are likely /* It's nicer for optimize_expression if constants that are likely
to fold when added/multiplied//whatever are put next to each to fold when added/multiplied//whatever are put next to each
other. Since all constants have rank 0, order them by type. */ other. Since all constants have rank 0, order them by type. */
if (oeb->rank == 0 && oea->rank == 0) if (oeb->rank == 0 && oea->rank == 0)
{ {
if (constant_type (oeb->op) != constant_type (oea->op)) if (constant_type (oeb->op) != constant_type (oea->op))
return constant_type (oeb->op) - constant_type (oea->op); return constant_type (oeb->op) - constant_type (oea->op);
...@@ -3441,7 +3437,7 @@ transform_stmt_to_multiply (gimple_stmt_iterator *gsi, gimple stmt, ...@@ -3441,7 +3437,7 @@ transform_stmt_to_multiply (gimple_stmt_iterator *gsi, gimple stmt,
print_gimple_stmt (dump_file, stmt, 0, 0); print_gimple_stmt (dump_file, stmt, 0, 0);
} }
gimple_assign_set_rhs_with_ops_1 (gsi, MULT_EXPR, rhs1, rhs2, NULL_TREE); gimple_assign_set_rhs_with_ops (gsi, MULT_EXPR, rhs1, rhs2);
update_stmt (gsi_stmt (*gsi)); update_stmt (gsi_stmt (*gsi));
remove_visited_stmt_chain (rhs1); remove_visited_stmt_chain (rhs1);
...@@ -3647,7 +3643,6 @@ init_reassoc (void) ...@@ -3647,7 +3643,6 @@ init_reassoc (void)
{ {
int i; int i;
long rank = 2; long rank = 2;
tree param;
int *bbs = XNEWVEC (int, last_basic_block + 1); int *bbs = XNEWVEC (int, last_basic_block + 1);
/* Find the loops, so that we can prevent moving calculations in /* Find the loops, so that we can prevent moving calculations in
...@@ -3666,24 +3661,15 @@ init_reassoc (void) ...@@ -3666,24 +3661,15 @@ init_reassoc (void)
bb_rank = XCNEWVEC (long, last_basic_block + 1); bb_rank = XCNEWVEC (long, last_basic_block + 1);
operand_rank = pointer_map_create (); operand_rank = pointer_map_create ();
/* Give each argument a distinct rank. */ /* Give each default definition a distinct rank. This includes
for (param = DECL_ARGUMENTS (current_function_decl); parameters and the static chain. Walk backwards over all
param; SSA names so that we get proper rank ordering according
param = DECL_CHAIN (param)) to tree_swap_operands_p. */
{ for (i = num_ssa_names - 1; i > 0; --i)
if (gimple_default_def (cfun, param) != NULL)
{
tree def = gimple_default_def (cfun, param);
insert_operand_rank (def, ++rank);
}
}
/* Give the chain decl a distinct rank. */
if (cfun->static_chain_decl != NULL)
{ {
tree def = gimple_default_def (cfun, cfun->static_chain_decl); tree name = ssa_name (i);
if (def != NULL) if (name && SSA_NAME_IS_DEFAULT_DEF (name))
insert_operand_rank (def, ++rank); insert_operand_rank (name, ++rank);
} }
/* Set up rank for each BB */ /* Set up rank for each BB */
......
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