This is the mail archive of the gcc-bugs@gcc.gnu.org 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]

[Bug optimization/11381] New: [regression] volatile memory access optimized away


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11381

           Summary: [regression] volatile memory access optimized away
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tori at unhappy dot mine dot nu
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu

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


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