This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] tree-cfg.c: Speed up tree_forwarder_block_p.


Hi,

Attached is a patch to speed up tree_forwarder_block_p by reordering
two checks.

The "for" loop immediately below the "if" statement that I am moving
in the patch catches far more non-forwarder blocks than the "if"
statement for an obvious reason.  There are far more basic blocks with
at least one statement than basic blocks that are successors of
ENTRY_BLOCK_PTR. :-)

Here is a timing in seconds for three runs of "./cc1 -quiet -O2
-fomit-frame-pointer -o /dev/null insn-attrtab.i".

      original patched
real:  135.841 134.997 (0.621% down)
user:  133.496 132.616 (0.659% down)

Tested on i686-pc-linux-gnu.  OK to apply?

Kazu Hirata

2004-11-23  Kazu Hirata  <kazu@cs.umass.edu>

	* tree-cfg.c (tree_forwarder_block_p): Speed up by reordering
	two checks.

Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.118
diff -u -d -p -r2.118 tree-cfg.c
--- tree-cfg.c	23 Nov 2004 19:34:35 -0000	2.118
+++ tree-cfg.c	23 Nov 2004 20:09:00 -0000
@@ -3907,9 +3907,6 @@ tree_forwarder_block_p (basic_block bb)
   gcc_assert (bb != ENTRY_BLOCK_PTR);
 #endif
 
-  if (find_edge (ENTRY_BLOCK_PTR, bb))
-    return false;
-
   /* Now walk through the statements.  We can ignore labels, anything else
      means this is not a forwarder block.  */
   for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
@@ -3928,6 +3925,9 @@ tree_forwarder_block_p (basic_block bb)
 	}
     }
 
+  if (find_edge (ENTRY_BLOCK_PTR, bb))
+    return false;
+
   return true;
 }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]