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]

fix typo in reload


In:

r37370 | bernds | 2000-11-10 09:10:29 -0800 (Fri, 10 Nov 2000) | 2 lines

Several fixes to make reload handle POST_MODIFY correctly.

We see:

-regno_clobbered_p (regno, insn, mode)
+regno_clobbered_p (regno, insn, mode, sets)
      unsigned int regno;
      rtx insn;
      enum machine_mode mode;
+     int sets;
 {
   int nregs = HARD_REGNO_NREGS (regno, mode);
   int endregno = regno + nregs;
 
-  if (GET_CODE (PATTERN (insn)) == CLOBBER
+  if ((GET_CODE (PATTERN (insn)) == CLOBBER
+       || (sets && GET_CODE (PATTERN (insn)) == SET))
       && GET_CODE (XEXP (PATTERN (insn), 0)) == REG)
     {
       int test = REGNO (XEXP (PATTERN (insn), 0));
@@ -6578,7 +6592,9 @@ regno_clobbered_p (regno, insn, mode)
       for (; i >= 0; i--)
        {
          rtx elt = XVECEXP (PATTERN (insn), 0, i);
-         if (GET_CODE (elt) == CLOBBER && GET_CODE (XEXP (elt, 0)) == REG)
+         if ((GET_CODE (elt) == CLOBBER
+              || (sets && GET_CODE (PATTERN (insn)) == SET))
+             && GET_CODE (XEXP (elt, 0)) == REG)
            {
              int test = REGNO (XEXP (elt, 0));
              

But, if you examine the PARALLEL code carefully, we discover it doesn't use elt, instead it uses PATTERN (INSN) which is wrong.  :-(

I'd propose:

Index: reload.c
===================================================================
--- reload.c	(revision 180265)
+++ reload.c	(working copy)
@@ -7231,7 +7231,7 @@ regno_clobbered_p (unsigned int regno, r
 	{
 	  rtx elt = XVECEXP (PATTERN (insn), 0, i);
 	  if ((GET_CODE (elt) == CLOBBER
-	       || (sets == 1 && GET_CODE (PATTERN (insn)) == SET))
+	       || (sets == 1 && GET_CODE (elt) == SET))
 	      && REG_P (XEXP (elt, 0)))
 	    {
 	      unsigned int test = REGNO (XEXP (elt, 0));

to fix it.  It fixes my testcase, and I'm doing a regression run now on a normal machine to further test, but I'm pretty sure it is correct.

Ok?

I would ask for 2.6, but, apparently no one else hits this (not in 11 years), so, I think it is safe to punt.

This is the hairy reload bug I've been chasing.  What a PITA to chase down.  You don't want to see my testcase.  20 minutes to compile, the nice thing is, it easily catches things like this.  The english on this is, if you have an instruction, that needs a input and output reload on an operand, and that is resolved by going to memory, and that memory address is sp+const, and that const is too large for a normal displacement and needs to be reloaded into a register, and the main instruction uses a reload register (I think that's true) as output, but that register is dead, then, we would try and use that dead register for the address reload on the input reloads, and on the address reload on the output reloads, but, this register is also the output of the main instruction, which is a PARALLEL with two sets.  Note, that might not be quite enough to trigger.  I also have register classes in play and movements between classes that can't do certain things, like move to memory, or move large numbers into.

Attachment: reload.patch.txt
Description: Text document


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