This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Loop unrolling
- To: knobi at rocketmail dot com (Martin Knoblauch)
- Subject: Re: Loop unrolling
- From: Joern Rennecke <amylaar at cygnus dot co dot uk>
- Date: Tue, 2 Jun 1998 17:14:07 +0100 (BST)
- Cc: leei at ai dot sri dot com, steve at icarus dot icarus dot com, pfeifer at dbai dot tuwien dot ac dot at, egcs at cygnus dot com
> > 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"?
AFAIK it prevents current versions of gcc to delete the loop (unless the loop
is unreachable), but the standard's 'as if' rule still allows to optimize
the loop away.