This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Loop unrolling


>  > 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]