[patch] tree-cfg.c: Speed up remove_forwarder_block_with_phi.
Kazu Hirata
kazu@cs.umass.edu
Sat Jan 22 08:47:00 GMT 2005
Hi,
Attached is a patch to speed up remove_forwarder_block_with_phi.
Note that we now make a considerable effort to ensure that a nonlocal
label appears first in a sequence of labels. Specifically,
stmt_starts_bb_p guarantees this property when CFG is constructed, and
tree_verify_flow_info verifies it at various points in tree
optimizations.
So we should take advantage of this property and simplify a loop that
looks for nonlocal labels. We can simply look at the very first
statement and see if it's a nonlocal label.
Tested on i686-pc-linux-gnu. OK to apply?
Kazu Hirata
2005-01-22 Kazu Hirata <kazu@cs.umass.edu>
* tree-cfg.c (remove_forwarder_block_with_phi): Look at the
first label to see if it is a nonlocal label.
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.144
diff -c -d -p -r2.144 tree-cfg.c
*** tree-cfg.c 21 Jan 2005 13:05:02 -0000 2.144
--- tree-cfg.c 21 Jan 2005 14:42:31 -0000
*************** remove_forwarder_block_with_phi (basic_b
*** 4130,4137 ****
{
edge succ = EDGE_SUCC (bb, 0);
basic_block dest = succ->dest;
basic_block dombb, domdest, dom;
- block_stmt_iterator bsi;
/* We check for infinite loops already in tree_forwarder_block_p.
However it may happen that the infinite loop is created
--- 4130,4137 ----
{
edge succ = EDGE_SUCC (bb, 0);
basic_block dest = succ->dest;
+ tree label;
basic_block dombb, domdest, dom;
/* We check for infinite loops already in tree_forwarder_block_p.
However it may happen that the infinite loop is created
*************** remove_forwarder_block_with_phi (basic_b
*** 4141,4156 ****
/* If the destination block consists of a nonlocal label, do not
merge it. */
! for (bsi = bsi_start (dest); !bsi_end_p (bsi); bsi_next (&bsi))
! {
! tree stmt = bsi_stmt (bsi);
!
! if (TREE_CODE (stmt) != LABEL_EXPR)
! break;
!
! if (DECL_NONLOCAL (LABEL_EXPR_LABEL (stmt)))
! return;
! }
/* Redirect each incoming edge to BB to DEST. */
while (EDGE_COUNT (bb->preds) > 0)
--- 4141,4151 ----
/* If the destination block consists of a nonlocal label, do not
merge it. */
! label = first_stmt (dest);
! if (label
! && TREE_CODE (label) == LABEL_EXPR
! && DECL_NONLOCAL (LABEL_EXPR_LABEL (label)))
! return;
/* Redirect each incoming edge to BB to DEST. */
while (EDGE_COUNT (bb->preds) > 0)
More information about the Gcc-patches
mailing list