This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/13309] New: Incorrect code generated for __udivdi3
- From: "jch50 at comcast dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Dec 2003 00:29:02 -0000
- Subject: [Bug target/13309] New: Incorrect code generated for __udivdi3
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
GCC 3.3.1 was configured as follows:
~/mips-tools0/gcc-3.3.1/configure --target=mips-elf
--prefix=/usr/local/tools/mips-elf --enable-languages=c,c++ --with-gnu-as
--with-gnu-ld --with-newlib
--with-gxx-include-dir=/usr/local/tools/mips-elf/include -v 2>&
Binutils 2.14 was configured as follows:
~/mips-tools0/binutils-2.14/configure --target=mips-elf
--prefix=/usr/local/tools/mips-elf
It appears that __udivdi3 (libgcc2.c) contains incorrect code. Specifically,
mips-elf-objdump -D libgcc.a
....
....
cc: 006b0018 mult v1,t3
d0: 00002812 mflo a1
d4: 00c5182b sltu v1,a2,a1
d8: 1060000a beqz v1,104 <__udivdi3+0x104>
dc: 0147001b divu zero,t2,a3
e0: 00cc3021 addu a2,a2,t4
e4: 00cc102b sltu v0,a2,t4
e8: 14400006 bnez v0,104 <__udivdi3+0x104>
ec: 2529ffff addiu t1,t1,-1
f0: 00c5102b sltu v0,a2,a1
f4: 10400003 beqz v0,104 <__udivdi3+0x104>
f8: 00000000 nop
fc: 2529ffff addiu t1,t1,-1
100: 00cc3021 addu a2,a2,t4
104: 00c53023 subu a2,a2,a1
108: 00c7001b divu zero,a2,a3
10c: 31e4ffff andi a0,t7,0xffff
110: 14e00002 bnez a3,11c <__udivdi3+0x11c>
114: 00000000 nop
118: 0007000d break 0x7
11c: 00001812 mflo v1
120: 00001010 mfhi v0
The results from the first divu are never accessed, and a second divu is issued
before the first one has completed. This appears to cause problems for r3000.
The following code produces incorrect results:
externC void cyg_start( void )
{
volatile unsigned long long a = 0x23e3;
volatile unsigned long long b = 0x15;
volatile unsigned long c;
c = a/b;
}
mips-elf-gcc -c -I/home/chouston/ecos-projects/test0/test0_install/include
-I/home/chouston/ecos/packages/hal/common/current
-I/home/chouston/ecos/packages/hal/common/current/src
-I/home/chouston/ecos/packages/hal/common/current/tests -I.
-I/home/chouston/ecos/packages/hal/common/current/tests/ -mips1 -EB -msoft-float
-Wall -Wpointer-arith -Wstrict-prototypes -Winline -Wundef -g -O2
-ffunction-sections -fdata-sections -fno-exceptions -G0
-Wp,-MD,tests/context.tmp -o tests/context.o
/home/chouston/ecos/packages/hal/common/current/tests/context.c
--
Summary: Incorrect code generated for __udivdi3
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jch50 at comcast dot net
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux
GCC host triplet: i686-pc-linux
GCC target triplet: mips-elf-unkown
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13309