This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GCC 3.3 code generation error

Please file a bug report but I still see it on the mainline ().
Also Here is a workaround:
void flash_wait_ready(volatile unsigned *vaddr)
                unsigned temp = *vaddr;
                if (temp != *vaddr)

Andrew Pinski

On Monday, Jun 30, 2003, at 11:50 US/Eastern, Tobias Ringstrom wrote:

Example code:

flash_wait_ready(volatile unsigned *vaddr)
	while (*vaddr != *vaddr)

Using gcc 3.3 (tested with arm-elf and i686-pc-linux-gnu), the loop in the example above is incorrectly removed by the optimizer when using -O. Correct code is generated using -O2, -O3 and -Os. Here is the -O case:

> gcc -S -o - -O tmp.c
	.file	"tmp.c"
.globl flash_wait_ready
	.type	flash_wait_ready, @function
	pushl	%ebp
	movl	%esp, %ebp
	popl	%ebp
	.size	flash_wait_ready, .-flash_wait_ready
	.ident	"GCC: (GNU) 3.3"

It's a regression from GCC 3.2.3 which generates correct code with -O.

[I know the code looks funny, but as the function name indicates I'm waiting for a flash memory to finish. When the flash is busy, two consecutive read accesses will not read the same value.]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]