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] More aggressive jump bypassing


This is a repost of my "More aggressive jump bypassing" patch from
last June, http://gcc.gnu.org/ml/gcc-patches/2002-06/msg01392.html
The recent patch to split GCSE means that the bad interactions with
GCC's loop optimization passes are no longer a problem.


The current jump bypassing pass uses redirect_edge_and_branch
which works if the edge being directed is an unconditional
branch or the taken branch of a conditional jump.  The patch
below replaces this with a call to redirect_edge_and_branch_force
which can additionally redirect branch not-taken edges, and
unconditional fall-thru edges.

Timings for this patch can be found as "Aggr" in the posting
http://gcc.gnu.org/ml/gcc/2002-09/msg01129.html  [but from
Andreas SPEC runs last night, the relative improvements may
have varied somewhat since September].


The patch below has been tested on i686-pc-linux-gnu with a
full "make bootstrap", all languages except Ada and treelang,
and a complete "make -k check" with no new regressions.

Ok for mainline?


2003-01-16  Roger Sayle  <roger@eyesopen.com>

	* gcse.c (bypass_last_basic_block): New global variable.
	(bypass_block):  Use redirect_edge_and_branch_force to redirect
	fall-through edges.  Use bypass_last_basic_block to determine
	which blocks have valid PRE information.
	(bypass_conditional_jumps): Initialize bypass_last_basic_block.

Index: gcse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcse.c,v
retrieving revision 1.226
diff -c -3 -p -r1.226 gcse.c
*** gcse.c	16 Jan 2003 01:06:32 -0000	1.226
--- gcse.c	16 Jan 2003 15:22:25 -0000
*************** one_cprop_pass (pass, cprop_jumps, bypas
*** 4509,4514 ****
--- 4509,4521 ----

  /* Bypass conditional jumps.  */

+ /* The value of last_basic_block at the beginning of the jump_bypass
+    pass.  The use of redirect_edge_and_branch_force may introduce new
+    basic blocks, but the data flow analysis is only valid for basic
+    block indices less than bypass_last_basic_block.  */
+
+ static int bypass_last_basic_block;
+
  /* Find a set of REGNO to a constant that is available at the end of basic
     block BB.  Returns NULL if no such set is found.  Based heavily upon
     find_avail_set.  */
*************** bypass_block (bb, setcc, jump)
*** 4579,4584 ****
--- 4586,4598 ----
    for (e = bb->pred; e; e = enext)
      {
        enext = e->pred_next;
+       if (e->flags & EDGE_COMPLEX)
+ 	continue;
+
+       /* We can't redirect edges from new basic blocks.  */
+       if (e->src->index >= bypass_last_basic_block)
+ 	continue;
+
        for (i = 0; i < reg_use_count; i++)
  	{
  	  struct reg_use *reg_used = &reg_use_table[i];
*************** bypass_block (bb, setcc, jump)
*** 4612,4623 ****
  	  else
  	    dest = NULL;

- 	  /* Once basic block indices are stable, we should be able
- 	     to use redirect_edge_and_branch_force instead.  */
  	  old_dest = e->dest;
! 	  if (dest != NULL && dest != old_dest
! 	      && redirect_edge_and_branch (e, dest))
! 	    {
  	      /* Copy the register setter to the redirected edge.
  		 Don't copy CC0 setters, as CC0 is dead after jump.  */
  	      if (setcc)
--- 4626,4638 ----
  	  else
  	    dest = NULL;

  	  old_dest = e->dest;
! 	  if (dest != NULL
! 	      && dest != old_dest
! 	      && dest != EXIT_BLOCK_PTR)
!             {
! 	      redirect_edge_and_branch_force (e, dest);
!
  	      /* Copy the register setter to the redirected edge.
  		 Don't copy CC0 setters, as CC0 is dead after jump.  */
  	      if (setcc)
*************** bypass_conditional_jumps ()
*** 4660,4665 ****
--- 4675,4682 ----
    /* Note we start at block 1.  */
    if (ENTRY_BLOCK_PTR->next_bb == EXIT_BLOCK_PTR)
      return 0;
+
+   bypass_last_basic_block = last_basic_block;

    changed = 0;
    FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR->next_bb->next_bb,

Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833


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