This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Loop unroll fixes
- To: mark at codesourcery dot com (Mark Mitchell)
- Subject: Re: Loop unroll fixes
- From: Zoltan Hidvegi <hzoli at hzoli dot 2y dot net>
- Date: Thu, 25 Oct 2001 01:14:37 -0500 (CDT)
- Cc: hzoli at hzoli dot 2y dot net, wilson at cygnus dot com, gcc-patches at gcc dot gnu dot org,bernds at redhat dot com, Franz dot Sirl-kernel at lauterbach dot com
> > Actually, what I am doing in not an optimization, my patch does not
> > make any loop that is correctly infinite in the current gcc version
> > finite. This this fix could be applied, then the infinite loop bug
> > can be addressed in a different patch. I would argue that infinite
> > loop is a different bug I that did not address, but opinions can
> > differ on that.
>
> I'm not sure I understand, but let me try to say what I think you're
> saying. :-)
>
> You're saying that GCC has a long-standing bug whereby some infinite
> loops terminate, and that your patch does not introduce any new
> occurrences of this bug. Is that right?
Exactly. The bug is present in 3.0, but not in 2.95.x since that did
not use ctr loops. E.g. this fails with gcc 2.95.x or any later
version and also with IBM cc on PowerPC. Note that this is not a real
testcase, I do not know how to check for a real infinite loop. It is
difficult to write a test, because any function call or extra exit
point inside the loop will prevent the use of the ctr, thus the bug
goes away.
void abort(void);
int
infinite(int c)
{
int i;
int ct = 0;
for (i = (~0ul >> 1) - 3; i <= c; i++)
ct++;
return ct;
}
int
main(void)
{
if (infinite(~0ul >> 1))
abort();
return 0;
}
If you change i++ above to i += 2, then 2.95.x will pass this because
it will not use a ctr loop, but gcc-3.0 and up still fails.
Zoli