This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: __fixuns?fSI() lose if long is wider than SI
On Jan 30, 2001, Richard Henderson <rth@redhat.com> wrote:
> On Tue, Jan 30, 2001 at 09:15:09PM -0200, Alexandre Oliva wrote:
>> The functions are indeed supposed to convert to SImode, not word mode,
>> regardless of their bit-widths (at least that's what their names imply).
> Look again -- they all get renamed in libgcc2.h.
I see. Ok to install the revised patch below?
>> Now it seems like it is float_to_si() that shouldn't assume
>> SImode is 32-bits.
> Indeed.
Any suggestions on how to figure out the width of SItype at
compile-time in fp-bit.[hc]?
Index: gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* libgcc2.h (Wtype_MAX, Wtype_MIN): Define.
* libgcc2.c (__fixunssfSI, __fixunsdfSI, __fixunsxfSI): Use
Wtype_MIN instead of LONG_MIN.
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/31 02:31:55
@@ -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.
@@ -198,6 +198,9 @@ typedef int word_type __attribute__ ((mo
#define __NW(a,b) __ ## a ## qi ## b
#define __NDW(a,b) __ ## a ## hi ## b
#endif
+
+#define Wtype_MAX ((Wtype)(((UWtype)1 << (W_TYPE_SIZE - 1)) - 1))
+#define Wtype_MIN (- Wtype_MAX - 1)
#define __muldi3 __NDW(mul,3)
#define __divdi3 __NDW(div,3)
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/31 02:31:56
@@ -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) Wtype_MIN)
+ return (Wtype) (a + Wtype_MIN) - Wtype_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) Wtype_MIN)
+ return (Wtype) (a + Wtype_MIN) - Wtype_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) Wtype_MIN)
+ return (Wtype) (a + Wtype_MIN) - Wtype_MIN;
return (Wtype) a;
}
#endif
--
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