Commit c0e50f72 by Richard Biener Committed by Richard Biener

tree-call-cdce.c (tree_call_cdce): Do not remove unused locals.

2013-02-20  Richard Biener  <rguenther@suse.de>

	* tree-call-cdce.c (tree_call_cdce): Do not remove unused locals.
	* tree-ssa-forwprop.c (ssa_forward_propagate_and_combine): Likewise.
	* tree-ssa-dce.c (perform_tree_ssa_dce): Likewise.
	* tree-ssa-copyrename.c (copy_rename_partition_coalesce): Do
	not return anything.
	(rename_ssa_copies): Do not remove unused locals.
	* tree-ssa-ccp.c (do_ssa_ccp): Likewise.
	* tree-ssanames.c (pass_release_ssa_names): Remove unused
	locals first.
	* passes.c (execute_function_todo): Do not schedule unused locals
	removal if cleanup_tree_cfg did something.
	* tree-ssa-live.c (remove_unused_locals): Dump statistics
	about the number of removed locals.

	* gcc.dg/tree-ssa/forwprop-8.c: Adjust.

From-SVN: r196174
parent a52ca739
2013-02-20 Richard Biener <rguenther@suse.de> 2013-02-20 Richard Biener <rguenther@suse.de>
* tree-call-cdce.c (tree_call_cdce): Do not remove unused locals.
* tree-ssa-forwprop.c (ssa_forward_propagate_and_combine): Likewise.
* tree-ssa-dce.c (perform_tree_ssa_dce): Likewise.
* tree-ssa-copyrename.c (copy_rename_partition_coalesce): Do
not return anything.
(rename_ssa_copies): Do not remove unused locals.
* tree-ssa-ccp.c (do_ssa_ccp): Likewise.
* tree-ssanames.c (pass_release_ssa_names): Remove unused
locals first.
* passes.c (execute_function_todo): Do not schedule unused locals
removal if cleanup_tree_cfg did something.
* tree-ssa-live.c (remove_unused_locals): Dump statistics
about the number of removed locals.
2013-02-20 Richard Biener <rguenther@suse.de>
PR tree-optimization/56398 PR tree-optimization/56398
* tree-vect-loop-manip.c (adjust_debug_stmts): Skip * tree-vect-loop-manip.c (adjust_debug_stmts): Skip
SSA default defs. SSA default defs.
......
...@@ -1918,10 +1918,7 @@ execute_function_todo (void *data) ...@@ -1918,10 +1918,7 @@ execute_function_todo (void *data)
/* Always cleanup the CFG before trying to update SSA. */ /* Always cleanup the CFG before trying to update SSA. */
if (flags & TODO_cleanup_cfg) if (flags & TODO_cleanup_cfg)
{ {
bool cleanup = cleanup_tree_cfg (); cleanup_tree_cfg ();
if (cleanup && (cfun->curr_properties & PROP_ssa))
flags |= TODO_remove_unused_locals;
/* When cleanup_tree_cfg merges consecutive blocks, it may /* When cleanup_tree_cfg merges consecutive blocks, it may
perform some simplistic propagation when removing single perform some simplistic propagation when removing single
......
2013-02-20 Richard Biener <rguenther@suse.de> 2013-02-20 Richard Biener <rguenther@suse.de>
* gcc.dg/tree-ssa/forwprop-8.c: Adjust.
2013-02-20 Richard Biener <rguenther@suse.de>
Jakub Jelinek <jakub@redhat.com> Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/56396 PR tree-optimization/56396
......
...@@ -11,6 +11,5 @@ int foo(struct X *q) ...@@ -11,6 +11,5 @@ int foo(struct X *q)
/* We should have propragated &q->a into (*pointer). */ /* We should have propragated &q->a into (*pointer). */
/* { dg-final { scan-tree-dump-times "pointer" 0 "forwprop1"} } */ /* { dg-final { scan-tree-dump "q_.\\\(D\\\)\\\]\\\[0\\\];" "forwprop1" } } */
/* { dg-final { scan-tree-dump "\\\[0\\\]" "forwprop1" } } */
/* { dg-final { cleanup-tree-dump "forwprop1" } } */ /* { dg-final { cleanup-tree-dump "forwprop1" } } */
...@@ -898,11 +898,10 @@ tree_call_cdce (void) ...@@ -898,11 +898,10 @@ tree_call_cdce (void)
/* As we introduced new control-flow we need to insert PHI-nodes /* As we introduced new control-flow we need to insert PHI-nodes
for the call-clobbers of the remaining call. */ for the call-clobbers of the remaining call. */
mark_virtual_operands_for_renaming (cfun); mark_virtual_operands_for_renaming (cfun);
return (TODO_update_ssa | TODO_cleanup_cfg | TODO_ggc_collect return TODO_update_ssa;
| TODO_remove_unused_locals);
} }
else
return 0; return 0;
} }
static bool static bool
......
...@@ -2108,7 +2108,7 @@ do_ssa_ccp (void) ...@@ -2108,7 +2108,7 @@ do_ssa_ccp (void)
ccp_initialize (); ccp_initialize ();
ssa_propagate (ccp_visit_stmt, ccp_visit_phi_node); ssa_propagate (ccp_visit_stmt, ccp_visit_phi_node);
if (ccp_finalize ()) if (ccp_finalize ())
todo = (TODO_cleanup_cfg | TODO_update_ssa | TODO_remove_unused_locals); todo = (TODO_cleanup_cfg | TODO_update_ssa);
free_dominance_info (CDI_DOMINATORS); free_dominance_info (CDI_DOMINATORS);
return todo; return todo;
} }
......
...@@ -113,7 +113,7 @@ static struct ...@@ -113,7 +113,7 @@ static struct
/* Coalesce the partitions in MAP representing VAR1 and VAR2 if it is valid. /* Coalesce the partitions in MAP representing VAR1 and VAR2 if it is valid.
Choose a representative for the partition, and send debug info to DEBUG. */ Choose a representative for the partition, and send debug info to DEBUG. */
static bool static void
copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug) copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug)
{ {
int p1, p2, p3; int p1, p2, p3;
...@@ -146,7 +146,7 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug) ...@@ -146,7 +146,7 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug)
{ {
if (debug) if (debug)
fprintf (debug, " : Already coalesced.\n"); fprintf (debug, " : Already coalesced.\n");
return false; return;
} }
rep1 = partition_to_var (map, p1); rep1 = partition_to_var (map, p1);
...@@ -154,7 +154,7 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug) ...@@ -154,7 +154,7 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug)
root1 = SSA_NAME_VAR (rep1); root1 = SSA_NAME_VAR (rep1);
root2 = SSA_NAME_VAR (rep2); root2 = SSA_NAME_VAR (rep2);
if (!root1 && !root2) if (!root1 && !root2)
return false; return;
/* Don't coalesce if one of the variables occurs in an abnormal PHI. */ /* Don't coalesce if one of the variables occurs in an abnormal PHI. */
abnorm = (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rep1) abnorm = (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rep1)
...@@ -163,7 +163,7 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug) ...@@ -163,7 +163,7 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug)
{ {
if (debug) if (debug)
fprintf (debug, " : Abnormal PHI barrier. No coalesce.\n"); fprintf (debug, " : Abnormal PHI barrier. No coalesce.\n");
return false; return;
} }
/* Partitions already have the same root, simply merge them. */ /* Partitions already have the same root, simply merge them. */
...@@ -172,7 +172,7 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug) ...@@ -172,7 +172,7 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug)
p1 = partition_union (map->var_partition, p1, p2); p1 = partition_union (map->var_partition, p1, p2);
if (debug) if (debug)
fprintf (debug, " : Same root, coalesced --> P%d.\n", p1); fprintf (debug, " : Same root, coalesced --> P%d.\n", p1);
return false; return;
} }
/* Never attempt to coalesce 2 different parameters. */ /* Never attempt to coalesce 2 different parameters. */
...@@ -181,7 +181,7 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug) ...@@ -181,7 +181,7 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug)
{ {
if (debug) if (debug)
fprintf (debug, " : 2 different PARM_DECLS. No coalesce.\n"); fprintf (debug, " : 2 different PARM_DECLS. No coalesce.\n");
return false; return;
} }
if ((root1 && TREE_CODE (root1) == RESULT_DECL) if ((root1 && TREE_CODE (root1) == RESULT_DECL)
...@@ -189,7 +189,7 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug) ...@@ -189,7 +189,7 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug)
{ {
if (debug) if (debug)
fprintf (debug, " : One root a RESULT_DECL. No coalesce.\n"); fprintf (debug, " : One root a RESULT_DECL. No coalesce.\n");
return false; return;
} }
ign1 = !root1 || (TREE_CODE (root1) == VAR_DECL && DECL_IGNORED_P (root1)); ign1 = !root1 || (TREE_CODE (root1) == VAR_DECL && DECL_IGNORED_P (root1));
...@@ -206,7 +206,7 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug) ...@@ -206,7 +206,7 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug)
{ {
if (debug) if (debug)
fprintf (debug, " : 2 different USER vars. No coalesce.\n"); fprintf (debug, " : 2 different USER vars. No coalesce.\n");
return false; return;
} }
else else
ign2 = true; ign2 = true;
...@@ -220,7 +220,7 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug) ...@@ -220,7 +220,7 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug)
{ {
if (debug) if (debug)
fprintf (debug, " : 2 default defs. No coalesce.\n"); fprintf (debug, " : 2 default defs. No coalesce.\n");
return false; return;
} }
else else
{ {
...@@ -240,7 +240,7 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug) ...@@ -240,7 +240,7 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug)
{ {
if (debug) if (debug)
fprintf (debug, " : Choosen variable has no root. No coalesce.\n"); fprintf (debug, " : Choosen variable has no root. No coalesce.\n");
return false; return;
} }
/* Don't coalesce if the new chosen root variable would be read-only. /* Don't coalesce if the new chosen root variable would be read-only.
...@@ -253,7 +253,7 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug) ...@@ -253,7 +253,7 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug)
{ {
if (debug) if (debug)
fprintf (debug, " : Readonly variable. No coalesce.\n"); fprintf (debug, " : Readonly variable. No coalesce.\n");
return false; return;
} }
/* Don't coalesce if the two variables aren't type compatible . */ /* Don't coalesce if the two variables aren't type compatible . */
...@@ -266,7 +266,7 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug) ...@@ -266,7 +266,7 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug)
{ {
if (debug) if (debug)
fprintf (debug, " : Incompatible types. No coalesce.\n"); fprintf (debug, " : Incompatible types. No coalesce.\n");
return false; return;
} }
/* Merge the two partitions. */ /* Merge the two partitions. */
...@@ -288,7 +288,6 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug) ...@@ -288,7 +288,6 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug)
TDF_SLIM); TDF_SLIM);
fprintf (debug, "\n"); fprintf (debug, "\n");
} }
return true;
} }
...@@ -308,7 +307,6 @@ rename_ssa_copies (void) ...@@ -308,7 +307,6 @@ rename_ssa_copies (void)
gimple stmt, phi; gimple stmt, phi;
unsigned x; unsigned x;
FILE *debug; FILE *debug;
bool updated = false;
memset (&stats, 0, sizeof (stats)); memset (&stats, 0, sizeof (stats));
...@@ -330,7 +328,7 @@ rename_ssa_copies (void) ...@@ -330,7 +328,7 @@ rename_ssa_copies (void)
tree lhs = gimple_assign_lhs (stmt); tree lhs = gimple_assign_lhs (stmt);
tree rhs = gimple_assign_rhs1 (stmt); tree rhs = gimple_assign_rhs1 (stmt);
updated |= copy_rename_partition_coalesce (map, lhs, rhs, debug); copy_rename_partition_coalesce (map, lhs, rhs, debug);
} }
} }
} }
...@@ -358,8 +356,8 @@ rename_ssa_copies (void) ...@@ -358,8 +356,8 @@ rename_ssa_copies (void)
{ {
tree arg = PHI_ARG_DEF (phi, i); tree arg = PHI_ARG_DEF (phi, i);
if (TREE_CODE (arg) == SSA_NAME) if (TREE_CODE (arg) == SSA_NAME)
updated |= copy_rename_partition_coalesce (map, res, arg, copy_rename_partition_coalesce (map, res, arg,
debug); debug);
} }
/* Else if all arguments are in the same partition try to merge /* Else if all arguments are in the same partition try to merge
it with the result. */ it with the result. */
...@@ -390,9 +388,9 @@ rename_ssa_copies (void) ...@@ -390,9 +388,9 @@ rename_ssa_copies (void)
} }
} }
if (all_p_same == 1) if (all_p_same == 1)
updated |= copy_rename_partition_coalesce (map, res, copy_rename_partition_coalesce (map, res,
PHI_ARG_DEF (phi, 0), PHI_ARG_DEF (phi, 0),
debug); debug);
} }
} }
} }
...@@ -426,7 +424,7 @@ rename_ssa_copies (void) ...@@ -426,7 +424,7 @@ rename_ssa_copies (void)
statistics_counter_event (cfun, "copies coalesced", statistics_counter_event (cfun, "copies coalesced",
stats.coalesced); stats.coalesced);
delete_var_map (map); delete_var_map (map);
return updated ? TODO_remove_unused_locals : 0; return 0;
} }
/* Return true if copy rename is to be performed. */ /* Return true if copy rename is to be performed. */
......
...@@ -1607,10 +1607,8 @@ perform_tree_ssa_dce (bool aggressive) ...@@ -1607,10 +1607,8 @@ perform_tree_ssa_dce (bool aggressive)
free_edge_list (el); free_edge_list (el);
if (something_changed) if (something_changed)
return (TODO_update_ssa | TODO_cleanup_cfg | TODO_ggc_collect return TODO_update_ssa | TODO_cleanup_cfg;
| TODO_remove_unused_locals); return 0;
else
return 0;
} }
/* Pass entry points. */ /* Pass entry points. */
......
...@@ -2936,7 +2936,6 @@ ssa_forward_propagate_and_combine (void) ...@@ -2936,7 +2936,6 @@ ssa_forward_propagate_and_combine (void)
&& forward_propagate_addr_expr (lhs, rhs)) && forward_propagate_addr_expr (lhs, rhs))
{ {
release_defs (stmt); release_defs (stmt);
todoflags |= TODO_remove_unused_locals;
gsi_remove (&gsi, true); gsi_remove (&gsi, true);
} }
else else
...@@ -2961,7 +2960,6 @@ ssa_forward_propagate_and_combine (void) ...@@ -2961,7 +2960,6 @@ ssa_forward_propagate_and_combine (void)
off))))) off)))))
{ {
release_defs (stmt); release_defs (stmt);
todoflags |= TODO_remove_unused_locals;
gsi_remove (&gsi, true); gsi_remove (&gsi, true);
} }
else if (is_gimple_min_invariant (rhs)) else if (is_gimple_min_invariant (rhs))
......
...@@ -889,7 +889,10 @@ remove_unused_locals (void) ...@@ -889,7 +889,10 @@ remove_unused_locals (void)
dstidx++; dstidx++;
} }
if (dstidx != num) if (dstidx != num)
cfun->local_decls->truncate (dstidx); {
statistics_counter_event (cfun, "unused VAR_DECLs removed", num - dstidx);
cfun->local_decls->truncate (dstidx);
}
remove_unused_scope_block_p (DECL_INITIAL (current_function_decl)); remove_unused_scope_block_p (DECL_INITIAL (current_function_decl));
clear_unused_block_pointer (); clear_unused_block_pointer ();
......
...@@ -455,7 +455,7 @@ struct gimple_opt_pass pass_release_ssa_names = ...@@ -455,7 +455,7 @@ struct gimple_opt_pass pass_release_ssa_names =
PROP_ssa, /* properties_required */ PROP_ssa, /* properties_required */
0, /* properties_provided */ 0, /* properties_provided */
0, /* properties_destroyed */ 0, /* properties_destroyed */
0, /* todo_flags_start */ TODO_remove_unused_locals, /* todo_flags_start */
0 /* todo_flags_finish */ 0 /* todo_flags_finish */
} }
}; };
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