This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
GCC 3.3 code generation error
- From: Tobias Ringstrom <tobias at ringstrom dot mine dot nu>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 30 Jun 2003 17:50:30 +0200
- Subject: GCC 3.3 code generation error
Example code:
void
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"
.text
.globl flash_wait_ready
.type flash_wait_ready, @function
flash_wait_ready:
pushl %ebp
movl %esp, %ebp
popl %ebp
ret
.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.]
/Tobias