RFC: #pragma optimization_level
E. Weddington
ericw@evcohs.com
Fri Apr 1 22:40:00 GMT 2005
Georg Bauhaus wrote:
>
> We have just been discussing a similar topic in a de.* newsgroup.
> A busy-loop function is used to effect a delay, not too precise,
> but portably. Like
>
> #define COUNT 1000
>
> void f() {
> /*volatile*/ /*register*/ int i;
>
> for (i = 0; i < COUNT; ++i)
> ;
> }
>
> If volatile is used to instruct the compiler to actually produce
> a loop even when optimizing, then we get copying from/to the stack,
> or memory access (ARM). What the compiler users have expected their
> compiler to do is to produce an obvious loop using registers.
>
What do you get if you use the C99 construct of declaring the variable
in the for statement? Like so:
for(volatile int i = 0; i < COUNT; ++i);
Eric
More information about the Gcc
mailing list