aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Hayes <mhayes@redhat.com>2001-01-09 10:25:44 +0000
committerMichael Hayes <m.hayes@gcc.gnu.org>2001-01-09 10:25:44 +0000
commiteab02febcf4cd68c278d8c517d131d3f7a50933f (patch)
treea15d6fb57cb13bc26a6ce53829f8821e926dd07f
parent4b49c3657f581b4f484f7dd380d174a95449cdd1 (diff)
downloadgcc-eab02febcf4cd68c278d8c517d131d3f7a50933f.zip
gcc-eab02febcf4cd68c278d8c517d131d3f7a50933f.tar.gz
gcc-eab02febcf4cd68c278d8c517d131d3f7a50933f.tar.bz2
flow.c (flow_loop_scan): Break out of ...
* flow.c (flow_loop_scan): Break out of ... (flow_loops_find) ... here. * basic-block.h (flow_loop_scan): New. (LOOP_ENTRY_EDGES, LOOP_EXIT_EDGES): Add. (LOOP_EDGES, LOOP_EXITS_DOMS, LOOP_ALL): Redefine. From-SVN: r38822
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/basic-block.h9
-rw-r--r--gcc/flow.c113
3 files changed, 84 insertions, 46 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5bc2e8a..81c6a01 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2001-01-09 Michael Hayes <mhayes@redhat.com>
+
+ * flow.c (flow_loop_scan): Break out of ...
+ (flow_loops_find) ... here.
+ * basic-block.h (flow_loop_scan): New.
+ (LOOP_ENTRY_EDGES, LOOP_EXIT_EDGES): Add.
+ (LOOP_EDGES, LOOP_EXITS_DOMS, LOOP_ALL): Redefine.
+
2001-01-09 Alexandre Oliva <aoliva@redhat.com>
* cppinit.c (cpp_cleanup): NULLify macro_buffer and zero
diff --git a/gcc/basic-block.h b/gcc/basic-block.h
index f86ff3c..c48a547 100644
--- a/gcc/basic-block.h
+++ b/gcc/basic-block.h
@@ -428,6 +428,7 @@ extern void flow_loops_dump PARAMS ((const struct loops *, FILE *,
extern void flow_loop_dump PARAMS ((const struct loop *, FILE *,
void (*)(const struct loop *,
FILE *, int), int));
+extern int flow_loop_scan PARAMS ((struct loops *, struct loop *, int));
/* This structure maintains an edge list vector. */
struct edge_list
@@ -485,9 +486,11 @@ enum update_life_extent
#define LOOP_TREE 1 /* Build loop hierarchy tree. */
#define LOOP_PRE_HEADER 2 /* Analyse loop pre-header. */
-#define LOOP_EDGES 4 /* Find entry and exit edges. */
-#define LOOP_EXITS_DOMS 8 /* Find nodes that dom. all exits. */
-#define LOOP_ALL 15 /* All of the above */
+#define LOOP_ENTRY_EDGES 4 /* Find entry edges. */
+#define LOOP_EXIT_EDGES 8 /* Find exit edges. */
+#define LOOP_EDGES (LOOP_ENTRY_EDGES | LOOP_EXIT_EDGES)
+#define LOOP_EXITS_DOMS 16 /* Find nodes that dom. all exits. */
+#define LOOP_ALL 31 /* All of the above */
extern void life_analysis PARAMS ((rtx, FILE *, int));
extern void update_life_info PARAMS ((sbitmap, enum update_life_extent,
diff --git a/gcc/flow.c b/gcc/flow.c
index a53043d..faed23f 100644
--- a/gcc/flow.c
+++ b/gcc/flow.c
@@ -8137,6 +8137,70 @@ flow_loops_level_compute (loops)
}
+/* Scan a single natural loop specified by LOOP collecting information
+ about it specified by FLAGS. */
+
+int
+flow_loop_scan (loops, loop, flags)
+ struct loops *loops;
+ struct loop *loop;
+ int flags;
+{
+ /* Determine prerequisites. */
+ if ((flags & LOOP_EXITS_DOMS) && ! loop->exit_edges)
+ flags |= LOOP_EXIT_EDGES;
+
+ if (flags & LOOP_ENTRY_EDGES)
+ {
+ /* Find edges which enter the loop header.
+ Note that the entry edges should only
+ enter the header of a natural loop. */
+ loop->num_entries
+ = flow_loop_entry_edges_find (loop->header,
+ loop->nodes,
+ &loop->entry_edges);
+ }
+
+ if (flags & LOOP_EXIT_EDGES)
+ {
+ /* Find edges which exit the loop. */
+ loop->num_exits
+ = flow_loop_exit_edges_find (loop->nodes,
+ &loop->exit_edges);
+ }
+
+ if (flags & LOOP_EXITS_DOMS)
+ {
+ int j;
+
+ /* Determine which loop nodes dominate all the exits
+ of the loop. */
+ loop->exits_doms = sbitmap_alloc (n_basic_blocks);
+ sbitmap_copy (loop->exits_doms, loop->nodes);
+ for (j = 0; j < loop->num_exits; j++)
+ sbitmap_a_and_b (loop->exits_doms, loop->exits_doms,
+ loops->cfg.dom[loop->exit_edges[j]->src->index]);
+
+ /* The header of a natural loop must dominate
+ all exits. */
+ if (! TEST_BIT (loop->exits_doms, loop->header->index))
+ abort ();
+ }
+
+ if (flags & LOOP_PRE_HEADER)
+ {
+ /* Look to see if the loop has a pre-header node. */
+ loop->pre_header
+ = flow_loop_pre_header_find (loop->header, loops->cfg.dom);
+
+ /* Find the blocks within the extended basic block of
+ the loop pre-header. */
+ flow_loop_pre_header_scan (loop);
+ }
+ return 1;
+}
+
+
/* Find all the natural loops in the function and save in LOOPS structure
and recalculate loop_depth information in basic block structures.
FLAGS controls which loop information is collected.
@@ -8213,6 +8277,11 @@ flow_loops_find (loops, flags)
rc_order = (int *) xmalloc (n_basic_blocks * sizeof (int));
flow_depth_first_order_compute (dfs_order, rc_order);
+ /* Save CFG derived information to avoid recomputing it. */
+ loops->cfg.dom = dom;
+ loops->cfg.dfs_order = dfs_order;
+ loops->cfg.rc_order = rc_order;
+
/* Allocate loop structures. */
loops->array
= (struct loop *) xcalloc (num_loops, sizeof (struct loop));
@@ -8264,7 +8333,6 @@ flow_loops_find (loops, flags)
for (i = 0; i < num_loops; i++)
{
struct loop *loop = &loops->array[i];
- int j;
/* Keep track of blocks that are loop headers so
that we can tell which loops should be merged. */
@@ -8286,43 +8354,7 @@ flow_loops_find (loops, flags)
loop->last
= BASIC_BLOCK (sbitmap_last_set_bit (loop->nodes));
- if (flags & LOOP_EDGES)
- {
- /* Find edges which enter the loop header.
- Note that the entry edges should only
- enter the header of a natural loop. */
- loop->num_entries
- = flow_loop_entry_edges_find (loop->header,
- loop->nodes,
- &loop->entry_edges);
-
- /* Find edges which exit the loop. */
- loop->num_exits
- = flow_loop_exit_edges_find (loop->nodes,
- &loop->exit_edges);
-
- /* Determine which loop nodes dominate all the exits
- of the loop. */
- loop->exits_doms = sbitmap_alloc (n_basic_blocks);
- sbitmap_copy (loop->exits_doms, loop->nodes);
- for (j = 0; j < loop->num_exits; j++)
- sbitmap_a_and_b (loop->exits_doms, loop->exits_doms,
- dom[loop->exit_edges[j]->src->index]);
-
- /* The header of a natural loop must dominate
- all exits. */
- if (! TEST_BIT (loop->exits_doms, loop->header->index))
- abort ();
- }
-
- if (flags & LOOP_PRE_HEADER)
- {
- /* Look to see if the loop has a pre-header node. */
- loop->pre_header
- = flow_loop_pre_header_find (loop->header, dom);
-
- flow_loop_pre_header_scan (loop);
- }
+ flow_loop_scan (loops, loop, flags);
}
/* Natural loops with shared headers may either be disjoint or
@@ -8338,11 +8370,6 @@ flow_loops_find (loops, flags)
loops->num = num_loops;
- /* Save CFG derived information to avoid recomputing it. */
- loops->cfg.dom = dom;
- loops->cfg.dfs_order = dfs_order;
- loops->cfg.rc_order = rc_order;
-
/* Build the loop hierarchy tree. */
flow_loops_tree_build (loops);