This is the mail archive of the gcc-bugs@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: egcs-CVS19980901 (trunk) mips-sgi-irix6.2 bootstrap failure in unroll


This is a problem with the relatively new load_mems loop optimization.
It modifies a label inside a JUMP_INSN, but does not update the JUMP_LABEL
field.  I wrote this patch for it, and tested it with a bootstrap.

I suspect there are other problems here.  It would make more sense to
pass &PATTERN(p) to for_each_rtx, and then deal with other insn fields
like REG_NOTES separately if we change anything.  For instance, if this is an
insn loading a label into a register, then there should be a REG_LABEL note
which needs to be fixed, but for_each_rtx/replace_label won't handle that
currently because it only handles references within a LABEL_REF.  Also, such
an insn is likely to have a REG_EQUAL note containing a LABEL_REF.  The code
would fix that REG_EQUAL note, but then it would increment LABEL_NUSES which
is wrong, because the REG_EQUAL note is not a use of the label, the use is
in the PATTERN of the insn.

However, I think there is a simpler solution to this problem.  An insn
using a label must either have a REG_LABEL note or be a JUMP_INSN.
There is no need to recursively search all rtx.  You can just check
for a REG_LABEL note if it is a INSN or CALL_INSN, and recursively search
PATTERN (p) if it is a JUMP_INSN.  I suspect you can probably even just
check JUMP_LABEL of JUMP_INSN first instead of searching the PATTERN.
If the insn does use end_label, then the REG_NOTES have to be checked and
fixed for INSN and CALL_INSN, and JUMP_LABEL has to be fixed for a JUMP_INSN.
Incidentally, redirect_jump in jump.c is a good and easy way to change a
JUMP_INSN to branch to a different label.  I don't think we have any
convenient routine for fixing an insn that loads a label into a pseudo.

While writing this message, I realized that the comments in my patch are
wrong.  replace_label would not work for JUMP_LABEL, because JUMP_LABEL
does not contain a LABEL_REF, it just points to the label directly.

Wed Sep  2 17:05:04 1998  Jim Wilson  <wilson@cygnus.com>

	* loop.c (load_mems): Fix JUMP_LABEL field after for_each_rtx call.

Index: loop.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/loop.c,v
retrieving revision 1.73
diff -p -r1.73 loop.c
*** loop.c	1998/08/28 11:23:35	1.73
--- loop.c	1998/09/02 23:59:11
*************** load_mems (scan_start, end, loop_top, st
*** 8826,8832 ****
        rr.r2 = label;
  
        for (p = start; p != end; p = NEXT_INSN (p))
! 	for_each_rtx (&p, replace_label, &rr);
      }
  }
  
--- 8826,8843 ----
        rr.r2 = label;
  
        for (p = start; p != end; p = NEXT_INSN (p))
! 	{
! 	  for_each_rtx (&p, replace_label, &rr);
! 
! 	  /* If this is a JUMP_INSN, then we also need to fix the JUMP_LABEL
! 	     field.  This is not handled by for_each_rtx because it doesn't
! 	     handle unprinted ('0') fields.  We need to update JUMP_LABEL
! 	     because the immediately following unroll pass will use it.
! 	     Also, we don't want to use replace_label anyways, because that
! 	     would modify LABEL_NUSES.  */
! 	  if (GET_CODE (p) == JUMP_INSN && JUMP_LABEL (p) == end_label)
! 	    JUMP_LABEL (p) = label;
! 	}
      }
  }
  


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