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


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


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