[PATCH] Fix SCHED_GROUP_P ICEs on v850

Roger Sayle roger@www.eyesopen.com
Sun Jan 19 15:49:00 GMT 2003


The following patch fixes two ICEs building mainline GCC on v850.
Both occur building libstdc++-v3/include/bits/istream.tcc:

internal compiler error: RTL flag check: SCHED_GROUP_P used with
unexpected rtx code `note' in can_schedule_ready_p, at sched-rgn.c:2123

The code in question looks like:

>	while (SCHED_GROUP_P (insn))
>	  insn = PREV_INSN (insn);

Examining the other examples of looping over SCHED_GROUP_P in
sched-rgn.c, it appears the correct fix it to use prev_nonnote_insn.
Making this change, gets us very slightly further:

internal compiler error: RTL flag check: SCHED_GROUP_P used with
unexpected rtx code `note' in move_insn, at haifa-sched.c:1774

This is an identical problem, and can be resolved using the same
idiom, replacing PREV_INSN with prev_nonnote_insn.

With these two changes I'm able to successfully build a cross-compiler
from i686-pc-linux-gnu to v850-elf, and run the testsuite on v850-sim.
The patch has also been tested with a complete bootstrap, all languages
except Ada and treelang, on i686-pc-linux-gnu, and a full "make -k check"
with no new regressions.


Could a scheduling expert confirm this is indeed the correct fix?
Ok for mainline?


2003-01-19  Roger Sayle  <roger@eyesopen.com>

	* sched-rgn.c (can_schedule_ready_p): Use prev_nonnote_insn
	instead of PREV_INSN to avoid ICE in SCHED_GROUP_P.
	* haifa-sched.c (move_insn): Likewise.

Index: sched-rgn.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/sched-rgn.c,v
retrieving revision 1.56
diff -c -3 -p -r1.56 sched-rgn.c
*** sched-rgn.c	17 Jan 2003 00:00:18 -0000	1.56
--- sched-rgn.c	19 Jan 2003 15:37:09 -0000
***************
*** 1,6 ****
  /* Instruction scheduling pass.
!    Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998,
!    1999, 2000, 2001, 2002 Free Software Foundation, Inc.
     Contributed by Michael Tiemann (tiemann@cygnus.com) Enhanced by,
     and currently maintained by, Jim Wilson (wilson@cygnus.com)

--- 1,6 ----
  /* Instruction scheduling pass.
!    Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
!    2000, 2001, 2002, 2003 Free Software Foundation, Inc.
     Contributed by Michael Tiemann (tiemann@cygnus.com) Enhanced by,
     and currently maintained by, Jim Wilson (wilson@cygnus.com)

*************** can_schedule_ready_p (insn)
*** 2121,2127 ****

        temp = insn;
        while (SCHED_GROUP_P (temp))
! 	temp = PREV_INSN (temp);

        /* Update source block boundaries.  */
        b1 = BLOCK_FOR_INSN (temp);
--- 2121,2127 ----

        temp = insn;
        while (SCHED_GROUP_P (temp))
! 	temp = prev_nonnote_insn (temp);

        /* Update source block boundaries.  */
        b1 = BLOCK_FOR_INSN (temp);
Index: haifa-sched.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/haifa-sched.c,v
retrieving revision 1.216
diff -c -3 -p -r1.216 haifa-sched.c
*** haifa-sched.c	17 Jan 2003 00:00:17 -0000	1.216
--- haifa-sched.c	19 Jan 2003 15:37:10 -0000
***************
*** 1,6 ****
  /* Instruction scheduling pass.
!    Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998,
!    1999, 2000, 2001, 2002 Free Software Foundation, Inc.
     Contributed by Michael Tiemann (tiemann@cygnus.com) Enhanced by,
     and currently maintained by, Jim Wilson (wilson@cygnus.com)

--- 1,6 ----
  /* Instruction scheduling pass.
!    Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
!    2000, 2001, 2002, 2003 Free Software Foundation, Inc.
     Contributed by Michael Tiemann (tiemann@cygnus.com) Enhanced by,
     and currently maintained by, Jim Wilson (wilson@cygnus.com)

*************** move_insn (insn, last)
*** 1773,1779 ****
       insns with SCHED_GROUP_P set first.  */
    while (SCHED_GROUP_P (insn))
      {
!       rtx prev = PREV_INSN (insn);

        /* Move a SCHED_GROUP_P insn.  */
        move_insn1 (insn, last);
--- 1773,1779 ----
       insns with SCHED_GROUP_P set first.  */
    while (SCHED_GROUP_P (insn))
      {
!       rtx prev = prev_nonnote_insn (insn);

        /* Move a SCHED_GROUP_P insn.  */
        move_insn1 (insn, last);

Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833



More information about the Gcc-patches mailing list