This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
wrong code generated in gcc3 (current cvs) for powerpc-eabi
- To: gcc-bugs at gcc dot gnu dot org
- Subject: wrong code generated in gcc3 (current cvs) for powerpc-eabi
- From: Michael Schwingen <michaels at stochastik dot rwth-aachen dot de>
- Date: Wed, 4 Jul 2001 11:44:28 +0200
Hello,
using a fresh checkout of the gcc-3 branch, compiled as a cross-compiler for
powerpc-eabi, I get wrong code in this case:
unsigned short test3(unsigned int a)
{
unsigned short int *p = (unsigned short int *) &a;
return p[0] ^ p[1] ^ 0x55;
}
The generated code is:
test3: stwu 1,-16(1)
lhz 3,8(1) <--- here the value is loaded from the stack
lhz 0,10(1) <--- but R3 was never written to 8(1)!
addi 1,1,16
xor 3,3,0
xori 3,3,85
blr
Thus the function returns a random result (old stack contents) instead of
the intended computed value.
The same happens with 2.95.2
/opt/cgcc2/bin/powerpc-eabi-gcc -v -Wall -O2 -S test5.c
Reading specs from /opt/cgcc2/lib/gcc-lib/powerpc-eabi/3.0.1/specs
Configured with: /usr/local/src/gnu/gcc-3-cvs/gcc/configure
--target=powerpc-eabi --prefix=/opt/cgcc2 --without-headers --with-newlib
Thread model: single
gcc version 3.0.1 20010704 (prerelease)
/opt/cgcc2/lib/gcc-lib/powerpc-eabi/3.0.1/cc1 -lang-c -v -D__GNUC__=3
-D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=1 -DPPC -D__embedded__ -D__PPC__
-D__embedded__ -D__PPC -Asystem=embedded -Acpu=powerpc -Amachine=powerpc
-D__CHAR_UNSIGNED__ -D__OPTIMIZE__ -D__STDC_HOSTED__=1 -Wall -D_CALL_SYSV
-D_BIG_ENDIAN -D__BIG_ENDIAN__ -Amachine=bigendian -D_ARCH_PPC test5.c
-quiet -dumpbase test5.c -O2 -Wall -version -o test5.s
GNU CPP version 3.0.1 20010704 (prerelease) (cpplib) (PowerPC Embedded)
GNU C version 3.0.1 20010704 (prerelease) (powerpc-eabi)
compiled by GNU C version 2.95.2 20000220 (Debian GNU/Linux).
ignoring nonexistent directory "/opt/cgcc2/powerpc-eabi/include"
#include "..." search starts here:
#include <...> search starts here:
/opt/cgcc2/lib/gcc-lib/powerpc-eabi/3.0.1/include
/opt/cgcc2/powerpc-eabi/sys-include
End of search list.