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: Speed up lv_adjust_loop_header_phi.


Hi,

Attached is a patch to speed up lv_adjust_loop_header_phi by moving a
call to find_edge outside a loop to go through a PHI chain.

The patch also adds a call to gcc_assert to verify that we always find
an edge.  See the comment just above the new gcc_assert.

This is something I should have addressed when I touched this function
after my "O(1) PHI argument look-up" project, but at that time, I just
changed "search for an edge in a PHI array" into "search for an edge
in predecessor vector".  The search itself, namely a call to
find_edge, stayed in the loop.

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

Kazu Hirata

2005-04-26  Kazu Hirata  <kazu@cs.umass.edu>

	* tree-cfg.c (lv_adjust_loop_header_phi): Speed up moving a
	call to find_edge outside a loop to go through a PHI chain.

Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.179
diff -u -d -p -r2.179 tree-cfg.c
--- tree-cfg.c	23 Apr 2005 21:27:56 -0000	2.179
+++ tree-cfg.c	23 Apr 2005 22:14:39 -0000
@@ -5388,6 +5388,11 @@ tree_lv_adjust_loop_header_phi (basic_bl
 				basic_block new_head, edge e)
 {
   tree phi1, phi2;
+  edge e2 = find_edge (new_head, second);
+
+  /* Because NEW_HEAD has been created by splitting SECOND's incoming
+     edge, we should always have an edge from NEW_HEAD to SECOND.  */
+  gcc_assert (e2 != NULL);
 
   /* Browse all 'second' basic block phi nodes and add phi args to
      edge 'e' for 'first' head. PHI args are always in correct order.  */
@@ -5396,13 +5401,8 @@ tree_lv_adjust_loop_header_phi (basic_bl
        phi2 && phi1; 
        phi2 = PHI_CHAIN (phi2),  phi1 = PHI_CHAIN (phi1))
     {
-      edge e2 = find_edge (new_head, second);
-
-      if (e2)
-	{
-	  tree def = PHI_ARG_DEF (phi2, e2->dest_idx);
-	  add_phi_arg (phi1, def, e);
-	}
+      tree def = PHI_ARG_DEF (phi2, e2->dest_idx);
+      add_phi_arg (phi1, def, e);
     }
 }
 


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