some more edge cleanups
Ben Elliston
bje@au1.ibm.com
Thu Sep 30 08:30:00 GMT 2004
A few places around the source tree missed out when the switch was
made to using edge_iterators. The following changes make the intent
of the code much clearer. Tested with a bootstrap and regression
testsuite run.
Okay for mainline?
Ben
2004-09-30 Ben Elliston <bje@au.ibm.com>
* cfgexpand.c (construct_exit_block): Use an edge_iterator.
* cfgrtl.c (cfg_layout_redirect_edge_and_branch): Likewise.
* ra-build.c (live_in): Likewise.
* sbitmap.c (sbitmap_intersection_of_succs): Likewise.
(sbitmap_intersection_of_preds): Likewise.
(sbitmap_union_of_succs): Likewise.
(sbitmap_union_of_preds): Likewise.
Index: cfgexpand.c
===================================================================
RCS file: /home/bje/gcc-cvs/gcc/gcc/cfgexpand.c,v
retrieving revision 2.27
diff -u -p -r2.27 cfgexpand.c
--- cfgexpand.c 28 Sep 2004 07:59:42 -0000 2.27
+++ cfgexpand.c 30 Sep 2004 05:22:04 -0000
@@ -1172,7 +1172,6 @@ construct_exit_block (void)
rtx end;
basic_block exit_block;
edge e, e2;
- unsigned ix;
edge_iterator ei;
/* Make sure the locus is set to the end of the function, so that
@@ -1200,14 +1199,12 @@ construct_exit_block (void)
exit_block->frequency = EXIT_BLOCK_PTR->frequency;
exit_block->count = EXIT_BLOCK_PTR->count;
- ix = 0;
- while (ix < EDGE_COUNT (EXIT_BLOCK_PTR->preds))
+ for (ei = ei_start (EXIT_BLOCK_PTR->preds); (e = ei_safe_edge (ei)); )
{
- e = EDGE_I (EXIT_BLOCK_PTR->preds, ix);
if (!(e->flags & EDGE_ABNORMAL))
redirect_edge_succ (e, exit_block);
else
- ix++;
+ ei_next (&ei);
}
e = make_edge (exit_block, EXIT_BLOCK_PTR, EDGE_FALLTHRU);
Index: cfgrtl.c
===================================================================
RCS file: /home/bje/gcc-cvs/gcc/gcc/cfgrtl.c,v
retrieving revision 1.135
diff -u -p -r1.135 cfgrtl.c
--- cfgrtl.c 28 Sep 2004 07:59:43 -0000 1.135
+++ cfgrtl.c 30 Sep 2004 05:22:04 -0000
@@ -2590,7 +2590,6 @@ cfg_layout_redirect_edge_and_branch (edg
if (EDGE_COUNT (src->succs) == 2)
{
bool found = false;
- unsigned ix = 0;
edge tmp, s;
edge_iterator ei;
@@ -2598,14 +2597,16 @@ cfg_layout_redirect_edge_and_branch (edg
if (e == tmp)
{
found = true;
- ix = ei.index;
break;
}
gcc_assert (found);
- if (EDGE_COUNT (src->succs) > (ix + 1))
- s = EDGE_SUCC (src, ix + 1);
+ if (EDGE_COUNT (src->succs) > (ei.index + 1))
+ {
+ ei_next (&ei);
+ s = ei_edge (ei);
+ }
else
s = EDGE_SUCC (src, 0);
Index: ra-build.c
===================================================================
RCS file: /home/bje/gcc-cvs/gcc/gcc/ra-build.c,v
retrieving revision 1.35
diff -u -p -r1.35 ra-build.c
--- ra-build.c 28 Sep 2004 07:59:48 -0000 1.35
+++ ra-build.c 30 Sep 2004 05:22:04 -0000
@@ -924,7 +924,6 @@ live_in (struct df *df, struct curr_use
are allowed. */
while (1)
{
- unsigned int i;
int uid = INSN_UID (insn);
basic_block bb = BLOCK_FOR_INSN (insn);
number_seen[uid]++;
@@ -939,6 +938,7 @@ live_in (struct df *df, struct curr_use
if (bb != BLOCK_FOR_INSN (insn))
{
edge e;
+ edge_iterator ei;
unsigned HOST_WIDE_INT undef = use->undefined;
struct ra_bb_info *info = (struct ra_bb_info *) bb->aux;
if (EDGE_COUNT (bb->preds) == 0)
@@ -953,9 +953,9 @@ live_in (struct df *df, struct curr_use
info->pass = loc_vpass;
info->undefined = undef;
/* All but the last predecessor are handled recursively. */
- for (e = NULL, i = 0; i < EDGE_COUNT (bb->preds) - 1; i++)
+ for (e = NULL, ei = ei_start (bb->preds); !ei_one_before_end_p (ei); ei_next (&ei))
{
- e = EDGE_PRED (bb, i);
+ e = ei_safe_edge (ei);
insn = live_in_edge (df, use, e);
if (insn)
live_in (df, use, insn);
Index: sbitmap.c
===================================================================
RCS file: /home/bje/gcc-cvs/gcc/gcc/sbitmap.c,v
retrieving revision 1.33
diff -u -p -r1.33 sbitmap.c
--- sbitmap.c 28 Sep 2004 07:59:49 -0000 1.33
+++ sbitmap.c 30 Sep 2004 05:22:04 -0000
@@ -514,11 +514,10 @@ sbitmap_intersection_of_succs (sbitmap d
basic_block b = BASIC_BLOCK (bb);
unsigned int set_size = dst->size;
edge e;
- unsigned ix;
+ edge_iterator ei;
- for (e = NULL, ix = 0; ix < EDGE_COUNT (b->succs); ix++)
+ FOR_EACH_EDGE (e, ei, b->succs)
{
- e = EDGE_SUCC (b, ix);
if (e->dest == EXIT_BLOCK_PTR)
continue;
@@ -526,15 +525,15 @@ sbitmap_intersection_of_succs (sbitmap d
break;
}
- if (e == 0)
+ if (ei_end_p (ei))
sbitmap_ones (dst);
else
- for (++ix; ix < EDGE_COUNT (b->succs); ix++)
+ for (ei_next (&ei); !ei_end_p (ei); ei_next (&ei))
{
unsigned int i;
sbitmap_ptr p, r;
- e = EDGE_SUCC (b, ix);
+ e = ei_edge (ei);
if (e->dest == EXIT_BLOCK_PTR)
continue;
@@ -554,11 +553,10 @@ sbitmap_intersection_of_preds (sbitmap d
basic_block b = BASIC_BLOCK (bb);
unsigned int set_size = dst->size;
edge e;
- unsigned ix;
+ edge_iterator ei;
- for (e = NULL, ix = 0; ix < EDGE_COUNT (b->preds); ix++)
+ FOR_EACH_EDGE (e, ei, b->preds)
{
- e = EDGE_PRED (b, ix);
if (e->src == ENTRY_BLOCK_PTR)
continue;
@@ -566,15 +564,15 @@ sbitmap_intersection_of_preds (sbitmap d
break;
}
- if (e == 0)
+ if (ei_end_p (ei))
sbitmap_ones (dst);
else
- for (++ix; ix < EDGE_COUNT (b->preds); ix++)
+ for (ei_next (&ei); !ei_end_p (ei); ei_next (&ei))
{
unsigned int i;
sbitmap_ptr p, r;
- e = EDGE_PRED (b, ix);
+ e = ei_edge (ei);
if (e->src == ENTRY_BLOCK_PTR)
continue;
@@ -594,11 +592,10 @@ sbitmap_union_of_succs (sbitmap dst, sbi
basic_block b = BASIC_BLOCK (bb);
unsigned int set_size = dst->size;
edge e;
- unsigned ix;
+ edge_iterator ei;
- for (ix = 0; ix < EDGE_COUNT (b->succs); ix++)
+ FOR_EACH_EDGE (e, ei, b->succs)
{
- e = EDGE_SUCC (b, ix);
if (e->dest == EXIT_BLOCK_PTR)
continue;
@@ -606,15 +603,15 @@ sbitmap_union_of_succs (sbitmap dst, sbi
break;
}
- if (ix == EDGE_COUNT (b->succs))
+ if (ei_end_p (ei))
sbitmap_zero (dst);
else
- for (ix++; ix < EDGE_COUNT (b->succs); ix++)
+ for (ei_next (&ei); !ei_end_p (ei); ei_next (&ei))
{
unsigned int i;
sbitmap_ptr p, r;
- e = EDGE_SUCC (b, ix);
+ e = ei_edge (ei);
if (e->dest == EXIT_BLOCK_PTR)
continue;
@@ -634,26 +631,26 @@ sbitmap_union_of_preds (sbitmap dst, sbi
basic_block b = BASIC_BLOCK (bb);
unsigned int set_size = dst->size;
edge e;
- unsigned ix;
+ edge_iterator ei;
- for (e = NULL, ix = 0; ix < EDGE_COUNT (b->preds); ix++)
+ FOR_EACH_EDGE (e, ei, b->preds)
{
- if (e->src== ENTRY_BLOCK_PTR)
+ if (e->src == ENTRY_BLOCK_PTR)
continue;
sbitmap_copy (dst, src[e->src->index]);
break;
}
- if (ix == EDGE_COUNT (b->preds))
+ if (ei_end_p (ei))
sbitmap_zero (dst);
else
- for (ix++; ix < EDGE_COUNT (b->preds); ix++)
+ for (ei_next (&ei); !ei_end_p (ei); ei_next (&ei))
{
unsigned int i;
sbitmap_ptr p, r;
- e = EDGE_PRED (b, ix);
+ e = ei_edge (ei);
if (e->src == ENTRY_BLOCK_PTR)
continue;
More information about the Gcc-patches
mailing list