Commit d38ffc55 by Jeff Law Committed by Jeff Law

basic-block.h (rediscover_loops_after_threading): Declare.

   * basic-block.h (rediscover_loops_after_threading): Declare.
        * tree-ssa-dom.c: Include cfgloop.h.
        (tree_ssa_dominator_optimize): Discover loops and some basic
        properties.  Remove forwarder blocks recreated by loop header
        canonicalization.  Also mark backedges in the CFG.
        * tree-ssa-threadupdate.c: Include cfgloop.h
        (rediscover_loops_after_threading): Define.
        (struct local_info): New field, JUMP_THREADED.
        (prune_undesirable_thread_requests): New function.
        (redirect_edges): Clear EDGE_ABNORMAL.  If edges were threaded
        then record that fact for the callers of redirct_edges.
        (thread_block): If BB has incoming backedges, then call
        prune_undesirable_thraed_requests.    Note when we are
        going to have to rediscover loop information.  Return a
        boolean indicating if any jumps were threaded.
        (thread_through_all_blocks): Bubble up boolean indicating
        if any jumps were threaded.
        * Makefile.in (tree-ssa-dom.o): Depend on cfgloop.h
        (tree-ssa-threadupdate.o): Similarly.

From-SVN: r95903
parent 3852e8b8
2005-03-04 Jeff Law <law@redhat.com>
* basic-block.h (rediscover_loops_after_threading): Declare.
* tree-ssa-dom.c: Include cfgloop.h.
(tree_ssa_dominator_optimize): Discover loops and some basic
properties. Remove forwarder blocks recreated by loop header
canonicalization. Also mark backedges in the CFG.
* tree-ssa-threadupdate.c: Include cfgloop.h
(rediscover_loops_after_threading): Define.
(struct local_info): New field, JUMP_THREADED.
(prune_undesirable_thread_requests): New function.
(redirect_edges): Clear EDGE_ABNORMAL. If edges were threaded
then record that fact for the callers of redirct_edges.
(thread_block): If BB has incoming backedges, then call
prune_undesirable_thraed_requests. Note when we are
going to have to rediscover loop information. Return a
boolean indicating if any jumps were threaded.
(thread_through_all_blocks): Bubble up boolean indicating
if any jumps were threaded.
* Makefile.in (tree-ssa-dom.o): Depend on cfgloop.h
(tree-ssa-threadupdate.o): Similarly.
2005-03-04 Kazu Hirata <kazu@cs.umass.edu> 2005-03-04 Kazu Hirata <kazu@cs.umass.edu>
* fold-const.c (fold_ternary): Unroll the "for" loop to * fold-const.c (fold_ternary): Unroll the "for" loop to
......
...@@ -1638,11 +1638,11 @@ tree-ssa-dom.o : tree-ssa-dom.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \ ...@@ -1638,11 +1638,11 @@ tree-ssa-dom.o : tree-ssa-dom.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
$(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) output.h diagnostic.h \ $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) output.h diagnostic.h \
errors.h function.h $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) \ errors.h function.h $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) \
$(BASIC_BLOCK_H) domwalk.h real.h tree-pass.h $(FLAGS_H) langhooks.h \ $(BASIC_BLOCK_H) domwalk.h real.h tree-pass.h $(FLAGS_H) langhooks.h \
tree-ssa-propagate.h tree-ssa-propagate.h cfgloop.h
tree-ssa-threadupdate.o : tree-ssa-threadupdate.c $(TREE_FLOW_H) $(CONFIG_H) \ tree-ssa-threadupdate.o : tree-ssa-threadupdate.c $(TREE_FLOW_H) $(CONFIG_H) \
$(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) output.h \ $(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) output.h \
diagnostic.h errors.h function.h $(TM_H) coretypes.h $(TREE_DUMP_H) \ diagnostic.h errors.h function.h $(TM_H) coretypes.h $(TREE_DUMP_H) \
$(BASIC_BLOCK_H) $(FLAGS_H) tree-pass.h $(BASIC_BLOCK_H) $(FLAGS_H) tree-pass.h cfgloop.h
tree-ssanames.o : tree-ssanames.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ tree-ssanames.o : tree-ssanames.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) $(TREE_H) varray.h $(GGC_H) gt-tree-ssanames.h $(TREE_FLOW_H) $(TM_H) $(TREE_H) varray.h $(GGC_H) gt-tree-ssanames.h $(TREE_FLOW_H)
tree-phinodes.o : tree-phinodes.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ tree-phinodes.o : tree-phinodes.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
......
...@@ -352,6 +352,10 @@ extern int last_basic_block; ...@@ -352,6 +352,10 @@ extern int last_basic_block;
extern int n_edges; extern int n_edges;
/* TRUE if we should re-run loop discovery after threading jumps, FALSE
otherwise. */
extern bool rediscover_loops_after_threading;
/* Signalize the status of profile information in the CFG. */ /* Signalize the status of profile information in the CFG. */
extern enum profile_status extern enum profile_status
{ {
......
...@@ -29,6 +29,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -29,6 +29,7 @@ Boston, MA 02111-1307, USA. */
#include "tm_p.h" #include "tm_p.h"
#include "ggc.h" #include "ggc.h"
#include "basic-block.h" #include "basic-block.h"
#include "cfgloop.h"
#include "output.h" #include "output.h"
#include "errors.h" #include "errors.h"
#include "expr.h" #include "expr.h"
...@@ -368,6 +369,7 @@ tree_ssa_dominator_optimize (void) ...@@ -368,6 +369,7 @@ tree_ssa_dominator_optimize (void)
{ {
struct dom_walk_data walk_data; struct dom_walk_data walk_data;
unsigned int i; unsigned int i;
struct loops loops_info;
memset (&opt_stats, 0, sizeof (opt_stats)); memset (&opt_stats, 0, sizeof (opt_stats));
...@@ -407,6 +409,17 @@ tree_ssa_dominator_optimize (void) ...@@ -407,6 +409,17 @@ tree_ssa_dominator_optimize (void)
calculate_dominance_info (CDI_DOMINATORS); calculate_dominance_info (CDI_DOMINATORS);
/* We need to know which edges exit loops so that we can
aggressively thread through loop headers to an exit
edge. */
flow_loops_find (&loops_info);
mark_loop_exit_edges (&loops_info);
flow_loops_free (&loops_info);
/* Clean up the CFG so that any forwarder blocks created by loop
canonicalization are removed. */
cleanup_tree_cfg ();
/* If we prove certain blocks are unreachable, then we want to /* If we prove certain blocks are unreachable, then we want to
repeat the dominator optimization process as PHI nodes may repeat the dominator optimization process as PHI nodes may
have turned into copies which allows better propagation of have turned into copies which allows better propagation of
...@@ -417,6 +430,10 @@ tree_ssa_dominator_optimize (void) ...@@ -417,6 +430,10 @@ tree_ssa_dominator_optimize (void)
/* Optimize the dominator tree. */ /* Optimize the dominator tree. */
cfg_altered = false; cfg_altered = false;
/* We need accurate information regarding back edges in the CFG
for jump threading. */
mark_dfs_back_edges ();
/* Recursively walk the dominator tree optimizing statements. */ /* Recursively walk the dominator tree optimizing statements. */
walk_dominator_tree (&walk_data, ENTRY_BLOCK_PTR); walk_dominator_tree (&walk_data, ENTRY_BLOCK_PTR);
...@@ -445,8 +462,24 @@ tree_ssa_dominator_optimize (void) ...@@ -445,8 +462,24 @@ tree_ssa_dominator_optimize (void)
} }
if (cfg_altered) if (cfg_altered)
free_dominance_info (CDI_DOMINATORS); free_dominance_info (CDI_DOMINATORS);
cfg_altered |= cleanup_tree_cfg (); cfg_altered |= cleanup_tree_cfg ();
if (rediscover_loops_after_threading)
{
/* Rerun basic loop analysis to discover any newly
created loops and update the set of exit edges. */
rediscover_loops_after_threading = false;
flow_loops_find (&loops_info);
mark_loop_exit_edges (&loops_info);
flow_loops_free (&loops_info);
/* Remove any forwarder blocks inserted by loop
header canonicalization. */
cleanup_tree_cfg ();
}
calculate_dominance_info (CDI_DOMINATORS); calculate_dominance_info (CDI_DOMINATORS);
rewrite_ssa_into_ssa (); rewrite_ssa_into_ssa ();
......
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