Commit 3253eafb by Jan Hubicka Committed by Jan Hubicka

tree-ssa-ccp.c (ccp_finalize): Return if something changed.

	* tree-ssa-ccp.c (ccp_finalize): Return if something changed.
	(execute_ssa_ccp): Return flags conditionally.
	* tree-ssa-propagate.c (substitue_and_fold): Return if something was
	changed.
	* tree-ssa-propagate.h (substitute_and_fold): Update prototype.

From-SVN: r120894
parent aeceeb06
18-01-2007 Jan Hubicka <jh@suse.cz>
* tree-ssa-ccp.c (ccp_finalize): Return if something changed.
(execute_ssa_ccp): Return flags conditionally.
* tree-ssa-propagate.c (substitue_and_fold): Return if something was
changed.
* tree-ssa-propagate.h (substitute_and_fold): Update prototype.
18-01-2007 Steven Bosscher <steven@gcc.gnu.org> 18-01-2007 Steven Bosscher <steven@gcc.gnu.org>
* cfgcleanup.c (cleanup_cfg): Detect cfglayout mode and set * cfgcleanup.c (cleanup_cfg): Detect cfglayout mode and set
......
...@@ -665,15 +665,18 @@ ccp_initialize (void) ...@@ -665,15 +665,18 @@ ccp_initialize (void)
/* Do final substitution of propagated values, cleanup the flowgraph and /* Do final substitution of propagated values, cleanup the flowgraph and
free allocated storage. */ free allocated storage.
static void Return TRUE when something was optimized. */
static bool
ccp_finalize (void) ccp_finalize (void)
{ {
/* Perform substitutions based on the known constant values. */ /* Perform substitutions based on the known constant values. */
substitute_and_fold (const_val, false); bool something_changed = substitute_and_fold (const_val, false);
free (const_val); free (const_val);
return something_changed;;
} }
...@@ -1397,21 +1400,24 @@ ccp_visit_stmt (tree stmt, edge *taken_edge_p, tree *output_p) ...@@ -1397,21 +1400,24 @@ ccp_visit_stmt (tree stmt, edge *taken_edge_p, tree *output_p)
/* Main entry point for SSA Conditional Constant Propagation. */ /* Main entry point for SSA Conditional Constant Propagation. */
static void static unsigned int
execute_ssa_ccp (bool store_ccp) execute_ssa_ccp (bool store_ccp)
{ {
do_store_ccp = store_ccp; do_store_ccp = store_ccp;
ccp_initialize (); ccp_initialize ();
ssa_propagate (ccp_visit_stmt, ccp_visit_phi_node); ssa_propagate (ccp_visit_stmt, ccp_visit_phi_node);
ccp_finalize (); if (ccp_finalize ())
return (TODO_cleanup_cfg | TODO_update_ssa | TODO_update_smt_usage
| TODO_remove_unused_locals);
else
return 0;
} }
static unsigned int static unsigned int
do_ssa_ccp (void) do_ssa_ccp (void)
{ {
execute_ssa_ccp (false); return execute_ssa_ccp (false);
return 0;
} }
...@@ -1435,13 +1441,8 @@ struct tree_opt_pass pass_ccp = ...@@ -1435,13 +1441,8 @@ struct tree_opt_pass pass_ccp =
0, /* properties_provided */ 0, /* properties_provided */
0, /* properties_destroyed */ 0, /* properties_destroyed */
0, /* todo_flags_start */ 0, /* todo_flags_start */
TODO_cleanup_cfg TODO_dump_func | TODO_verify_ssa
| TODO_dump_func | TODO_verify_stmts | TODO_ggc_collect,/* todo_flags_finish */
| TODO_update_ssa
| TODO_ggc_collect
| TODO_verify_ssa
| TODO_verify_stmts
| TODO_update_smt_usage, /* todo_flags_finish */
0 /* letter */ 0 /* letter */
}; };
...@@ -1450,8 +1451,7 @@ static unsigned int ...@@ -1450,8 +1451,7 @@ static unsigned int
do_ssa_store_ccp (void) do_ssa_store_ccp (void)
{ {
/* If STORE-CCP is not enabled, we just run regular CCP. */ /* If STORE-CCP is not enabled, we just run regular CCP. */
execute_ssa_ccp (flag_tree_store_ccp != 0); return execute_ssa_ccp (flag_tree_store_ccp != 0);
return 0;
} }
static bool static bool
...@@ -1477,13 +1477,8 @@ struct tree_opt_pass pass_store_ccp = ...@@ -1477,13 +1477,8 @@ struct tree_opt_pass pass_store_ccp =
0, /* properties_provided */ 0, /* properties_provided */
0, /* properties_destroyed */ 0, /* properties_destroyed */
0, /* todo_flags_start */ 0, /* todo_flags_start */
TODO_dump_func TODO_dump_func | TODO_verify_ssa
| TODO_update_ssa | TODO_verify_stmts | TODO_ggc_collect,/* todo_flags_finish */
| TODO_ggc_collect
| TODO_verify_ssa
| TODO_cleanup_cfg
| TODO_verify_stmts
| TODO_update_smt_usage, /* todo_flags_finish */
0 /* letter */ 0 /* letter */
}; };
......
...@@ -1137,15 +1137,18 @@ fold_predicate_in (tree stmt) ...@@ -1137,15 +1137,18 @@ fold_predicate_in (tree stmt)
expressions are evaluated with a call to vrp_evaluate_conditional. expressions are evaluated with a call to vrp_evaluate_conditional.
This will only give meaningful results when called from tree-vrp.c This will only give meaningful results when called from tree-vrp.c
(the information used by vrp_evaluate_conditional is built by the (the information used by vrp_evaluate_conditional is built by the
VRP pass). */ VRP pass).
void Return TRUE when something changed. */
bool
substitute_and_fold (prop_value_t *prop_value, bool use_ranges_p) substitute_and_fold (prop_value_t *prop_value, bool use_ranges_p)
{ {
basic_block bb; basic_block bb;
bool something_changed = false;
if (prop_value == NULL && !use_ranges_p) if (prop_value == NULL && !use_ranges_p)
return; return false;
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "\nSubstituing values and folding statements\n\n"); fprintf (dump_file, "\nSubstituing values and folding statements\n\n");
...@@ -1234,6 +1237,7 @@ substitute_and_fold (prop_value_t *prop_value, bool use_ranges_p) ...@@ -1234,6 +1237,7 @@ substitute_and_fold (prop_value_t *prop_value, bool use_ranges_p)
/* Determine what needs to be done to update the SSA form. */ /* Determine what needs to be done to update the SSA form. */
pop_stmt_changes (bsi_stmt_ptr (i)); pop_stmt_changes (bsi_stmt_ptr (i));
something_changed = true;
} }
else else
{ {
...@@ -1261,6 +1265,7 @@ substitute_and_fold (prop_value_t *prop_value, bool use_ranges_p) ...@@ -1261,6 +1265,7 @@ substitute_and_fold (prop_value_t *prop_value, bool use_ranges_p)
fprintf (dump_file, "Predicates folded: %6ld\n", fprintf (dump_file, "Predicates folded: %6ld\n",
prop_stats.num_pred_folded); prop_stats.num_pred_folded);
} }
return something_changed;
} }
#include "gt-tree-ssa-propagate.h" #include "gt-tree-ssa-propagate.h"
...@@ -120,6 +120,6 @@ bool stmt_makes_single_load (tree); ...@@ -120,6 +120,6 @@ bool stmt_makes_single_load (tree);
bool stmt_makes_single_store (tree); bool stmt_makes_single_store (tree);
prop_value_t *get_value_loaded_by (tree, prop_value_t *); prop_value_t *get_value_loaded_by (tree, prop_value_t *);
bool replace_uses_in (tree, bool *, prop_value_t *); bool replace_uses_in (tree, bool *, prop_value_t *);
void substitute_and_fold (prop_value_t *, bool); bool substitute_and_fold (prop_value_t *, bool);
#endif /* _TREE_SSA_PROPAGATE_H */ #endif /* _TREE_SSA_PROPAGATE_H */
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