target/3506: weird behaviour when incrementing volatile ints

Matthias Klose doko@klose.in-berlin.de
Sun Jul 1 09:06:00 GMT 2001


>Number:         3506
>Category:       target
>Synopsis:       weird behaviour when incrementing volatile ints
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          pessimizes-code
>Submitter-Id:   net
>Arrival-Date:   Sun Jul 01 09:06:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     herbert@gondor.apana.org.au
>Release:        3.0 (Debian GNU/Linux) and HEAD 20010701
>Organization:
The Debian project
>Environment:
System: Debian GNU/Linux (testing/unstable)
Architecture: i686
	
host: i386-linux
build: i386-linux
target: i386-linux
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,objc --prefix=/usr --infodir=/share/info --mandir=/share/man --enable-shared --with-gnu-as --with-gnu-ld --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking --enable-threads=posix --enable-java-gc=boehm --with-cpp-install-dir=bin --enable-objc-gc i386-linux
>Description:
[ Reported to the Debian BTS as report #89949.
  Please CC 89949-quiet@bugs.debian.org on replies.
  Log of report can be found at http://bugs.debian.org/89949 ]
 	
gcc generates non-intuitive code when one tries to increment a volatile int.

extern int x;
extern volatile int y;

void f() {
	x++;
	y++;
}

The move into %eax seems pointless.

----------------------------------- 
gcc-3.0 and gcc CVS HEAD 20010701: 
        .file   "bug-89949.i" 
        .text 
        .align 2 
.globl f 
        .type   f,@function 
f: 
        pushl   %ebp 
        movl    %esp, %ebp 
        incl    x 
        movl    y, %eax 
        incl    %eax 
        movl    %eax, y 
        popl    %ebp 
        ret 
.Lfe1: 
        .size   f,.Lfe1-f 
        .ident  "GCC: (GNU) 3.1 20010701 (experimental)" 
----------------------------------- 
gcc-3.0 and gcc CVS HEAD 20010701 -O2: 
        .file   "bug-89949.i" 
        .text 
        .align 2 
        .p2align 2,,3 
.globl f 
        .type   f,@function 
f: 
        pushl   %ebp 
        movl    y, %eax 
        movl    %esp, %ebp 
        incl    %eax 
        incl    x 
        popl    %ebp 
        movl    %eax, y 
        ret 
.Lfe1: 
        .size   f,.Lfe1-f 
        .ident  "GCC: (GNU) 3.1 20010701 (experimental)" 
----------------------------------- 
>How-To-Repeat:
	
>Fix:
	
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list