public inbox for
help / color / mirror / Atom feed
Subject: optimization/6806: gcc 3.0.4 ignoring clobbered registers in inline asm with -O1 or higher on i386
Date: Fri, 24 May 2002 18:56:00 -0000	[thread overview]
Message-ID: <> (raw)

>Number:         6806
>Category:       optimization
>Synopsis:       gcc 3.0.4 ignoring clobbered registers in inline asm with -O1 or higher on i386
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Fri May 24 18:26:01 PDT 2002
>Originator:     Michael Niedermayer
>Release:        gcc version 3.0.4
Linux MichaelsNB 2.4.18custom1 #1 Mit Mai 15 23:14:08 CEST 2002 i686 unknown
output from gcc -v:
Reading specs from /usr/lib/gcc-lib/i386-linux/3.0.4/specs
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
Thread model: posix
gcc version 3.0.4
volatile int f=64;
		"addl %6, %0		\n\t"
		:"+r" (out)
		:"r" (a), "r" (b), "r" (c), "g" (d), "g" (e), "g"(f)
		: "%eax", "%esi"
gcc puts f into eax even though eax is on the clobberlist
compile the attached file with gcc -O1 and run it
a possible workaround is to force specific registers instead of using "r"(...)
Content-Type: text/plain; name="gcc-test.i"
Content-Disposition: inline; filename="gcc-test.i"

# 1 "gcc-test.c"
volatile int out=1;
volatile int a=2;
volatile int b=4;
volatile int c=8;
volatile int d=16;
volatile int e=32;
volatile int f=64;

int main(){
        int err=0;
        asm volatile(
                "xorl %%eax, %%eax	\n\t"
                "xorl %%esi, %%esi	\n\t"
                "addl %1, %0		\n\t"
                "addl %2, %0		\n\t"
                "addl %3, %0		\n\t"
                "addl %4, %0		\n\t"
                "addl %5, %0		\n\t"
                "addl %6, %0		\n\t"
                :"+r" (out)
                :"r" (a), "r" (b), "r" (c), "g" (d), "g" (e), "g"(f)
                : "%eax", "%esi"

                printf("test1: ok\n");
                printf("test1: fail %d\n", 127-out);
        return err;

             reply	other threads:[~2002-05-25  1:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-24 18:56 michaelni [this message]
2002-05-28 10:16 rth
2003-05-14 23:16 Dara Hazeghi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).