diff mbox

Fix PR middle-end/78642

Message ID 1685148.FU8hdjfjAj@polaris
State New
Headers show

Commit Message

Eric Botcazou Dec. 5, 2016, 10:46 p.m. UTC
Hi,

this fixes the regressions introduced on SPARC by the newly reenabled RTL 
sharing verification.  They come from the special treatment for CLOBBERs:

    case CLOBBER:
   /* Share clobbers of hard registers (like cc0), but do not share pseudo reg
         clobbers or clobbers of hard registers that originated as pseudos.
         This is needed to allow safe register renaming.  */
      if (REG_P (XEXP (x, 0)) && REGNO (XEXP (x, 0)) < FIRST_PSEUDO_REGISTER
	  && ORIGINAL_REGNO (XEXP (x, 0)) == REGNO (XEXP (x, 0)))
	return;

in verify_rtx_sharing, copy_rtx_if_shared_1 and copy_insn_1.  The problem is 
that the property ORIGINAL_REGNO == REGNO is not invariant for hard registers, 
because e.g. the leaf register optimization can change the REGNO.

Therefore the attached patch only checks what's documented in the comment.

Tested on x86-64/Linux and SPARC/Solaris, OK for the mainline?


2016-12-05  Eric Botcazou  <ebotcazou@adacore.com>

	PR middle-end/78642
	* emit-rtl.c (verify_rtx_sharing) <CLOBBER>: Relax condition.
	(copy_rtx_if_shared_1) <CLOBBER>: Likewise.
	(copy_insn_1) <CLOBBER>: Likewise.

-- 
Eric Botcazou

Comments

Jeff Law Dec. 5, 2016, 10:55 p.m. UTC | #1
On 12/05/2016 03:46 PM, Eric Botcazou wrote:
> Hi,

>

> this fixes the regressions introduced on SPARC by the newly reenabled RTL

> sharing verification.  They come from the special treatment for CLOBBERs:

>

>     case CLOBBER:

>    /* Share clobbers of hard registers (like cc0), but do not share pseudo reg

>          clobbers or clobbers of hard registers that originated as pseudos.

>          This is needed to allow safe register renaming.  */

>       if (REG_P (XEXP (x, 0)) && REGNO (XEXP (x, 0)) < FIRST_PSEUDO_REGISTER

> 	  && ORIGINAL_REGNO (XEXP (x, 0)) == REGNO (XEXP (x, 0)))

> 	return;

>

> in verify_rtx_sharing, copy_rtx_if_shared_1 and copy_insn_1.  The problem is

> that the property ORIGINAL_REGNO == REGNO is not invariant for hard registers,

> because e.g. the leaf register optimization can change the REGNO.

>

> Therefore the attached patch only checks what's documented in the comment.

>

> Tested on x86-64/Linux and SPARC/Solaris, OK for the mainline?

>

>

> 2016-12-05  Eric Botcazou  <ebotcazou@adacore.com>

>

> 	PR middle-end/78642

> 	* emit-rtl.c (verify_rtx_sharing) <CLOBBER>: Relax condition.

> 	(copy_rtx_if_shared_1) <CLOBBER>: Likewise.

> 	(copy_insn_1) <CLOBBER>: Likewise.

OK.
jeff
diff mbox

Patch

Index: emit-rtl.c
===================================================================
--- emit-rtl.c	(revision 243245)
+++ emit-rtl.c	(working copy)
@@ -2718,8 +2718,9 @@  verify_rtx_sharing (rtx orig, rtx insn)
       /* Share clobbers of hard registers (like cc0), but do not share pseudo reg
          clobbers or clobbers of hard registers that originated as pseudos.
          This is needed to allow safe register renaming.  */
-      if (REG_P (XEXP (x, 0)) && REGNO (XEXP (x, 0)) < FIRST_PSEUDO_REGISTER
-	  && ORIGINAL_REGNO (XEXP (x, 0)) == REGNO (XEXP (x, 0)))
+      if (REG_P (XEXP (x, 0))
+	  && HARD_REGISTER_NUM_P (REGNO (XEXP (x, 0)))
+	  && HARD_REGISTER_NUM_P (ORIGINAL_REGNO (XEXP (x, 0))))
 	return;
       break;
 
@@ -2970,8 +2971,9 @@  repeat:
       /* Share clobbers of hard registers (like cc0), but do not share pseudo reg
          clobbers or clobbers of hard registers that originated as pseudos.
          This is needed to allow safe register renaming.  */
-      if (REG_P (XEXP (x, 0)) && REGNO (XEXP (x, 0)) < FIRST_PSEUDO_REGISTER
-	  && ORIGINAL_REGNO (XEXP (x, 0)) == REGNO (XEXP (x, 0)))
+      if (REG_P (XEXP (x, 0))
+	  && HARD_REGISTER_NUM_P (REGNO (XEXP (x, 0)))
+	  && HARD_REGISTER_NUM_P (ORIGINAL_REGNO (XEXP (x, 0))))
 	return;
       break;
 
@@ -5521,8 +5523,9 @@  copy_insn_1 (rtx orig)
       /* Share clobbers of hard registers (like cc0), but do not share pseudo reg
          clobbers or clobbers of hard registers that originated as pseudos.
          This is needed to allow safe register renaming.  */
-      if (REG_P (XEXP (orig, 0)) && REGNO (XEXP (orig, 0)) < FIRST_PSEUDO_REGISTER
-	  && ORIGINAL_REGNO (XEXP (orig, 0)) == REGNO (XEXP (orig, 0)))
+      if (REG_P (XEXP (orig, 0))
+	  && HARD_REGISTER_NUM_P (REGNO (XEXP (orig, 0)))
+	  && HARD_REGISTER_NUM_P (ORIGINAL_REGNO (XEXP (orig, 0))))
 	return orig;
       break;