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]

Re: [patch] Remove loop notes (5/8) -- sh.c


Steven Bosscher wrote:

On Tuesday 14 March 2006 18:09, Joern RENNECKE wrote:


This is not right, you are removing a useful optimization.



Then perhaps you should implement it in some other way,


I've looked at the way REG_FREQ is computed now, and it appears
bb->frequency is usable now. I've attached a patch to use it in
sh_optimize_target_register_callee_saved. I can't test it right now, though,
because of some hardware problems with our servers.


because
unless I'm mistaken you are the SH backend maintainer.

It should really not be the job of a port maintainer to pro-actively remove
everything that someone else thinks is in their way to re-write the compiler.


 Every
time people propose to clean up some part of the compiler, the
SH backend is the only backend that still depends on it and you
complain that it removes an alledgedly useful optimization.

Last time I checked, it is not using CC0, or reg-stack conversion,
or HFmode / TQFmode, or memory-indirect addressing...
A port that does not have some exceptional things is exceptional.  Why
are you picking on the SH?

As
if you haven't known for years that loop notes were going to
disappear.


Well, when Richard Kenner was blocking improvements to loop.c, he didn't
actually say he would remove loop notes although I suppose if he ever had
completed that rewrite, loop notes might have disappeared or changed their
semantics.
However, you can't use a new infrastructure until it is actually put in place,
has the required functionality, and is sufficiently documented. We still have
no documentation how to 'know about loops' in doc/*.texi except for the
description of loop notes.


Is the SH backend in deep maintenance mode, or are you planning
to catch up and drag it into the GCC 3 era at least?


The SH64 (SH5) part is in maintenance mode.  I think it worked best with
gcc 3.2 / 3.3 based sources (although never released as an FSF release).

Support for SH4 is being actively developed.
2006-03-14  J"orn Rennecke <joern.rennecke@st.com>

	* sh.c (sh_optimize_target_register_callee_saved): Use basic block
	frequency instead of loop notes.

Index: sh.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sh/sh.c,v
retrieving revision 1.347
diff -p -r1.347 sh.c
*** sh.c	5 Sep 2005 12:45:22 -0000	1.347
--- sh.c	14 Mar 2006 18:16:45 -0000
*************** static bool
*** 8832,8838 ****
  sh_optimize_target_register_callee_saved (bool after_prologue_epilogue_gen)
  {
    HARD_REG_SET dummy;
!   rtx insn;
  
    if (! shmedia_space_reserved_for_target_registers)
      return 0;
--- 8832,8840 ----
  sh_optimize_target_register_callee_saved (bool after_prologue_epilogue_gen)
  {
    HARD_REG_SET dummy;
!   int threshold;
!   basic_block bb;
!   int labels = 1; /* Each loop has at least one.  */
  
    if (! shmedia_space_reserved_for_target_registers)
      return 0;
*************** sh_optimize_target_register_callee_saved
*** 8842,8867 ****
      return 1;
    /* This is a borderline case.  See if we got a nested loop, or a loop
       with a call, or with more than 4 labels inside.  */
!   for (insn = get_insns(); insn; insn = NEXT_INSN (insn))
!     {
!       if (GET_CODE (insn) == NOTE
! 	  && NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_BEG)
! 	{
! 	  int labels = 0;
! 
! 	  do
! 	    {
! 	      insn = NEXT_INSN (insn);
! 	      if ((GET_CODE (insn) == NOTE
! 		   && NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_BEG)
! 		  || GET_CODE (insn) == CALL_INSN
! 		  || (GET_CODE (insn) == CODE_LABEL && ++labels > 4))
! 		return 1;
! 	    }
! 	  while (GET_CODE (insn) != NOTE
! 		 || NOTE_LINE_NUMBER (insn) != NOTE_INSN_LOOP_END);
! 	}
!     }
    return 0;
  }
  
--- 8844,8872 ----
      return 1;
    /* This is a borderline case.  See if we got a nested loop, or a loop
       with a call, or with more than 4 labels inside.  */
!   threshold = ENTRY_BLOCK_PTR->frequency * 2;
!   FOR_EACH_BB (bb)
!     if (bb->frequency > threshold)
!       {
! 	rtx head = BB_HEAD (bb);
! 	rtx end = BB_END (bb);
! 	rtx insn;
! 
! 	/* ??? We can't really tell which labels belong to the same loop,
! 	   or what the loop nesting is, without loop analysis.
! 	   Approximate by counting all labels in this function that are
! 	   not solely the start of a single-block loop.  */
! 	if (LABEL_P (head)
! 	    && (LABEL_NUSES (head) > 1
! 		|| !JUMP_P (end)
! 		|| !find_reg_note (end, REG_LABEL, head))
! 	    && ++labels > 3)
! 	  return 1;
! 
! 	for (insn = head; insn != end; insn = NEXT_INSN (insn))
! 	  if (GET_CODE (insn) == CALL_INSN)
! 	    return 1;
!       }
    return 0;
  }
  

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