RE: [arm-gnu] Optimization problems with ARM GCC 4.5.1 2010.09-50
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [arm-gnu] Optimization problems with ARM GCC 4.5.1 2010.09-50



> -----Original Message-----
> From: Dirk Behme [mailto:dirk.behme@xxxxxxxxxxxxxx]
> Sent: Wednesday, 22 December 2010 5:14 PM
> To: arm-gnu@xxxxxxxxxxxxxxxx
> Subject: [arm-gnu] Optimization problems with ARM GCC 4.5.1 2010.09-50
> 
...
> In a routine accessing a NAND device, the compiler adds an additional
> "ldrb    r3, [r3]" which breaks the access to the NAND device (the HW
> forbids reading in this state):
> 
...
>   if (cmd != -1)
>    ({ __asm__ __volatile__ ("" : : : "memory"); (*(volatile unsigned
> char *)(this->IO_ADDR_W) = (cmd)); });
> }

Quick guess: you seem to be using a GCC statement-expression there ("({ foo; })").

In this case, your assignment to IO_ADDR_W is the last statement in the statement-expression - so it will get used as the result of the statement-expression. Because of the volatile, this will force a read from IO_ADDR_W (just as "x = (IO_ADDR_W = y);" would).

Try dropping the statement-expression syntax and just using a normal pair of braces ("if {}") instead...

J