Commit 9ba025a2 by Zdenek Dvorak Committed by Zdenek Dvorak

tree-loop-linear.c (gather_interchange_stats, [...]): Use loop_depth and…

tree-loop-linear.c (gather_interchange_stats, [...]): Use loop_depth and loop_outer accessor functions.

	* tree-loop-linear.c (gather_interchange_stats, try_interchange_loops):
	Use loop_depth and loop_outer accessor functions.
	* tree-ssa-loop-im.c (outermost_invariant_loop, set_level,
	determine_invariantness_stmt, move_computations_stmt): Ditto.
	* cfgloopmanip.c (fix_bb_placement, fix_loop_placement, remove_path,
	add_loop, loopify, unloop, fix_loop_structure): Ditto.
	* tree-ssa-loop-manip.c (find_uses_to_rename_use): Ditto.
	* tree-scalar-evolution.c (interpret_loop_phi,
	compute_scalar_evolution_in_loop, analyze_scalar_evolution_in_loop,
	instantiate_parameters_1, scev_const_prop): Ditto.
	* cfghooks.c (make_forwarder_block): Ditto.
	* cfgloopanal.c (mark_irreducible_loops, mark_loop_exit_edges): Ditto.
	* modulo-sched.c (loop_canon_p): Ditto.
	* tree-vectorizer.c (slpeel_tree_duplicate_loop_to_edge_cfg,
	slpeel_can_duplicate_loop_p): Ditto.
	* lambda-code.c (invariant_in_loop_and_outer_loops): Ditto.
	* tree-cfg.c (tree_duplicate_sese_region): Ditto.
	* cfgloop.c (flow_loop_dump, flow_loop_nodes_find, rescan_loop_exit,
	cancel_loop, verify_loop_structure): Ditto.
	(flow_loop_nested_p, superloop_at_depth, flow_loop_free,
	add_bb_to_loop, remove_bb_from_loops, find_common_loop): Use the
	superloops vector instead of "pred" array.
	(establish_preds): Take father loop as an argument.  Initialize the
	superloops vector.
	(flow_loop_tree_node_add): Pass father loop to establish_preds.  Do not
	initialize loop->outer.
	(flow_loop_tree_node_remove): Truncate the superloops vector.
	* cfgloop.h (struct loop): Removed field "outer", fields "depth" and
	"pred" merged to "superloops" vector.
	(loop_depth, loop_outer): New.
	(fel_init): Use loop_outer.

