From: Kazu Hirata Date: Mon, 18 Oct 2004 21:14:34 +0000 (+0000) Subject: tree-cfg.c (tree_forwarder_block_p): Don't set forwardable. X-Git-Tag: releases/gcc-4.0.0~3928 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=78b6731db8690985eba76af2c9b8741bfc85654c;p=thirdparty%2Fgcc.git tree-cfg.c (tree_forwarder_block_p): Don't set forwardable. * tree-cfg.c (tree_forwarder_block_p): Don't set forwardable. (thread_jumps): Use forwardable as cache of tree_forwarder_block_p throughout the function. From-SVN: r89243 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 956cdc6a49ee..94e41010025a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2004-10-18 Kazu Hirata + + * tree-cfg.c (tree_forwarder_block_p): Don't set forwardable. + (thread_jumps): Use forwardable as cache of + tree_forwarder_block_p throughout the function. + 2004-10-18 Andreas Krebbel * cfg.c (dump_flow_info): Remove redundant dump of reg life info. diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 149be9515a2b..3fd8232719bf 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -3720,11 +3720,6 @@ tree_forwarder_block_p (basic_block bb) edge e; edge_iterator ei; - /* If we have already determined that this block is not forwardable, - then no further checks are necessary. */ - if (! bb_ann (bb)->forwardable) - return false; - /* BB must have a single outgoing edge. */ if (EDGE_COUNT (bb->succs) != 1 /* BB can not have any PHI nodes. This could potentially be @@ -3735,10 +3730,7 @@ tree_forwarder_block_p (basic_block bb) || EDGE_SUCC (bb, 0)->dest == EXIT_BLOCK_PTR /* BB may not have an abnormal outgoing edge. */ || (EDGE_SUCC (bb, 0)->flags & EDGE_ABNORMAL)) - { - bb_ann (bb)->forwardable = 0; - return false; - } + return false; #if ENABLE_CHECKING gcc_assert (bb != ENTRY_BLOCK_PTR); @@ -3747,10 +3739,7 @@ tree_forwarder_block_p (basic_block bb) /* Successors of the entry block are not forwarders. */ FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR->succs) if (e->dest == bb) - { - bb_ann (bb)->forwardable = 0; - return false; - } + return false; /* Now walk through the statements. We can ignore labels, anything else means this is not a forwarder block. */ @@ -3766,7 +3755,6 @@ tree_forwarder_block_p (basic_block bb) break; default: - bb_ann (bb)->forwardable = 0; return false; } } @@ -3794,21 +3782,17 @@ thread_jumps (void) bool retval = false; FOR_EACH_BB (bb) - bb_ann (bb)->forwardable = 1; + bb_ann (bb)->forwardable = tree_forwarder_block_p (bb); FOR_EACH_BB (bb) { edge_iterator ei; + bool this_jump_threaded = false; /* Don't waste time on forwarders. */ - if (tree_forwarder_block_p (bb)) + if (bb_ann (bb)->forwardable) continue; - /* This block is now part of a forwarding path, mark it as not - forwardable so that we can detect loops. This bit will be - reset below. */ - bb_ann (bb)->forwardable = 0; - /* Examine each of our block's successors to see if it is forwardable. */ for (ei = ei_start (bb->succs); (e = ei_safe_edge (ei)); ) @@ -3819,7 +3803,7 @@ thread_jumps (void) /* If the edge is abnormal or its destination is not forwardable, then there's nothing to do. */ if ((e->flags & EDGE_ABNORMAL) - || !tree_forwarder_block_p (e->dest)) + || !bb_ann (e->dest)->forwardable) { ei_next (&ei); continue; @@ -3834,7 +3818,7 @@ thread_jumps (void) last = EDGE_SUCC (e->dest, 0); bb_ann (e->dest)->forwardable = 0; for (dest = EDGE_SUCC (e->dest, 0)->dest; - tree_forwarder_block_p (dest); + bb_ann (dest)->forwardable; last = EDGE_SUCC (dest, 0), dest = EDGE_SUCC (dest, 0)->dest) bb_ann (dest)->forwardable = 0; @@ -3875,7 +3859,7 @@ thread_jumps (void) } /* Perform the redirection. */ - retval = true; + retval = this_jump_threaded = true; old_dest = e->dest; e = redirect_edge_and_branch (e, dest); @@ -3955,9 +3939,13 @@ thread_jumps (void) } } - /* Reset the forwardable bit on our block since it's no longer in - a forwarding chain path. */ - bb_ann (bb)->forwardable = 1; + /* If we succeeded in threading a jump at BB, update the + forwardable mark as BB may have become a new forwarder block. + This could happen if we have a useless "if" statement whose + two arms eventually merge without any intervening + statements. */ + if (this_jump_threaded && tree_forwarder_block_p (bb)) + bb_ann (bb)->forwardable = true; } return retval;