Compiling a special asm-statment will fail if -O1 -fgcse is set.
>Submitter-Id: net
>Originator: Dieter Schuster
>Organization:
>Confidential: no
>Synopsis: Compiling a special asm-statment will fail if -O1 -fgcse is set.
>Severity: non-critical
>Priority: low
>Category:
>Class: rejects-legal
>Release: 3.4.6 (Debian 3.4.6-1)
>Environment:
System: Linux Pegasos 2.6.16 #3 PREEMPT Sat Apr 8 18:28:12 CEST 2006 ppc GNU/Linux
Architecture: ppc
host: powerpc-unknown-linux-gnu
build: powerpc-unknown-linux-gnu
target: powerpc-unknown-linux-gnu
configured with: ../src/configure -v --enable-languages=c,c++,f77,pascal --prefix=/usr --libexecdir=/usr/lib --with-gxx-include-dir=/usr/include/c++/3.4 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --program-suffix=-3.4 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --disable-softfloat --enable-targets=powerpc-linux,powerpc64-linux --with-cpu=default32 --disable-softfloat powerpc-linux-gnu
>Description:
When compile with gcc-3.4 -O1 -fgcse -c -o qemu-bug.o qemu-bug.c,
there will be the error:
dieter@Pegasos:~/src/qemu-bug$ gcc-3.4 -O1 -fgcse -c -o qemu-bug.o qemu-bug.c
qemu-bug.c: In function `main':
qemu-bug.c:2: error: inconsistent operand constraints in an `asm'
qemu-bug.c:2: error: inconsistent operand constraints in an `asm'
Without -fgcse, there will no error, -O2 -fno-gcse does work as well.
>How-To-Repeat:
# 1 "qemu-bug.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "qemu-bug.c"
inline void stl(void *ptr, int v) {
__asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*(unsigned long *)ptr) : "r" (v), "r" (ptr));
}
int main () {
unsigned long *sp, *u_platform;
char *k_platform;
stl(sp, (unsigned long)(0)); stl(sp+1, (unsigned long)(0));;
if (k_platform)
stl(sp, (unsigned long)(15)); stl(sp+1, (unsigned long)((unsigned long) u_platform));;
return 0;
}
>Fix:
Reply to: