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]

Patch for PR target/28604 (cse.c change)


This patch needs a good review because my only justification for the
change is that it fixes the bug and does not cause any regressions.
I don't really understand why it would be the right thing to do.

The test gcc.c-torture/execute/20050604-1.c started failing on IA64 when
Paul Brook checked in a patch for PR 27363.  That patch put destination
addresses in the cse hash table and then later checks them.  The check
does not cause the problem, it is the insertion of the new data into the
hash table that causes the test suite failure.  The failure is bad code
generation, by the way.

My fix is to not put the stack register into the hash table.  The patch
avoids putting the stack reg, hard stack reg, or argument reg into the
hash table.  Not putting the stack reg in is what fixes the IA64 bug, I
also checked the hard stack reg and the argument reg because it seemed
like a good idea, but it may be that putting the arg reg in is OK, or it
may be that we shouldn't put any hardware regs into the hash table.  I
don't really know.  I am hoping someone with more cse.c knowledge will
look at this patch and either approve it or, with better understanding
of the issues, give me a better fix for the bug.

Here is the patch I tested, it had no regressions on IA64 Linux or HP-UX
and fixed 20050604-1.c on both those platforms.  It also had no
regressions on HPPA HP-UX.

Steve Ellcey
sje@cup.hp.com



2006-09-25  Steve Ellcey  <sje@cup.hp.com>

	PR target/28604
	* cse.c (cse_insn): Don't put frame or arg regs in hash table.


Index: cse.c
===================================================================
--- cse.c	(revision 117190)
+++ cse.c	(working copy)
@@ -6064,8 +6064,16 @@ cse_insn (rtx insn, rtx libcall_insn)
 	  struct table_elt *elt;
 	  enum machine_mode mode;
 	  unsigned hash;
+	  unsigned int regno = 0;
 
-	  if (MEM_P (x))
+	  if (!MEM_P (x))
+	    sets[i].dest_addr_elt = NULL;
+          else if (REG_P (XEXP (x, 0))
+		   && (regno = REGNO (XEXP (x, 0)) == FRAME_POINTER_REGNUM
+		       || regno == HARD_FRAME_POINTER_REGNUM
+		       || regno == ARG_POINTER_REGNUM))
+	    sets[i].dest_addr_elt = NULL;
+	  else
 	    {
 	      x = XEXP (x, 0);
 	      mode = GET_MODE (x);
@@ -6083,8 +6091,6 @@ cse_insn (rtx insn, rtx libcall_insn)
 
 	      sets[i].dest_addr_elt = elt;
 	    }
-	  else
-	    sets[i].dest_addr_elt = NULL;
 	}
     }
 


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