This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Loop unrolling
- To: Martin Knoblauch <knobi at rocketmail dot com>
- Subject: Re: Loop unrolling
- From: Lee Iverson <leei at ai dot sri dot com>
- Date: Tue, 02 Jun 1998 09:18:06 -0700
- cc: Stephen Williams <steve at icarus dot icarus dot com>, Gerald Pfeifer <pfeifer at dbai dot tuwien dot ac dot at>, egcs at cygnus dot com
In message <19980602093834.24519.rocketmail@web2.rocketmail.com> you write:
>
> > But the correct way to write an empty loop that
> shouldn't be deleted
> > (a timing loop) already exists:
> >
> > {
> > volatile int i;
> > for (i = 0; i < 10000; ++i);
> > }
> >
>
> Hmm. Does this prevent the loop from being deleted,
> or would it allow the compiler to just assign
> 9999 to "i"?
I don't believe so, since the compiler cannot assume that "i" isn't
modified within the loop. Thus, the compiler can't assume that the
loop even terminates. The only legal option is to increment the index
"i" throughout the loop.
-------------------------------------------------------------------------------
Lee Iverson SRI International
leei@ai.sri.com 333 Ravenswood Ave., Menlo Park CA 94025
http://www.ai.sri.com/~leei/ (650) 859-3307