[PATCH/RFC] PR target/15130 SH: A tail call optimization problem

Kaz Kojima kkojima@rr.iij4u.or.jp
Fri Apr 30 13:37:00 GMT 2004


Joern Rennecke <joern.rennecke@superh.com> wrote:
>> The appended patch is to take account of this case.  It always
>> scans registers to get an available register in epilogue case.
> 
> It seems to me that this unnecessarily slows down compilation at -O0.
> Could you try to use (epilogue_p && flag_optimize_sibling_calls)
> instead?  This also has the advantage of being more self-documenting.

Sounds a good idea.  It even makes the patch smaller.
How about the patch below?  I'm regtesting it now.

Regards,
	kaz
--
	* config/sh/sh.c (output_stack_adjust): Get a temporary	register
	by scan for epilogue when sibling call optimization is enabled.
	Take account of parmeter registers and static-chain register
	for that case.

--- ORIG/gcc-3.4.0/gcc/config/sh/sh.c	2004-03-09 12:00:12.000000000 +0900
+++ LOCAL/gcc-3.4.0/gcc/config/sh/sh.c	2004-04-30 22:15:17.000000000 +0900
@@ -4571,7 +4571,8 @@ output_stack_adjust (int size, rtx reg, 
 	  /* If TEMP is invalid, we could temporarily save a general
 	     register to MACL.  However, there is currently no need
 	     to handle this case, so just abort when we see it.  */
-	  if (current_function_interrupt
+	  if ((epilogue_p && flag_optimize_sibling_calls)
+	      || current_function_interrupt
 	      || ! call_used_regs[temp] || fixed_regs[temp])
 	    temp = -1;
 	  if (temp < 0 && ! current_function_interrupt)
@@ -4590,7 +4591,7 @@ output_stack_adjust (int size, rtx reg, 
 			CLEAR_HARD_REG_BIT (temps, EH_RETURN_DATA_REGNO (i));
 		    }
 		}
-	      else
+	      if (! epilogue_p || flag_optimize_sibling_calls)
 		{
 		  for (i = FIRST_PARM_REG;
 		       i < FIRST_PARM_REG + NPARM_REGS (SImode); i++)



More information about the Gcc-patches mailing list