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] cfg.c, cfgrtl.c: Speed up edge insertion


Hi,

Attached is a patch to speed up edge insertion by using VEC_safe_push
instead of VEC_safe_insert.

Note that VEC_safe_insert uses memmove to move multiple elements of a
vector, whereas VEC_safe_push simply appends one element at the end of
a vector.

Here is a timing of compiling preprocessed files for cc1.

      original patched
real:  480.605 477.933 (0.555% down)
user:  466.869 465.091 (0.380% down)

Tested on i686-pc-linux-gnu on top of

http://gcc.gnu.org/ml/gcc-patches/2004-10/msg02061.html

OK to apply?

Kazu Hirata

2004-10-25  Kazu Hirata  <kazu@cs.umass.edu>

	* cfg.c (unchecked_make_edge, redirect_edge_succ,
	redirect_edge_pred): Use VEC_safe_push instead of
	VEC_safe_insert.
	* cfgrtl.c (force_nonfallthru_and_redirect): Likewise.

Index: cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfg.c,v
retrieving revision 1.71
diff -u -p -r1.71 cfg.c
--- cfg.c	22 Oct 2004 22:55:47 -0000	1.71
+++ cfg.c	24 Oct 2004 00:27:29 -0000
@@ -270,8 +270,8 @@ unchecked_make_edge (basic_block src, ba
   e = ggc_alloc_cleared (sizeof (*e));
   n_edges++;
 
-  VEC_safe_insert (edge, src->succs, 0, e);
-  VEC_safe_insert (edge, dst->preds, 0, e);
+  VEC_safe_push (edge, src->succs, e);
+  VEC_safe_push (edge, dst->preds, e);
 
   e->src = src;
   e->dest = dst;
@@ -418,7 +418,7 @@ redirect_edge_succ (edge e, basic_block 
   gcc_assert (found);
 
   /* Reconnect the edge to the new successor block.  */
-  VEC_safe_insert (edge, new_succ->preds, 0, e);
+  VEC_safe_push (edge, new_succ->preds, e);
   e->dest = new_succ;
 }
 
@@ -476,7 +476,7 @@ redirect_edge_pred (edge e, basic_block 
   gcc_assert (found);
 
   /* Reconnect the edge to the new predecessor block.  */
-  VEC_safe_insert (edge, new_pred->succs, 0, e);
+  VEC_safe_push (edge, new_pred->succs, e);
   e->src = new_pred;
 }
 
Index: cfgrtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgrtl.c,v
retrieving revision 1.140
diff -u -p -r1.140 cfgrtl.c
--- cfgrtl.c	22 Oct 2004 22:55:47 -0000	1.140
+++ cfgrtl.c	24 Oct 2004 00:27:29 -0000
@@ -1069,7 +1069,7 @@ force_nonfallthru_and_redirect (edge e, 
 	  
 	  gcc_assert (found);
 	  
-	  VEC_safe_insert (edge, bb->succs, 0, e);
+	  VEC_safe_push (edge, bb->succs, e);
 	  make_single_succ_edge (ENTRY_BLOCK_PTR, bb, EDGE_FALLTHRU);
 	}
     }


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