Since afterstart = 0, there should be no loop to optimize out except ONE
value test

One hundred cycles for that would seem excessive for me

TWENTY THOUSAND CYCLES for a _zero_ loop?!?

Maybe in Java



El mié, 24 mar 2021 a las 14:30, Gregory Nutt (<spudan...@gmail.com>)
escribió:

>
> > Weird behavior:
> >
> > Simply changing loop counter variable from uint16_t to volatile uint16_t
> > causes initial delay (with variable delay = 0) going from ~500 ns to
> ~120 us
> >
> > The code is
> >
> > uint16_t delay;
> >
> > select_function();
> > for(delay = 0; delay < transfer->dev->afterstart; delay++);
> >
> > Any ideas?
> >
> I imagine that the delay loop is no longer being optimized out. That is
> what volatile is supposed to do (people often don't understand that, it
> is a great interview question).
>

Reply via email to