This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
SH gcc 2.95.2 _divdi3 miscompiled
- From: "Schirmer, Hartmut" <HSchirmer at Innovative-Systems dot de>
- To: "'gcc-bugs at gcc dot gnu dot org'" <gcc-bugs at gcc dot gnu dot org>
- Cc: "'joern dot rennecke at superh dot com'" <joern dot rennecke at superh dot com>, "'aoliva at redhat dot com'" <aoliva at redhat dot com>
- Date: Wed, 26 Jun 2002 17:46:38 +0200
- Subject: SH gcc 2.95.2 _divdi3 miscompiled
Hi,
Compiler: gcc 2.95.2 cygwin -> sh-hitachi-coff cross
The generated m2/libgcc2.a (big endian) is broken,
__divdi3 is miscompiled. The following function
long long foo(void)
{
long long x, y;
x = -1296760832;
y = -39829;
return x / y;
}
returns 0 instead of the correct value.
Replacing __divdi3.o in libgcc.a with
typedef int word_type __attribute__ ((mode (__word__)));
typedef int DItype __attribute__ ((mode (DI)));
typedef unsigned int UDItype __attribute__ ((mode (DI)));
DItype
__divdi3 (DItype u, DItype v)
{
word_type c = 0;
DItype w;
if (u < 0)
c = ~c, u = -u;
if (v < 0)
c = ~c, v = -v;
w = (UDItype)u / (UDItype)v;
if (c)
w = -w;
return w;
}
fixes the problem
Hartmut