This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Loop unrolling
- To: gavin at cygnus dot com (Gavin Romig-Koch)
- Subject: Re: Loop unrolling
- From: Joern Rennecke <amylaar at cygnus dot co dot uk>
- Date: Tue, 2 Jun 1998 21:59:58 +0100 (BST)
- Cc: amylaar at cygnus dot co dot uk, knobi at rocketmail dot com, 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
> > 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.
>
> No. The "volatile" requires the compiler to keep the implied
> loads and stores, dispite the as-if rule, and thus the loop is
> not empty, and thus not deleted.
i has automatic storage, and its address is never taken, so the compiler
might decide to allocate this object to some 'write-only-memory'.
This object has the property that you can have an implied store of any value
or a read at any desired point of time in the program execution,
without requiring any actual instructions.
Let's say our target needs a minimum time of '1' to executa an actual
instruction. So you could have:
time t0: nop
time t0+0.00001 i := 0
time t0+0.00002 read i
time t0+0.00003 i := 1
time t0+0.00004 read i
...
time t0+0.19999 i := 9999
time t0+0.20000 read i
time t0+0.20001 i := 10000
time t0+0.20002 read i
time t0+1: nop