This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
__fixuns?fSI() lose if long is wider than SI
- To: gcc-patches at gcc dot gnu dot org
- Subject: __fixuns?fSI() lose if long is wider than SI
- From: Alexandre Oliva <aoliva at redhat dot com>
- Date: 29 Jan 2001 02:26:27 -0200
- Organization: GCC Team, Red Hat
On a port with 64-bit longs, __fixuns?fSI() lose, because LONG_MIN
will be wider than SImode. config/fp-bit.c's float_to_si will end up
returning MAX_SI_INT if the exponent is larger than 30, which is what
the test in fixuns?fSI was supposed to ensure.
This patch fixes it, hopefully without any ill effects to 16-bit
ports. Ok to install?
Index: gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* libgcc2.h (SItype_MAX, SItype_MIN): Define.
* libgcc2.c (__fixunssfSI, __fixunsdfSI, __fixunsxfSI): Use
SItype_MIN instead of LONG_MIN.
Index: gcc/libgcc2.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/libgcc2.c,v
retrieving revision 1.113
diff -u -p -r1.113 libgcc2.c
--- gcc/libgcc2.c 2001/01/28 01:50:06 1.113
+++ gcc/libgcc2.c 2001/01/29 04:21:03
@@ -1,7 +1,7 @@
/* More subroutines needed by GCC output code on some machines. */
/* Compile this one with gcc. */
-/* Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
- 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+ 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -1145,8 +1145,8 @@ __floatdisf (DWtype u)
UWtype
__fixunsxfSI (XFtype a)
{
- if (a >= - (DFtype) LONG_MIN)
- return (Wtype) (a + LONG_MIN) - LONG_MIN;
+ if (a >= - (DFtype) SItype_MIN)
+ return (Wtype) (a + SItype_MIN) - SItype_MIN;
return (Wtype) a;
}
#endif
@@ -1167,8 +1167,8 @@ __fixunsxfSI (XFtype a)
UWtype
__fixunsdfSI (DFtype a)
{
- if (a >= - (DFtype) LONG_MIN)
- return (Wtype) (a + LONG_MIN) - LONG_MIN;
+ if (a >= - (DFtype) SItype_MIN)
+ return (Wtype) (a + SItype_MIN) - SItype_MIN;
return (Wtype) a;
}
#endif
@@ -1189,8 +1189,8 @@ __fixunsdfSI (DFtype a)
UWtype
__fixunssfSI (SFtype a)
{
- if (a >= - (SFtype) LONG_MIN)
- return (Wtype) (a + LONG_MIN) - LONG_MIN;
+ if (a >= - (SFtype) SItype_MIN)
+ return (Wtype) (a + SItype_MIN) - SItype_MIN;
return (Wtype) a;
}
#endif
Index: gcc/libgcc2.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/libgcc2.h,v
retrieving revision 1.13
diff -u -p -r1.13 libgcc2.h
--- gcc/libgcc2.h 2001/01/24 03:03:12 1.13
+++ gcc/libgcc2.h 2001/01/29 04:21:03
@@ -1,5 +1,5 @@
/* Header file for libgcc2.c. */
-/* Copyright (C) 2000
+/* Copyright (C) 2000, 2001
Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -103,6 +103,14 @@ typedef int TItype __attribute__ ((mod
typedef unsigned int UTItype __attribute__ ((mode (TI)));
#endif
#endif
+#endif
+
+#if MIN_UNITS_PER_WORD > 1
+# define SItype_MAX ((SItype)(((USItype)1 << 31) - 1))
+# define SItype_MIN (- SItype_MAX - 1)
+#else
+# define SItype_MAX ((long)(((unsigned long)1 << 31) - 1))
+# define SItype_MIN (- SItype_MAX - 1)
#endif
#if BITS_PER_UNIT == 8
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me