From-SVN: r124619
parent 7be82279
2007-05-11 Zdenek Dvorak <dvorakz@suse.cz>
* tree-loop-linear.c (gather_interchange_stats, try_interchange_loops):
Use loop_depth and loop_outer accessor functions.
* tree-ssa-loop-im.c (outermost_invariant_loop, set_level,
determine_invariantness_stmt, move_computations_stmt): Ditto.
* cfgloopmanip.c (fix_bb_placement, fix_loop_placement, remove_path,
add_loop, loopify, unloop, fix_loop_structure): Ditto.
* tree-ssa-loop-manip.c (find_uses_to_rename_use): Ditto.
* tree-scalar-evolution.c (interpret_loop_phi,
compute_scalar_evolution_in_loop, analyze_scalar_evolution_in_loop,
instantiate_parameters_1, scev_const_prop): Ditto.
* cfghooks.c (make_forwarder_block): Ditto.
* cfgloopanal.c (mark_irreducible_loops, mark_loop_exit_edges): Ditto.
* modulo-sched.c (loop_canon_p): Ditto.
* tree-vectorizer.c (slpeel_tree_duplicate_loop_to_edge_cfg,
slpeel_can_duplicate_loop_p): Ditto.
* lambda-code.c (invariant_in_loop_and_outer_loops): Ditto.
* tree-cfg.c (tree_duplicate_sese_region): Ditto.
* cfgloop.c (flow_loop_dump, flow_loop_nodes_find, rescan_loop_exit,
cancel_loop, verify_loop_structure): Ditto.
(flow_loop_nested_p, superloop_at_depth, flow_loop_free,
add_bb_to_loop, remove_bb_from_loops, find_common_loop): Use the
superloops vector instead of "pred" array.
(establish_preds): Take father loop as an argument. Initialize the
superloops vector.
(flow_loop_tree_node_add): Pass father loop to establish_preds. Do not
initialize loop->outer.
(flow_loop_tree_node_remove): Truncate the superloops vector.
* cfgloop.h (struct loop): Removed field "outer", fields "depth" and
"pred" merged to "superloops" vector.
(loop_depth, loop_outer): New.
(fel_init): Use loop_outer.
2007-05-11 Jan Hubicka <jh@suse.cz> 2007-05-11 Jan Hubicka <jh@suse.cz>
* cgraphunit.c: Include gt-cgraphunit.h * cgraphunit.c: Include gt-cgraphunit.h
......
...@@ -767,7 +767,7 @@ make_forwarder_block (basic_block bb, bool (*redirect_edge_p) (edge), ...@@ -767,7 +767,7 @@ make_forwarder_block (basic_block bb, bool (*redirect_edge_p) (edge),
} }
/* In case we split loop latch, update it. */ /* In case we split loop latch, update it. */
for (ploop = loop; ploop; ploop = ploop->outer) for (ploop = loop; ploop; ploop = loop_outer (ploop))
if (ploop->latch == dummy) if (ploop->latch == dummy)
ploop->latch = bb; ploop->latch = bb;
} }
......
...@@ -36,7 +36,6 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA ...@@ -36,7 +36,6 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
#include "output.h" #include "output.h"
static void flow_loops_cfg_dump (FILE *); static void flow_loops_cfg_dump (FILE *);
static void establish_preds (struct loop *);
/* Dump loop related CFG information. */ /* Dump loop related CFG information. */
...@@ -65,8 +64,10 @@ flow_loops_cfg_dump (FILE *file) ...@@ -65,8 +64,10 @@ flow_loops_cfg_dump (FILE *file)
bool bool
flow_loop_nested_p (const struct loop *outer, const struct loop *loop) flow_loop_nested_p (const struct loop *outer, const struct loop *loop)
{ {
return (loop->depth > outer->depth unsigned odepth = loop_depth (outer);
&& loop->pred[outer->depth] == outer);
return (loop_depth (loop) > odepth
&& VEC_index (loop_p, loop->superloops, odepth) == outer);
} }
/* Returns the loop such that LOOP is nested DEPTH (indexed from zero) /* Returns the loop such that LOOP is nested DEPTH (indexed from zero)
...@@ -75,12 +76,14 @@ flow_loop_nested_p (const struct loop *outer, const struct loop *loop) ...@@ -75,12 +76,14 @@ flow_loop_nested_p (const struct loop *outer, const struct loop *loop)
struct loop * struct loop *
superloop_at_depth (struct loop *loop, unsigned depth) superloop_at_depth (struct loop *loop, unsigned depth)
{ {
gcc_assert (depth <= (unsigned) loop->depth); unsigned ldepth = loop_depth (loop);
gcc_assert (depth <= ldepth);
if (depth == (unsigned) loop->depth) if (depth == ldepth)
return loop; return loop;
return loop->pred[depth]; return VEC_index (loop_p, loop->superloops, depth);
} }
/* Returns the list of the latch edges of LOOP. */ /* Returns the list of the latch edges of LOOP. */
...@@ -133,7 +136,8 @@ flow_loop_dump (const struct loop *loop, FILE *file, ...@@ -133,7 +136,8 @@ flow_loop_dump (const struct loop *loop, FILE *file,
} }
fprintf (file, ";; depth %d, outer %ld\n", fprintf (file, ";; depth %d, outer %ld\n",
loop->depth, (long) (loop->outer ? loop->outer->num : -1)); loop_depth (loop), (long) (loop_outer (loop)
? loop_outer (loop)->num : -1));
fprintf (file, ";; nodes:"); fprintf (file, ";; nodes:");
bbs = get_loop_body (loop); bbs = get_loop_body (loop);
...@@ -175,8 +179,7 @@ flow_loop_free (struct loop *loop) ...@@ -175,8 +179,7 @@ flow_loop_free (struct loop *loop)
{ {
struct loop_exit *exit, *next; struct loop_exit *exit, *next;
if (loop->pred) VEC_free (loop_p, heap, loop->superloops);
free (loop->pred);
/* Break the list of the loop exit records. They will be freed when the /* Break the list of the loop exit records. They will be freed when the
corresponding edge is rescanned or removed, and this avoids corresponding edge is rescanned or removed, and this avoids
...@@ -226,9 +229,10 @@ flow_loop_nodes_find (basic_block header, struct loop *loop) ...@@ -226,9 +229,10 @@ flow_loop_nodes_find (basic_block header, struct loop *loop)
int num_nodes = 1; int num_nodes = 1;
edge latch; edge latch;
edge_iterator latch_ei; edge_iterator latch_ei;
unsigned depth = loop_depth (loop);
header->loop_father = loop; header->loop_father = loop;
header->loop_depth = loop->depth; header->loop_depth = depth;
FOR_EACH_EDGE (latch, latch_ei, loop->header->preds) FOR_EACH_EDGE (latch, latch_ei, loop->header->preds)
{ {
...@@ -239,7 +243,7 @@ flow_loop_nodes_find (basic_block header, struct loop *loop) ...@@ -239,7 +243,7 @@ flow_loop_nodes_find (basic_block header, struct loop *loop)
num_nodes++; num_nodes++;
VEC_safe_push (basic_block, heap, stack, latch->src); VEC_safe_push (basic_block, heap, stack, latch->src);
latch->src->loop_father = loop; latch->src->loop_father = loop;
latch->src->loop_depth = loop->depth; latch->src->loop_depth = depth;
while (!VEC_empty (basic_block, stack)) while (!VEC_empty (basic_block, stack))
{ {
...@@ -256,7 +260,7 @@ flow_loop_nodes_find (basic_block header, struct loop *loop) ...@@ -256,7 +260,7 @@ flow_loop_nodes_find (basic_block header, struct loop *loop)
if (ancestor->loop_father != loop) if (ancestor->loop_father != loop)
{ {
ancestor->loop_father = loop; ancestor->loop_father = loop;
ancestor->loop_depth = loop->depth; ancestor->loop_depth = depth;
num_nodes++; num_nodes++;
VEC_safe_push (basic_block, heap, stack, ancestor); VEC_safe_push (basic_block, heap, stack, ancestor);
} }
...@@ -268,24 +272,27 @@ flow_loop_nodes_find (basic_block header, struct loop *loop) ...@@ -268,24 +272,27 @@ flow_loop_nodes_find (basic_block header, struct loop *loop)
return num_nodes; return num_nodes;
} }
/* Records the vector of superloops of the loop LOOP, whose immediate
superloop is FATHER. */
static void static void
establish_preds (struct loop *loop) establish_preds (struct loop *loop, struct loop *father)
{ {
struct loop *ploop, *father = loop->outer; loop_p ploop;
unsigned depth = loop_depth (father) + 1;
loop->depth = father->depth + 1; unsigned i;
/* Remember the current loop depth if it is the largest seen so far. */ /* Remember the current loop depth if it is the largest seen so far. */
cfun->max_loop_depth = MAX (cfun->max_loop_depth, loop->depth); cfun->max_loop_depth = MAX (cfun->max_loop_depth, (int) depth);
if (loop->pred) VEC_truncate (loop_p, loop->superloops, 0);
free (loop->pred); VEC_reserve (loop_p, heap, loop->superloops, depth);
loop->pred = XNEWVEC (struct loop *, loop->depth); for (i = 0; VEC_iterate (loop_p, father->superloops, i, ploop); i++)
memcpy (loop->pred, father->pred, sizeof (struct loop *) * father->depth); VEC_quick_push (loop_p, loop->superloops, ploop);
loop->pred[father->depth] = father; VEC_quick_push (loop_p, loop->superloops, father);
for (ploop = loop->inner; ploop; ploop = ploop->next) for (ploop = loop->inner; ploop; ploop = ploop->next)
establish_preds (ploop); establish_preds (ploop, loop);
} }
/* Add LOOP to the loop hierarchy tree where FATHER is father of the /* Add LOOP to the loop hierarchy tree where FATHER is father of the
...@@ -297,9 +304,8 @@ flow_loop_tree_node_add (struct loop *father, struct loop *loop) ...@@ -297,9 +304,8 @@ flow_loop_tree_node_add (struct loop *father, struct loop *loop)
{ {
loop->next = father->inner; loop->next = father->inner;
father->inner = loop; father->inner = loop;
loop->outer = father;
establish_preds (loop); establish_preds (loop, father);
} }
/* Remove LOOP from the loop hierarchy tree. */ /* Remove LOOP from the loop hierarchy tree. */
...@@ -309,21 +315,19 @@ flow_loop_tree_node_remove (struct loop *loop) ...@@ -309,21 +315,19 @@ flow_loop_tree_node_remove (struct loop *loop)
{ {
struct loop *prev, *father; struct loop *prev, *father;
father = loop->outer; father = loop_outer (loop);
loop->outer = NULL;
/* Remove loop from the list of sons. */ /* Remove loop from the list of sons. */
if (father->inner == loop) if (father->inner == loop)
father->inner = loop->next; father->inner = loop->next;
else else
{ {
for (prev = father->inner; prev->next != loop; prev = prev->next); for (prev = father->inner; prev->next != loop; prev = prev->next)
continue;
prev->next = loop->next; prev->next = loop->next;
} }
loop->depth = -1; VEC_truncate (loop_p, loop->superloops, 0);
free (loop->pred);
loop->pred = NULL;
} }
/* Allocates and returns new loop structure. */ /* Allocates and returns new loop structure. */
...@@ -994,7 +998,7 @@ rescan_loop_exit (edge e, bool new_edge, bool removed) ...@@ -994,7 +998,7 @@ rescan_loop_exit (edge e, bool new_edge, bool removed)
cloop = find_common_loop (e->src->loop_father, e->dest->loop_father); cloop = find_common_loop (e->src->loop_father, e->dest->loop_father);
for (aloop = e->src->loop_father; for (aloop = e->src->loop_father;
aloop != cloop; aloop != cloop;
aloop = aloop->outer) aloop = loop_outer (aloop))
{ {
exit = XNEW (struct loop_exit); exit = XNEW (struct loop_exit);
exit->e = e; exit->e = e;
...@@ -1161,16 +1165,17 @@ num_loop_branches (const struct loop *loop) ...@@ -1161,16 +1165,17 @@ num_loop_branches (const struct loop *loop)
void void
add_bb_to_loop (basic_block bb, struct loop *loop) add_bb_to_loop (basic_block bb, struct loop *loop)
{ {
int i; unsigned i;
loop_p ploop;
edge_iterator ei; edge_iterator ei;
edge e; edge e;
gcc_assert (bb->loop_father == NULL); gcc_assert (bb->loop_father == NULL);
bb->loop_father = loop; bb->loop_father = loop;
bb->loop_depth = loop->depth; bb->loop_depth = loop_depth (loop);
loop->num_nodes++; loop->num_nodes++;
for (i = 0; i < loop->depth; i++) for (i = 0; VEC_iterate (loop_p, loop->superloops, i, ploop); i++)
loop->pred[i]->num_nodes++; ploop->num_nodes++;
FOR_EACH_EDGE (e, ei, bb->succs) FOR_EACH_EDGE (e, ei, bb->succs)
{ {
...@@ -1188,13 +1193,14 @@ remove_bb_from_loops (basic_block bb) ...@@ -1188,13 +1193,14 @@ remove_bb_from_loops (basic_block bb)
{ {
int i; int i;
struct loop *loop = bb->loop_father; struct loop *loop = bb->loop_father;
loop_p ploop;
edge_iterator ei; edge_iterator ei;
edge e; edge e;
gcc_assert (loop != NULL); gcc_assert (loop != NULL);
loop->num_nodes--; loop->num_nodes--;
for (i = 0; i < loop->depth; i++) for (i = 0; VEC_iterate (loop_p, loop->superloops, i, ploop); i++)
loop->pred[i]->num_nodes--; ploop->num_nodes--;
bb->loop_father = NULL; bb->loop_father = NULL;
bb->loop_depth = 0; bb->loop_depth = 0;
...@@ -1212,18 +1218,23 @@ remove_bb_from_loops (basic_block bb) ...@@ -1212,18 +1218,23 @@ remove_bb_from_loops (basic_block bb)
struct loop * struct loop *
find_common_loop (struct loop *loop_s, struct loop *loop_d) find_common_loop (struct loop *loop_s, struct loop *loop_d)
{ {
unsigned sdepth, ddepth;
if (!loop_s) return loop_d; if (!loop_s) return loop_d;
if (!loop_d) return loop_s; if (!loop_d) return loop_s;
if (loop_s->depth < loop_d->depth) sdepth = loop_depth (loop_s);
loop_d = loop_d->pred[loop_s->depth]; ddepth = loop_depth (loop_d);
else if (loop_s->depth > loop_d->depth)
loop_s = loop_s->pred[loop_d->depth]; if (sdepth < ddepth)
loop_d = VEC_index (loop_p, loop_d->superloops, sdepth);
else if (sdepth > ddepth)
loop_s = VEC_index (loop_p, loop_s->superloops, ddepth);
while (loop_s != loop_d) while (loop_s != loop_d)
{ {
loop_s = loop_s->outer; loop_s = loop_outer (loop_s);
loop_d = loop_d->outer; loop_d = loop_outer (loop_d);
} }
return loop_s; return loop_s;
} }
...@@ -1250,13 +1261,14 @@ cancel_loop (struct loop *loop) ...@@ -1250,13 +1261,14 @@ cancel_loop (struct loop *loop)
{ {
basic_block *bbs; basic_block *bbs;
unsigned i; unsigned i;
struct loop *outer = loop_outer (loop);
gcc_assert (!loop->inner); gcc_assert (!loop->inner);
/* Move blocks up one level (they should be removed as soon as possible). */ /* Move blocks up one level (they should be removed as soon as possible). */
bbs = get_loop_body (loop); bbs = get_loop_body (loop);
for (i = 0; i < loop->num_nodes; i++) for (i = 0; i < loop->num_nodes; i++)
bbs[i]->loop_father = loop->outer; bbs[i]->loop_father = outer;
delete_loop (loop); delete_loop (loop);
} }
...@@ -1295,7 +1307,7 @@ verify_loop_structure (void) ...@@ -1295,7 +1307,7 @@ verify_loop_structure (void)
sizes[0] = 2; sizes[0] = 2;
FOR_EACH_BB (bb) FOR_EACH_BB (bb)
for (loop = bb->loop_father; loop; loop = loop->outer) for (loop = bb->loop_father; loop; loop = loop_outer (loop))
sizes[loop->num]++; sizes[loop->num]++;
FOR_EACH_LOOP (li, loop, LI_INCLUDE_ROOT) FOR_EACH_LOOP (li, loop, LI_INCLUDE_ROOT)
...@@ -1494,7 +1506,7 @@ verify_loop_structure (void) ...@@ -1494,7 +1506,7 @@ verify_loop_structure (void)
for (loop = bb->loop_father; for (loop = bb->loop_father;
loop != e->dest->loop_father; loop != e->dest->loop_father;
loop = loop->outer) loop = loop_outer (loop))
{ {
eloops--; eloops--;
sizes[loop->num]++; sizes[loop->num]++;
......
...@@ -85,6 +85,10 @@ struct loop_exit ...@@ -85,6 +85,10 @@ struct loop_exit
struct loop_exit *next_e; struct loop_exit *next_e;
}; };
typedef struct loop *loop_p;
DEF_VEC_P (loop_p);
DEF_VEC_ALLOC_P (loop_p, heap);
/* Structure to hold information for each natural loop. */ /* Structure to hold information for each natural loop. */
struct loop struct loop
{ {
...@@ -109,14 +113,8 @@ struct loop ...@@ -109,14 +113,8 @@ struct loop
/* Number of blocks contained within the loop. */ /* Number of blocks contained within the loop. */
unsigned num_nodes; unsigned num_nodes;
/* The loop nesting depth. */ /* Superloops of the loop, starting with the outermost loop. */
int depth; VEC (loop_p, heap) *superloops;
/* Superloops of the loop. */
struct loop **pred;
/* The outer (parent) loop or NULL if outermost loop. */
struct loop *outer;
/* The first inner (child) loop or NULL if innermost loop. */ /* The first inner (child) loop or NULL if innermost loop. */
struct loop *inner; struct loop *inner;
...@@ -178,10 +176,6 @@ enum ...@@ -178,10 +176,6 @@ enum
| LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS) | LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS)
#define AVOID_CFG_MODIFICATIONS (LOOPS_MAY_HAVE_MULTIPLE_LATCHES) #define AVOID_CFG_MODIFICATIONS (LOOPS_MAY_HAVE_MULTIPLE_LATCHES)
typedef struct loop *loop_p;
DEF_VEC_P (loop_p);
DEF_VEC_ALLOC_P (loop_p, heap);
/* Structure to hold CFG information about natural loops within a function. */ /* Structure to hold CFG information about natural loops within a function. */
struct loops struct loops
{ {
...@@ -410,6 +404,28 @@ get_loop (unsigned num) ...@@ -410,6 +404,28 @@ get_loop (unsigned num)
return VEC_index (loop_p, current_loops->larray, num); return VEC_index (loop_p, current_loops->larray, num);
} }
/* Returns the number of superloops of LOOP. */
static inline unsigned
loop_depth (const struct loop *loop)
{
return VEC_length (loop_p, loop->superloops);
}
/* Returns the immediate superloop of LOOP, or NULL if LOOP is the outermost
loop. */
static inline struct loop *
loop_outer (const struct loop *loop)
{
unsigned n = VEC_length (loop_p, loop->superloops);
if (n == 0)
return NULL;
return VEC_index (loop_p, loop->superloops, n - 1);
}
/* Returns the list of loops in current_loops. */ /* Returns the list of loops in current_loops. */
static inline VEC (loop_p, heap) * static inline VEC (loop_p, heap) *
...@@ -519,10 +535,10 @@ fel_init (loop_iterator *li, loop_p *loop, unsigned flags) ...@@ -519,10 +535,10 @@ fel_init (loop_iterator *li, loop_p *loop, unsigned flags)
aloop = aloop->inner) aloop = aloop->inner)
continue; continue;
} }
else if (!aloop->outer) else if (!loop_outer (aloop))
break; break;
else else
aloop = aloop->outer; aloop = loop_outer (aloop);
} }
} }
else else
...@@ -539,7 +555,7 @@ fel_init (loop_iterator *li, loop_p *loop, unsigned flags) ...@@ -539,7 +555,7 @@ fel_init (loop_iterator *li, loop_p *loop, unsigned flags)
else else
{ {
while (aloop != NULL && aloop->next == NULL) while (aloop != NULL && aloop->next == NULL)
aloop = aloop->outer; aloop = loop_outer (aloop);
if (aloop == NULL) if (aloop == NULL)
break; break;
aloop = aloop->next; aloop = aloop->next;
......
...@@ -276,7 +276,8 @@ mark_irreducible_loops (void) ...@@ -276,7 +276,8 @@ mark_irreducible_loops (void)
int num = current_loops ? number_of_loops () : 1; int num = current_loops ? number_of_loops () : 1;
int *queue1 = XNEWVEC (int, last_basic_block + num); int *queue1 = XNEWVEC (int, last_basic_block + num);
int *queue2 = XNEWVEC (int, last_basic_block + num); int *queue2 = XNEWVEC (int, last_basic_block + num);
int nq, depth; int nq;
unsigned depth;
struct loop *cloop, *loop; struct loop *cloop, *loop;
loop_iterator li; loop_iterator li;
...@@ -321,12 +322,13 @@ mark_irreducible_loops (void) ...@@ -321,12 +322,13 @@ mark_irreducible_loops (void)
if (!flow_bb_inside_loop_p (act->loop_father, e->dest)) if (!flow_bb_inside_loop_p (act->loop_father, e->dest))
{ {
depth = find_common_loop (act->loop_father, depth = 1 + loop_depth (find_common_loop (act->loop_father,
e->dest->loop_father)->depth + 1; e->dest->loop_father));
if (depth == act->loop_father->depth) if (depth == loop_depth (act->loop_father))
cloop = act->loop_father; cloop = act->loop_father;
else else
cloop = act->loop_father->pred[depth]; cloop = VEC_index (loop_p, act->loop_father->superloops,
depth);
src = LOOP_REPR (cloop); src = LOOP_REPR (cloop);
} }
...@@ -612,7 +614,7 @@ mark_loop_exit_edges (void) ...@@ -612,7 +614,7 @@ mark_loop_exit_edges (void)
FOR_EACH_EDGE (e, ei, bb->succs) FOR_EACH_EDGE (e, ei, bb->succs)
{ {
if (bb->loop_father->outer if (loop_outer (bb->loop_father)
&& loop_exit_edge_p (bb->loop_father, e)) && loop_exit_edge_p (bb->loop_father, e))
e->flags |= EDGE_LOOP_EXIT; e->flags |= EDGE_LOOP_EXIT;
else else
......
...@@ -102,7 +102,7 @@ fix_bb_placement (basic_block bb) ...@@ -102,7 +102,7 @@ fix_bb_placement (basic_block bb)
act = e->dest->loop_father; act = e->dest->loop_father;
if (act->header == e->dest) if (act->header == e->dest)
act = act->outer; act = loop_outer (act);
if (flow_loop_nested_p (loop, act)) if (flow_loop_nested_p (loop, act))
loop = act; loop = act;
...@@ -138,9 +138,9 @@ fix_loop_placement (struct loop *loop) ...@@ -138,9 +138,9 @@ fix_loop_placement (struct loop *loop)
father = act; father = act;
} }
if (father != loop->outer) if (father != loop_outer (loop))
{ {
for (act = loop->outer; act != father; act = act->outer) for (act = loop_outer (loop); act != father; act = loop_outer (act))
act->num_nodes -= loop->num_nodes; act->num_nodes -= loop->num_nodes;
flow_loop_tree_node_remove (loop); flow_loop_tree_node_remove (loop);
flow_loop_tree_node_add (father, loop); flow_loop_tree_node_add (father, loop);
...@@ -305,7 +305,7 @@ remove_path (edge e) ...@@ -305,7 +305,7 @@ remove_path (edge e)
we belong to. In this case first unloop the loops, then proceed we belong to. In this case first unloop the loops, then proceed
normally. We may assume that e->dest is not a header of any loop, normally. We may assume that e->dest is not a header of any loop,
as it now has exactly one predecessor. */ as it now has exactly one predecessor. */
while (e->src->loop_father->outer while (loop_outer (e->src->loop_father)
&& dominated_by_p (CDI_DOMINATORS, && dominated_by_p (CDI_DOMINATORS,
e->src->loop_father->latch, e->dest)) e->src->loop_father->latch, e->dest))
unloop (e->src->loop_father, &irred_invalidated); unloop (e->src->loop_father, &irred_invalidated);
...@@ -434,7 +434,7 @@ add_loop (struct loop *loop, struct loop *outer) ...@@ -434,7 +434,7 @@ add_loop (struct loop *loop, struct loop *outer)
/* If we find a direct subloop of OUTER, move it to LOOP. */ /* If we find a direct subloop of OUTER, move it to LOOP. */
subloop = bbs[i]->loop_father; subloop = bbs[i]->loop_father;
if (subloop->outer == outer if (loop_outer (subloop) == outer
&& subloop->header == bbs[i]) && subloop->header == bbs[i])
{ {
flow_loop_tree_node_remove (subloop); flow_loop_tree_node_remove (subloop);
...@@ -477,7 +477,7 @@ loopify (edge latch_edge, edge header_edge, ...@@ -477,7 +477,7 @@ loopify (edge latch_edge, edge header_edge,
unsigned n_dom_bbs, i; unsigned n_dom_bbs, i;
sbitmap seen; sbitmap seen;
struct loop *loop = alloc_loop (); struct loop *loop = alloc_loop ();
struct loop *outer = succ_bb->loop_father->outer; struct loop *outer = loop_outer (succ_bb->loop_father);
int freq; int freq;
gcov_type cnt; gcov_type cnt;
edge e; edge e;
...@@ -592,7 +592,7 @@ unloop (struct loop *loop, bool *irred_invalidated) ...@@ -592,7 +592,7 @@ unloop (struct loop *loop, bool *irred_invalidated)
if (body[i]->loop_father == loop) if (body[i]->loop_father == loop)
{ {
remove_bb_from_loops (body[i]); remove_bb_from_loops (body[i]);
add_bb_to_loop (body[i], loop->outer); add_bb_to_loop (body[i], loop_outer (loop));
} }
free(body); free(body);
...@@ -600,7 +600,7 @@ unloop (struct loop *loop, bool *irred_invalidated) ...@@ -600,7 +600,7 @@ unloop (struct loop *loop, bool *irred_invalidated)
{ {
ploop = loop->inner; ploop = loop->inner;
flow_loop_tree_node_remove (ploop); flow_loop_tree_node_remove (ploop);
flow_loop_tree_node_add (loop->outer, ploop); flow_loop_tree_node_add (loop_outer (loop), ploop);
} }
/* Remove the loop and free its data. */ /* Remove the loop and free its data. */
...@@ -627,9 +627,9 @@ fix_loop_placements (struct loop *loop, bool *irred_invalidated) ...@@ -627,9 +627,9 @@ fix_loop_placements (struct loop *loop, bool *irred_invalidated)
{ {
struct loop *outer; struct loop *outer;
while (loop->outer) while (loop_outer (loop))
{ {
outer = loop->outer; outer = loop_outer (loop);
if (!fix_loop_placement (loop)) if (!fix_loop_placement (loop))
break; break;
...@@ -1393,7 +1393,7 @@ fix_loop_structure (bitmap changed_bbs) ...@@ -1393,7 +1393,7 @@ fix_loop_structure (bitmap changed_bbs)
FOR_EACH_BB (bb) FOR_EACH_BB (bb)
{ {
if (changed_bbs) if (changed_bbs)
bb->aux = (void *) (size_t) bb->loop_father->depth; bb->aux = (void *) (size_t) loop_depth (bb->loop_father);
bb->loop_father = current_loops->tree_root; bb->loop_father = current_loops->tree_root;
} }
...@@ -1416,7 +1416,7 @@ fix_loop_structure (bitmap changed_bbs) ...@@ -1416,7 +1416,7 @@ fix_loop_structure (bitmap changed_bbs)
{ {
ploop = loop->inner; ploop = loop->inner;
flow_loop_tree_node_remove (ploop); flow_loop_tree_node_remove (ploop);
flow_loop_tree_node_add (loop->outer, ploop); flow_loop_tree_node_add (loop_outer (loop), ploop);
} }
/* Remove the loop and free its data. */ /* Remove the loop and free its data. */
...@@ -1439,7 +1439,7 @@ fix_loop_structure (bitmap changed_bbs) ...@@ -1439,7 +1439,7 @@ fix_loop_structure (bitmap changed_bbs)
FOR_EACH_LOOP (li, loop, 0) FOR_EACH_LOOP (li, loop, 0)
{ {
ploop = superloop[loop->num]; ploop = superloop[loop->num];
if (ploop != loop->outer) if (ploop != loop_outer (loop))
{ {
flow_loop_tree_node_remove (loop); flow_loop_tree_node_remove (loop);
flow_loop_tree_node_add (ploop, loop); flow_loop_tree_node_add (ploop, loop);
...@@ -1452,7 +1452,7 @@ fix_loop_structure (bitmap changed_bbs) ...@@ -1452,7 +1452,7 @@ fix_loop_structure (bitmap changed_bbs)
{ {
FOR_EACH_BB (bb) FOR_EACH_BB (bb)
{ {
if ((void *) (size_t) bb->loop_father->depth != bb->aux) if ((void *) (size_t) loop_depth (bb->loop_father) != bb->aux)
bitmap_set_bit (changed_bbs, bb->index); bitmap_set_bit (changed_bbs, bb->index);
bb->aux = NULL; bb->aux = NULL;
......
...@@ -1187,12 +1187,11 @@ invariant_in_loop_and_outer_loops (struct loop *loop, tree op) ...@@ -1187,12 +1187,11 @@ invariant_in_loop_and_outer_loops (struct loop *loop, tree op)
{ {
if (is_gimple_min_invariant (op)) if (is_gimple_min_invariant (op))
return true; return true;
if (loop->depth == 0) if (loop_depth (loop) == 0)
return true; return true;
if (!expr_invariant_in_loop_p (loop, op)) if (!expr_invariant_in_loop_p (loop, op))
return false; return false;
if (loop->outer if (!invariant_in_loop_and_outer_loops (loop_outer (loop), op))
&& !invariant_in_loop_and_outer_loops (loop->outer, op))
return false; return false;
return true; return true;
} }
......
...@@ -811,7 +811,7 @@ static bool ...@@ -811,7 +811,7 @@ static bool
loop_canon_p (struct loop *loop) loop_canon_p (struct loop *loop)
{ {
if (loop->inner || ! loop->outer) if (loop->inner || !loop_outer (loop))
return false; return false;
if (!single_exit (loop)) if (!single_exit (loop))
......
...@@ -4367,7 +4367,7 @@ tree_duplicate_sese_region (edge entry, edge exit, ...@@ -4367,7 +4367,7 @@ tree_duplicate_sese_region (edge entry, edge exit,
if (loop->header == entry->dest) if (loop->header == entry->dest)
{ {
copying_header = true; copying_header = true;
loop->copy = loop->outer; loop->copy = loop_outer (loop);
if (!dominated_by_p (CDI_DOMINATORS, loop->latch, exit->src)) if (!dominated_by_p (CDI_DOMINATORS, loop->latch, exit->src))
return false; return false;
......
...@@ -117,7 +117,7 @@ gather_interchange_stats (VEC (ddr_p, heap) *dependence_relations, ...@@ -117,7 +117,7 @@ gather_interchange_stats (VEC (ddr_p, heap) *dependence_relations,
for (j = 0; j < DDR_NUM_DIST_VECTS (ddr); j++) for (j = 0; j < DDR_NUM_DIST_VECTS (ddr); j++)
{ {
int dist = DDR_DIST_VECT (ddr, j)[loop->depth - first_loop->depth]; int dist = DDR_DIST_VECT (ddr, j)[loop_depth (loop) - loop_depth (first_loop)];
if (dist == 0) if (dist == 0)
(*nb_deps_not_carried_by_loop) += 1; (*nb_deps_not_carried_by_loop) += 1;
...@@ -200,7 +200,7 @@ try_interchange_loops (lambda_trans_matrix trans, ...@@ -200,7 +200,7 @@ try_interchange_loops (lambda_trans_matrix trans,
loop_j; loop_j;
loop_j = loop_j->inner) loop_j = loop_j->inner)
for (loop_i = first_loop; for (loop_i = first_loop;
loop_i->depth < loop_j->depth; loop_depth (loop_i) < loop_depth (loop_j);
loop_i = loop_i->inner) loop_i = loop_i->inner)
{ {
gather_interchange_stats (dependence_relations, datarefs, gather_interchange_stats (dependence_relations, datarefs,
...@@ -230,14 +230,14 @@ try_interchange_loops (lambda_trans_matrix trans, ...@@ -230,14 +230,14 @@ try_interchange_loops (lambda_trans_matrix trans,
|| double_int_ucmp (access_strides_i, access_strides_j) < 0) || double_int_ucmp (access_strides_i, access_strides_j) < 0)
{ {
lambda_matrix_row_exchange (LTM_MATRIX (trans), lambda_matrix_row_exchange (LTM_MATRIX (trans),
loop_i->depth - first_loop->depth, loop_depth (loop_i) - loop_depth (first_loop),
loop_j->depth - first_loop->depth); loop_depth (loop_j) - loop_depth (first_loop));
/* Validate the resulting matrix. When the transformation /* Validate the resulting matrix. When the transformation
is not valid, reverse to the previous transformation. */ is not valid, reverse to the previous transformation. */
if (!lambda_transform_legal_p (trans, depth, dependence_relations)) if (!lambda_transform_legal_p (trans, depth, dependence_relations))
lambda_matrix_row_exchange (LTM_MATRIX (trans), lambda_matrix_row_exchange (LTM_MATRIX (trans),
loop_i->depth - first_loop->depth, loop_depth (loop_i) - loop_depth (first_loop),
loop_j->depth - first_loop->depth); loop_depth (loop_j) - loop_depth (first_loop));
} }
} }
......
...@@ -1534,7 +1534,7 @@ interpret_loop_phi (struct loop *loop, tree loop_phi_node) ...@@ -1534,7 +1534,7 @@ interpret_loop_phi (struct loop *loop, tree loop_phi_node)
(phi_loop, PHI_RESULT (loop_phi_node)); (phi_loop, PHI_RESULT (loop_phi_node));
/* Dive one level deeper. */ /* Dive one level deeper. */
subloop = superloop_at_depth (phi_loop, loop->depth + 1); subloop = superloop_at_depth (phi_loop, loop_depth (loop) + 1);
/* Interpret the subloop. */ /* Interpret the subloop. */
res = compute_overall_effect_of_inner_loop (subloop, evolution_fn); res = compute_overall_effect_of_inner_loop (subloop, evolution_fn);
...@@ -1680,7 +1680,7 @@ compute_scalar_evolution_in_loop (struct loop *wrto_loop, ...@@ -1680,7 +1680,7 @@ compute_scalar_evolution_in_loop (struct loop *wrto_loop,
if (def_loop == wrto_loop) if (def_loop == wrto_loop)
return ev; return ev;
def_loop = superloop_at_depth (def_loop, wrto_loop->depth + 1); def_loop = superloop_at_depth (def_loop, loop_depth (wrto_loop) + 1);
res = compute_overall_effect_of_inner_loop (def_loop, ev); res = compute_overall_effect_of_inner_loop (def_loop, ev);
return analyze_scalar_evolution_1 (wrto_loop, res, chrec_not_analyzed_yet); return analyze_scalar_evolution_1 (wrto_loop, res, chrec_not_analyzed_yet);
...@@ -2023,7 +2023,7 @@ analyze_scalar_evolution_in_loop (struct loop *wrto_loop, struct loop *use_loop, ...@@ -2023,7 +2023,7 @@ analyze_scalar_evolution_in_loop (struct loop *wrto_loop, struct loop *use_loop,
|| !val) || !val)
return chrec_dont_know; return chrec_dont_know;
use_loop = use_loop->outer; use_loop = loop_outer (use_loop);
} }
} }
...@@ -2169,8 +2169,8 @@ instantiate_parameters_1 (struct loop *loop, tree chrec, int flags, htab_t cache ...@@ -2169,8 +2169,8 @@ instantiate_parameters_1 (struct loop *loop, tree chrec, int flags, htab_t cache
/* Don't instantiate loop-closed-ssa phi nodes. */ /* Don't instantiate loop-closed-ssa phi nodes. */
if (TREE_CODE (res) == SSA_NAME if (TREE_CODE (res) == SSA_NAME
&& (loop_containing_stmt (SSA_NAME_DEF_STMT (res)) == NULL && (loop_containing_stmt (SSA_NAME_DEF_STMT (res)) == NULL
|| (loop_containing_stmt (SSA_NAME_DEF_STMT (res))->depth || (loop_depth (loop_containing_stmt (SSA_NAME_DEF_STMT (res)))
> def_loop->depth))) > loop_depth (def_loop))))
{ {
if (res == chrec) if (res == chrec)
res = loop_closed_phi_def (chrec); res = loop_closed_phi_def (chrec);
...@@ -2966,7 +2966,8 @@ scev_const_prop (void) ...@@ -2966,7 +2966,8 @@ scev_const_prop (void)
tree_block_label (exit->dest); tree_block_label (exit->dest);
bsi = bsi_after_labels (exit->dest); bsi = bsi_after_labels (exit->dest);
ex_loop = superloop_at_depth (loop, exit->dest->loop_father->depth + 1); ex_loop = superloop_at_depth (loop,
loop_depth (exit->dest->loop_father) + 1);
for (phi = phi_nodes (exit->dest); phi; phi = next_phi) for (phi = phi_nodes (exit->dest); phi; phi = next_phi)
{ {
......
...@@ -316,10 +316,10 @@ outermost_invariant_loop (tree def, struct loop *loop) ...@@ -316,10 +316,10 @@ outermost_invariant_loop (tree def, struct loop *loop)
if (LIM_DATA (def_stmt) && LIM_DATA (def_stmt)->max_loop) if (LIM_DATA (def_stmt) && LIM_DATA (def_stmt)->max_loop)
max_loop = find_common_loop (max_loop, max_loop = find_common_loop (max_loop,
LIM_DATA (def_stmt)->max_loop->outer); loop_outer (LIM_DATA (def_stmt)->max_loop));
if (max_loop == loop) if (max_loop == loop)
return NULL; return NULL;
max_loop = superloop_at_depth (loop, max_loop->depth + 1); max_loop = superloop_at_depth (loop, loop_depth (max_loop) + 1);
return max_loop; return max_loop;
} }
...@@ -525,7 +525,7 @@ set_level (tree stmt, struct loop *orig_loop, struct loop *level) ...@@ -525,7 +525,7 @@ set_level (tree stmt, struct loop *orig_loop, struct loop *level)
stmt_loop = find_common_loop (orig_loop, stmt_loop); stmt_loop = find_common_loop (orig_loop, stmt_loop);
if (LIM_DATA (stmt) && LIM_DATA (stmt)->tgt_loop) if (LIM_DATA (stmt) && LIM_DATA (stmt)->tgt_loop)
stmt_loop = find_common_loop (stmt_loop, stmt_loop = find_common_loop (stmt_loop,
LIM_DATA (stmt)->tgt_loop->outer); loop_outer (LIM_DATA (stmt)->tgt_loop));
if (flow_loop_nested_p (stmt_loop, level)) if (flow_loop_nested_p (stmt_loop, level))
return; return;
...@@ -709,12 +709,12 @@ determine_invariantness_stmt (struct dom_walk_data *dw_data ATTRIBUTE_UNUSED, ...@@ -709,12 +709,12 @@ determine_invariantness_stmt (struct dom_walk_data *dw_data ATTRIBUTE_UNUSED,
bool maybe_never = ALWAYS_EXECUTED_IN (bb) == NULL; bool maybe_never = ALWAYS_EXECUTED_IN (bb) == NULL;
struct loop *outermost = ALWAYS_EXECUTED_IN (bb); struct loop *outermost = ALWAYS_EXECUTED_IN (bb);
if (!bb->loop_father->outer) if (!loop_outer (bb->loop_father))
return; return;
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "Basic block %d (loop %d -- depth %d):\n\n", fprintf (dump_file, "Basic block %d (loop %d -- depth %d):\n\n",
bb->index, bb->loop_father->num, bb->loop_father->depth); bb->index, bb->loop_father->num, loop_depth (bb->loop_father));
for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi)) for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
{ {
...@@ -774,7 +774,7 @@ determine_invariantness_stmt (struct dom_walk_data *dw_data ATTRIBUTE_UNUSED, ...@@ -774,7 +774,7 @@ determine_invariantness_stmt (struct dom_walk_data *dw_data ATTRIBUTE_UNUSED,
{ {
print_generic_stmt_indented (dump_file, stmt, 0, 2); print_generic_stmt_indented (dump_file, stmt, 0, 2);
fprintf (dump_file, " invariant up to level %d, cost %d.\n\n", fprintf (dump_file, " invariant up to level %d, cost %d.\n\n",
LIM_DATA (stmt)->max_loop->depth, loop_depth (LIM_DATA (stmt)->max_loop),
LIM_DATA (stmt)->cost); LIM_DATA (stmt)->cost);
} }
...@@ -815,7 +815,7 @@ move_computations_stmt (struct dom_walk_data *dw_data ATTRIBUTE_UNUSED, ...@@ -815,7 +815,7 @@ move_computations_stmt (struct dom_walk_data *dw_data ATTRIBUTE_UNUSED,
tree stmt; tree stmt;
unsigned cost = 0; unsigned cost = 0;
if (!bb->loop_father->outer) if (!loop_outer (bb->loop_father))
return; return;
for (bsi = bsi_start (bb); !bsi_end_p (bsi); ) for (bsi = bsi_start (bb); !bsi_end_p (bsi); )
......
...@@ -244,7 +244,7 @@ find_uses_to_rename_use (basic_block bb, tree use, bitmap *use_blocks, ...@@ -244,7 +244,7 @@ find_uses_to_rename_use (basic_block bb, tree use, bitmap *use_blocks,
def_loop = def_bb->loop_father; def_loop = def_bb->loop_father;
/* If the definition is not inside loop, it is not interesting. */ /* If the definition is not inside loop, it is not interesting. */
if (!def_loop->outer) if (!loop_outer (def_loop))
return; return;
if (!use_blocks[ver]) if (!use_blocks[ver])
......
...@@ -832,7 +832,7 @@ slpeel_tree_duplicate_loop_to_edge_cfg (struct loop *loop, edge e) ...@@ -832,7 +832,7 @@ slpeel_tree_duplicate_loop_to_edge_cfg (struct loop *loop, edge e)
} }
/* Generate new loop structure. */ /* Generate new loop structure. */
new_loop = duplicate_loop (loop, loop->outer); new_loop = duplicate_loop (loop, loop_outer (loop));
if (!new_loop) if (!new_loop)
{ {
free (bbs); free (bbs);
...@@ -962,7 +962,7 @@ slpeel_can_duplicate_loop_p (struct loop *loop, edge e) ...@@ -962,7 +962,7 @@ slpeel_can_duplicate_loop_p (struct loop *loop, edge e)
if (loop->inner if (loop->inner
/* All loops have an outer scope; the only case loop->outer is NULL is for /* All loops have an outer scope; the only case loop->outer is NULL is for
the function itself. */ the function itself. */
|| !loop->outer || !loop_outer (loop)
|| loop->num_nodes != 2 || loop->num_nodes != 2
|| !empty_block_p (loop->latch) || !empty_block_p (loop->latch)
|| !single_exit (loop) || !single_exit (loop)
......
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