This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
gcc 2.95, infinite loop in cse optimization pass
- To: egcs-bugs at egcs dot cygnus dot com
- Subject: gcc 2.95, infinite loop in cse optimization pass
- From: Peter Osterlund <peter dot osterlund at mailbox dot swipnet dot se>
- Date: Tue, 15 Jun 1999 23:06:52 +0200 (CEST)
The following code generates an infinite loop in the cse optimization pass
on i686-pc-linux-gnu:
--------------------------------------
void f()
{
extern char* p;
int ch;
while (!(ch = 0)) {
if ((ch == 0) || (ch == 2)) {
break;
}
*p = 0;
}
}
--------------------------------------
The compiler gets to line 7482 in cse.c (in the function cse_insn):
/* Now that we've converted this jump to an unconditional jump,
there is dead code after it. Delete the dead code until we
reach a BARRIER, the end of the function, or a label. Do
not delete NOTEs except for NOTE_INSN_DELETED since later
phases assume these notes are retained. */
p = insn;
while (NEXT_INSN (p) != 0
&& GET_CODE (NEXT_INSN (p)) != BARRIER
&& GET_CODE (NEXT_INSN (p)) != CODE_LABEL)
{
if (GET_CODE (NEXT_INSN (p)) != NOTE
|| NOTE_LINE_NUMBER (NEXT_INSN (p)) == NOTE_INSN_DELETED)
delete_insn (NEXT_INSN (p));
else
p = NEXT_INSN (p);
}
This while loop calls the delete_insn() function in jump.c. It gets to
line 3940:
/* This insn is already deleted => return first following nondeleted. */
if (INSN_DELETED_P (insn))
return next;
The compiler here executes the "return next" statement, and therefore
returns to the while loop in cse.c without any change in state. The result
is an infinite loop.
Any ideas how to debug this further?
--
Peter Österlund Email: peter.osterlund@mailbox.swipnet.se
Sköndalsvägen 35 f90-pos@nada.kth.se
S-128 66 Sköndal Home page: http://home1.swipnet.se/~w-15919
Sweden Phone: +46 8 942647