This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug optimization/13373] New: optimization with -frerun-cse-after-loop -fexpensive-optimizations produces wrong code on mcore
- From: "olaf at bonorden dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Dec 2003 10:38:45 -0000
- Subject: [Bug optimization/13373] New: optimization with -frerun-cse-after-loop -fexpensive-optimizations produces wrong code on mcore
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Compilation of a crc8 faild:
source:
unsigned short Calc_crc8(unsigned char data, unsigned short crc )
{
unsigned char i,x16,carry;
for (i = 0; i < 8; i++)
{
x16 = (unsigned char)((data & 1) ^ ((unsigned char)crc & 1));
data >>= 1;
if (x16 == 1)
{
crc ^= 0x4002;
carry = 1;
}
else carry = 0;
crc >>= 1;
if (carry)
crc |= 0x8000;
else
crc &= 0x7fff;
}
return crc;
}
-----------
Compilation with "mcore-be-elf-gcc -mbig-endian -O0 -frerun-cse-after-loop
crc.c -S" is ok,
with "mcore-be-elf-gcc -mbig-endian -O0 -frerun-cse-after-loop
-fexpensive-optimizations crc.c -S" the code is not correct.
Part in the produced assembler code:
first version:
ld.h r7,(r8,2)
bgeni r6,14
addi r6,2 // 16386 0x4002
xor r7,r6
st.h r7,(r8,2)
ldw r6,(r8,8)
st.b r6,(r8,6)
wrong second version:
ld.h r7,(r8,2)
st.h r7,(r8,2)
ldw r7,(r8,8)
st.b r7,(r8,6)
The xor part is removed :-(
Compiler without optimization is nearly useless.
--
Summary: optimization with -frerun-cse-after-loop -fexpensive-
optimizations produces wrong code on mcore
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: olaf at bonorden dot de
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: mcore-be-elf
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13373