Patchwork [4/6] Shrink-wrapping

login
register
mail settings
Submitter Alan Modra
Date Aug. 3, 2011, 10:41 a.m.
Message ID <20110803104143.GI26813@bubble.grove.modra.org>
Download mbox | patch
Permalink /patch/108105/
State New
Headers show

Comments

Alan Modra - Aug. 3, 2011, 10:41 a.m.
On Thu, Jul 28, 2011 at 12:35:46PM +0200, Bernd Schmidt wrote:
[snip]
> 	* rtl.h (ANY_RETURN_P): New macro.
[snip]

This patch makes rebuild_jump_labels set JUMP_LABEL appropriately
for return jumps, and fixes sharing for RETURN.  Since ANY_RETURN_P(X)
is defined as ((X) == ret_rtx), RETURNs need to stay shared.
Bootstrapped and regression tested powerpc-linux and powerpc64-linux.
OK to apply?

	PR rtl-optimization/49941
	* jump.c (mark_jump_label): Comment.
	(mark_jump_label_1): Set JUMP_LABEL for return jumps.
	* emit-rtl.c (copy_rtx_if_shared_1, copy_insn_1): Leave RETURN shared.
	(mark_used_flags): Don't mark RETURN.
Bernd Schmidt - Aug. 3, 2011, 11:18 a.m.
On 08/03/11 12:41, Alan Modra wrote:
> This patch makes rebuild_jump_labels set JUMP_LABEL appropriately
> for return jumps, and fixes sharing for RETURN.  Since ANY_RETURN_P(X)
> is defined as ((X) == ret_rtx), RETURNs need to stay shared.
> Bootstrapped and regression tested powerpc-linux and powerpc64-linux.
> OK to apply?
> 
> 	PR rtl-optimization/49941
> 	* jump.c (mark_jump_label): Comment.
> 	(mark_jump_label_1): Set JUMP_LABEL for return jumps.
> 	* emit-rtl.c (copy_rtx_if_shared_1, copy_insn_1): Leave RETURN shared.
> 	(mark_used_flags): Don't mark RETURN.

Ok, thanks.


Bernd

Patch

Index: gcc/jump.c
===================================================================
--- gcc/jump.c	(revision 177084)
+++ gcc/jump.c	(working copy)
@@ -1039,6 +1039,7 @@  sets_cc0_p (const_rtx x)
    notes.  If INSN is an INSN or a CALL_INSN or non-target operands of
    a JUMP_INSN, and there is at least one CODE_LABEL referenced in
    INSN, add a REG_LABEL_OPERAND note containing that label to INSN.
+   For returnjumps, the JUMP_LABEL will also be set as appropriate.
 
    Note that two labels separated by a loop-beginning note
    must be kept distinct if we have not yet done loop-optimization,
@@ -1081,6 +1082,14 @@  mark_jump_label_1 (rtx x, rtx insn, bool
     case CALL:
       return;
 
+    case RETURN:
+      if (is_target)
+	{
+	  gcc_assert (JUMP_LABEL (insn) == NULL || JUMP_LABEL (insn) == x);
+	  JUMP_LABEL (insn) = x;
+	}
+      return;
+
     case MEM:
       in_mem = true;
       break;
Index: gcc/emit-rtl.c
===================================================================
--- gcc/emit-rtl.c	(revision 177084)
+++ gcc/emit-rtl.c	(working copy)
@@ -2724,6 +2724,7 @@  repeat:
     case CODE_LABEL:
     case PC:
     case CC0:
+    case RETURN:
     case SCRATCH:
       /* SCRATCH must be shared because they represent distinct values.  */
       return;
@@ -2843,6 +2844,7 @@  repeat:
     case CODE_LABEL:
     case PC:
     case CC0:
+    case RETURN:
       return;
 
     case DEBUG_INSN:
@@ -5257,6 +5259,7 @@  copy_insn_1 (rtx orig)
     case CODE_LABEL:
     case PC:
     case CC0:
+    case RETURN:
       return orig;
     case CLOBBER:
       if (REG_P (XEXP (orig, 0)) && REGNO (XEXP (orig, 0)) < FIRST_PSEUDO_REGISTER)