Hi,
Loveny Design schrieb:
> I wouldn't have thought the compiler was allowed to re-order statements
> *around* a volatile access. Perhaps someone can help my understanding, given
> :-
> 1: Volatile Statements<sp>
> 2: Statements<sp>
> 3: Volatile Statements<sp>
> where <sp> is a sequence point.
>
> Line 3 has a volatile access and therefore has side-effects that the
> compiler doesn't know about, so surely it must complete all preceeding
> statements up to and including the sequence point before the volatile access
> occurs?
the problem here is that atan() is declared as const, because
it is matematicaly only a "table look up". If you make two or
more calls to atan() with the same parameter, it could be
reduced to one.
That is essential in loops:
for(uint8_t i = 0; i < 32; i++)
{
PORTB = atan(foobar) + i * 2;
}
could be reordered to:
tmp = atan(foobar);
for(uint8_t i = 0; i < 32; i++)
{
PORTB = tmp + i * 2;
}
Alex
_______________________________________________
AVR-GCC-list mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list