On Oct 11, 2012, at 2:04 AM, Georg-Johann Lay wrote:

> But to make sure we know what we are talking about, here is a test case.
> 
> typedef struct
> {
>    unsigned char volatile CTRLA;
>    unsigned char volatile CTRLB;
>    unsigned char volatile CTRLC;
>    unsigned char volatile CTRLD;
> } TC0_t;
> 
> void tc0_writeC (void)
> {
>  (*(TC0_t*) 0x0800).CTRL = 0;
> }
> 
> Remember that GCC developers don't know what "TCC0" or "CTRLE" is.
> They don't even know what "AVR" stands for.

Why should they have to know anything about AVR to optimize struct references?

Am suspicious gcc is treating TCC0 as volatile, the address of the struct as 
volatile, while the desire is for the contents to be volatile. Appears to be 
defined as a pointer to a struct of volatiles, but perhaps the volatile 
property is leaking?

Dereferencing TCC0.CTRLE by taking its address and casting it as a pointer may 
strip volatile allowing gcc to optimize. It should be able to optimize anyway.

--
David Kelly N4HHE, dke...@hiwaay.net
============================================================
Whom computers would destroy, they must first drive mad.




_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to