PATCH: Re: ICE in 920624-1.c with -O3 -funroll-loops on vax-dec-ultrix4.3

John David Anglin dave@hiauly1.hia.nrc.ca
Mon Feb 4 16:04:00 GMT 2002


> On Tue, Jan 15, 2002 at 06:16:14PM -0500, John David Anglin wrote:
> > This patch fixes the problem by deleting the jump table data when a
> > conditional or computed jump is converted to an unconditional jump.
> > I have verified that the patch fixes the original problem observed
> > under vax-dec-ultrix4.3.  A new vax bootstrap is underway but it
> > won't finish until sometime next month.
> 
> This is extremely delicate.  It is not uncommon for there to 
> be references remaining to the jump table that won't be deleted
> until later dead code elimination.
> 
> I'm therefore uncomfortable with simply removing it like this.
> I'm not sure what to suggest as an alternative though...

Does this look better?  The patch no longer removes the jump table.
It simply changes the branch destination to a new label following
the jump table when it detects that the target of the jump is the
following insn.  The subsequent flow analysis deletes the unused jump
table.  This should only happen on the vax.

Tested on vax-dec-ultrix4.3 and various PA builds for the last month.

OK?

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

2002-01-16	John David Anglin  <dave@hiauly1.hia.nrc.ca>

	* cse.c (cse_insn): Fix the destination of unconditional jumps to an
	immediately following code label, followed by jump table data.

--- cse.c.orig	Wed Jan 16 12:28:28 2002
+++ cse.c	Wed Jan 16 16:50:26 2002
@@ -5767,9 +5767,30 @@
 	 be a conditional or computed branch.  */
       else if (dest == pc_rtx && GET_CODE (src) == LABEL_REF)
 	{
-	  /* Now emit a BARRIER after the unconditional jump.  */
-	  if (NEXT_INSN (insn) == 0
-	      || GET_CODE (NEXT_INSN (insn)) != BARRIER)
+	  rtx next = NEXT_INSN (insn);
+	  rtx tmp;
+
+	  /* If there is jump table data after the jump and its destination
+	     is now the code label preceding the jump table, change the
+	     destination to a new label after the jump table.  This kludge
+	     is needed on the VAX because fold_rtx uses the label before
+	     the jump table in folding a case insn.  */
+	  if (next != NULL_RTX
+	      && LABEL_P (next)
+	      && (tmp = NEXT_INSN (next)) != NULL_RTX
+	      && JUMP_TABLE_DATA_P (tmp)
+	      && XEXP (src, 0) == next)
+	    {
+	      rtx label = gen_label_rtx ();
+	      emit_label_after (label, tmp);
+	      XEXP (src, 0) = label;
+	      --LABEL_NUSES (next);
+	      ++LABEL_NUSES (label);
+	    }
+
+	  /*  Now emit a BARRIER after the unconditional jump.  */
+	  if (next == NULL_RTX
+	      || GET_CODE (next) != BARRIER)
 	    emit_barrier_after (insn);
 
 	  /* We reemit the jump in as many cases as possible just in



More information about the Gcc-patches mailing list