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]

Re: avoid try_split recursion on sequence


On Thu, Apr 13, 2000 at 08:17:44PM +0100, grahams wrote:
> Clint
> 
> Clinton Popetz wrote:
> > 
> > I found a case where an attempted split would result in a sequence, the first
> > insn of which was equal to the original insn, so emit-rtl would recurse
> > infinitely.  This behavior is explicitly avoided in the simple (non-sequence
> > case), so its seems appropriate to do the same in the sequence case.
> > 
> > Ok?
> > 
> >                                 -Clint
> > 
> 
> Would it not be prudent to check all insns in the sequence and not just the
> first insn. 
> 
> Graham

Yup.  The prior patch fixed my bug, and tunnel vision kicked in :)

				-Clint


Thu Apr 13 14:03:03 CDT 2000  Clinton Popetz  <cpopetz@cygnus.com>

	* emit-rtl.c (try_split): Avoid infinite loop if the split
	results in a sequence that contains the original insn.

Index: emit-rtl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/emit-rtl.c,v
retrieving revision 1.124
diff -c -2 -p -r1.124 emit-rtl.c
*** emit-rtl.c	2000/04/10 11:51:53	1.124
--- emit-rtl.c	2000/04/13 19:39:44
*************** try_split (pat, trial, last)
*** 2337,2344 ****
        if (GET_CODE (seq) == SEQUENCE)
  	{
  	  /* If we are splitting a JUMP_INSN, look for the JUMP_INSN in
  	     SEQ and copy our JUMP_LABEL to it.  If JUMP_LABEL is non-zero,
  	     increment the usage count so we don't delete the label.  */
- 	  int i;
  
  	  if (GET_CODE (trial) == JUMP_INSN)
--- 2337,2352 ----
        if (GET_CODE (seq) == SEQUENCE)
  	{
+ 	  int i;
+ 
+ 	  /* Avoid infinite loop if any insn of the result matches 
+ 	     the original pattern.  */
+ 	  for (i = 0; i < XVECLEN (seq, 0); i++)
+   	    if (GET_CODE (XVECEXP (seq, 0, i)) == INSN 
+ 		&& rtx_equal_p (PATTERN (XVECEXP (seq, 0, i)), pat))
+   	      return trial;
+ 
  	  /* If we are splitting a JUMP_INSN, look for the JUMP_INSN in
  	     SEQ and copy our JUMP_LABEL to it.  If JUMP_LABEL is non-zero,
  	     increment the usage count so we don't delete the label.  */
  
  	  if (GET_CODE (trial) == JUMP_INSN)

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