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]

Dead code removal before sibcall pass


Hi,
this patch enables dead code removal before sibcall pass making more sibcalls
to be discovered.
/* { dg-do compile { target "i?86-*-*" } } */
/* { dg-options "-O2" } */
/* { dg-final { scan-assembler-not "call" } } */
void q()
{ int a;
  t();
  a=1;
}
Wed May 21 23:11:13 CEST 2003  Jan Hubicka  <jh@suse.cz>
	* cfgcleanup.c (cleanup_cfg):  Remove dead code even before sibcall.
	* cse.c (count_reg_usage): Look into call placeholders.
	(insn_live_p): Call placeholders are always live.
	(optimize_sibling_and_tail_recursive_call): Delete trivially dead insns.
*** cfgcleanup.c.old	Wed May 21 14:12:00 2003
--- cfgcleanup.c	Wed May 21 14:12:43 2003
*************** cleanup_cfg (mode)
*** 1895,1902 ****
        changed = true;
        /* We've possibly created trivially dead code.  Cleanup it right
  	 now to introduce more opportunities for try_optimize_cfg.  */
!       if (!(mode & (CLEANUP_NO_INSN_DEL
! 		    | CLEANUP_UPDATE_LIFE | CLEANUP_PRE_SIBCALL))
  	  && !reload_completed)
  	delete_trivially_dead_insns (get_insns(), max_reg_num ());
      }
--- 1895,1901 ----
        changed = true;
        /* We've possibly created trivially dead code.  Cleanup it right
  	 now to introduce more opportunities for try_optimize_cfg.  */
!       if (!(mode & (CLEANUP_NO_INSN_DEL | CLEANUP_UPDATE_LIFE))
  	  && !reload_completed)
  	delete_trivially_dead_insns (get_insns(), max_reg_num ());
      }
*** cse.c.old	Wed May 21 14:06:27 2003
--- cse.c	Wed May 21 14:13:57 2003
*************** count_reg_usage (x, counts, dest, incr)
*** 7499,7504 ****
--- 7499,7515 ----
  		       incr);
        return;
  
+     case CALL_PLACEHOLDER:
+       for (i = 0; i < 3; i++)
+ 	if (XEXP (x, i) != NULL_RTX)
+ 	  {
+ 	    rtx insn;
+ 
+ 	    for (insn = XEXP (x, i); insn; insn = NEXT_INSN (insn))
+ 	      if (INSN_P (insn))
+ 		count_reg_usage (insn, counts, NULL_RTX, incr);
+ 	  }
+       return;
      case CALL_INSN:
        count_reg_usage (CALL_INSN_FUNCTION_USAGE (x), counts, NULL_RTX, incr);
        /* Fall through.  */
*************** insn_live_p (insn, counts)
*** 7587,7592 ****
--- 7598,7605 ----
       int *counts;
  {
    int i;
+   if (GET_CODE (PATTERN (insn)) == CALL_PLACEHOLDER)
+     return true;
    if (flag_non_call_exceptions && may_trap_p (PATTERN (insn)))
      return true;
    else if (GET_CODE (PATTERN (insn)) == SET)
*** ../../../gcc.old/gcc/gcc/sibcall.c	Tue Dec 24 09:30:31 2002
--- sibcall.c	Wed May 21 14:13:16 2003
*************** optimize_sibling_and_tail_recursive_call
*** 582,587 ****
--- 582,588 ----
  
    insns = get_insns ();
  
+   delete_trivially_dead_insns (get_insns(), max_reg_num ());
    cleanup_cfg (CLEANUP_PRE_SIBCALL | CLEANUP_PRE_LOOP);
  
    /* If there are no basic blocks, then there is nothing to do.  */


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