This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] tree-cfg.c: Speed up thread_jumps() - Part 1
- From: Kazu Hirata <kazu at cs dot umass dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 04 Oct 2004 12:57:21 -0400 (EDT)
- Subject: [patch] tree-cfg.c: Speed up thread_jumps() - Part 1
Hi,
Attached is a patch to speed up thread_jumps().
Now we have no unreachable block before and after calling
thread_jumps(). Even within thread_jumps(), unreachable blocks are
removed as they arise.
So basically
/* Don't waste time on unreachable blocks. */
if (EDGE_COUNT (bb->preds) == 0)
continue;
does not trigger except for ENTRY_BLOCK_PTR. We don't want to perform
jump threading on ENTRY_BLOCK_PTR anyway, so I can change
FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
to
FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR->nextbb, EXIT_BLOCK_PTR, next_bb)
which is just the same as
FOR_EACH_BB (bb)
The patch removes the useless if and changes FOR_BB_BETWEEN to
FOR_EACH_BB.
Tested on i686-pc-linux-gnu on top of
http://gcc.gnu.org/ml/gcc-patches/2004-10/msg00169.html
http://gcc.gnu.org/ml/gcc-patches/2004-10/msg00186.html
OK to apply?
Kazu Hirata
2004-10-04 Kazu Hirata <kazu@cs.umass.edu>
* tree-cfg.c (thread_jumps): Iterate with FOR_EACH_BB instead
of FOR_BB_BETWEEN. Remove a useless check for unreachable
blocks.
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.64
diff -c -r2.64 tree-cfg.c
*** tree-cfg.c 2 Oct 2004 12:47:10 -0000 2.64
--- tree-cfg.c 3 Oct 2004 19:31:22 -0000
***************
*** 3835,3841 ****
/* Thread jumps over empty statements.
This code should _not_ thread over obviously equivalent conditions
! as that requires nontrivial updates to the SSA graph. */
static bool
thread_jumps (void)
--- 3835,3845 ----
/* Thread jumps over empty statements.
This code should _not_ thread over obviously equivalent conditions
! as that requires nontrivial updates to the SSA graph.
!
! As a precondition, we require that all basic blocks be reachable.
! That is, there should be no opportunities left for
! delete_unreachable_blocks(). */
static bool
thread_jumps (void)
***************
*** 3849,3866 ****
FOR_EACH_BB (bb)
bb_ann (bb)->forwardable = 1;
! FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
{
edge_iterator ei;
! /* Don't waste time on unreachable blocks. */
! if (EDGE_COUNT (bb->preds) == 0)
! continue;
!
! /* Nor on forwarders. */
if (tree_forwarder_block_p (bb))
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. */
--- 3853,3866 ----
FOR_EACH_BB (bb)
bb_ann (bb)->forwardable = 1;
! FOR_EACH_BB (bb)
{
edge_iterator ei;
! /* Don't waste time on forwarders. */
if (tree_forwarder_block_p (bb))
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. */