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.
- From: Kazu Hirata <kazu at cs dot umass dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 07 Nov 2004 23:59:34 -0500 (EST)
- Subject: [patch] tree-cfg.c: Speed up thread_jumps.
Hi,
Attached is a patch to speed up thread_jumps by keeping a pointer to
the last used element in the worklist.
This trick is used in cfganal.c:find_unreachable_blocks as well.
Note that we get to keep one fewer variables in innermost loops.
Tested on i686-pc-linux-gnu. OK to apply?
Kazu Hirata
2004-11-07 Kazu Hirata <kazu@cs.umass.edu>
* tree-cfg.c (thread_jumps): Speed up by keeping a pointer to
the last used element in the worklist.
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.101
diff -u -d -p -r2.101 tree-cfg.c
--- tree-cfg.c 6 Nov 2004 15:57:25 -0000 2.101
+++ tree-cfg.c 6 Nov 2004 20:10:51 -0000
@@ -3934,7 +3934,7 @@ thread_jumps (void)
basic_block bb;
bool retval = false;
basic_block *worklist = xmalloc (sizeof (basic_block) * last_basic_block);
- unsigned int size = 0;
+ basic_block *current = worklist;
FOR_EACH_BB (bb)
{
@@ -3974,17 +3974,15 @@ thread_jumps (void)
&& !bb_ann (e->src)->forwardable)
{
e->src->flags |= BB_VISITED;
- worklist[size] = e->src;
- size++;
+ *current++ = e->src;
}
}
}
/* Now let's drain WORKLIST. */
- while (size > 0)
+ while (worklist != current)
{
- size--;
- bb = worklist[size];
+ bb = *--current;
/* BB is no longer in WORKLIST, so clear BB_VISITED. */
bb->flags &= ~BB_VISITED;
@@ -4013,8 +4011,7 @@ thread_jumps (void)
&& !bb_ann (f->src)->forwardable)
{
f->src->flags |= BB_VISITED;
- worklist[size] = f->src;
- size++;
+ *current++ = f->src;
}
}
}