This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
const_double garbage
- To: egcs-patches at cygnus dot com
- Subject: const_double garbage
- From: Richard Henderson <rth at cygnus dot com>
- Date: Fri, 3 Jul 1998 17:35:57 -0700
- Reply-To: Richard Henderson <rth at cygnus dot com>
Seems we are none too clean about our handling of real-valued
constants. I noticed this when trying to figure out why to
builds of 104.hydra had distressingly different constants as
early as .rtl. Of course the answer is that the second word
on a real-valued const_double is, on an alpha, unused. And
so was never being initialized.
While the real.h and varasm.c changes are straightforward, I
also seek opinion on the print-rtl.c change. It makes things
easier imho to figure out what's what.
r~
* print-rtl.c (print_rtx): Display the real-value equivalent of
a const_double when easy.
* real.h (REAL_VALUE_TO_TARGET_SINGLE): Use a union to pun types.
Zero memory first for predictability.
(REAL_VALUE_TO_TARGET_DOUBLE): Likewise.
* varasm.c (immed_real_const_1): Notice width of H_W_I == double.
Index: print-rtl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/print-rtl.c,v
retrieving revision 1.9
diff -c -p -d -r1.9 print-rtl.c
*** print-rtl.c 1998/06/29 21:40:02 1.9
--- print-rtl.c 1998/07/04 00:22:49
*************** Boston, MA 02111-1307, USA. */
*** 23,28 ****
--- 23,29 ----
#include "system.h"
#include "rtl.h"
#include "bitmap.h"
+ #include "real.h"
/* How to print out a register name.
*************** print_rtx (in_rtx)
*** 267,272 ****
--- 268,282 ----
format_ptr[-1]);
abort ();
}
+
+ #if HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
+ if (GET_CODE (in_rtx) == CONST_DOUBLE && FLOAT_MODE_P (GET_MODE (in_rtx)))
+ {
+ double val;
+ REAL_VALUE_FROM_CONST_DOUBLE (val, in_rtx);
+ fprintf (outfile, " [%.16g]", val);
+ }
+ #endif
fprintf (outfile, ")");
sawclose = 1;
Index: real.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/real.h,v
retrieving revision 1.7
diff -c -p -d -r1.7 real.h
*** real.h 1998/05/05 23:17:21 1.7
--- real.h 1998/07/04 00:22:49
*************** typedef struct {
*** 264,273 ****
value in host format and then to a single type `long' value which
is the bitwise equivalent of the `float' value. */
#ifndef REAL_VALUE_TO_TARGET_SINGLE
! #define REAL_VALUE_TO_TARGET_SINGLE(IN, OUT) \
! do { float f = (float) (IN); \
! (OUT) = *(long *) &f; \
! } while (0)
#endif
/* Convert a type `double' value in host format to a pair of type `long'
--- 264,281 ----
value in host format and then to a single type `long' value which
is the bitwise equivalent of the `float' value. */
#ifndef REAL_VALUE_TO_TARGET_SINGLE
! #define REAL_VALUE_TO_TARGET_SINGLE(IN, OUT) \
! do { \
! union { \
! float f; \
! HOST_WIDE_INT l; \
! } u; \
! if (sizeof(HOST_WIDE_INT) < sizeof(float)) \
! abort(); \
! u.l = 0; \
! u.f = (IN); \
! (OUT) = u.l; \
! } while (0)
#endif
/* Convert a type `double' value in host format to a pair of type `long'
*************** do { float f = (float) (IN); \
*** 275,292 ****
proper word order for the target. */
#ifndef REAL_VALUE_TO_TARGET_DOUBLE
#define REAL_VALUE_TO_TARGET_DOUBLE(IN, OUT) \
! do { REAL_VALUE_TYPE in = (IN); /* Make sure it's not in a register. */\
! if (HOST_FLOAT_WORDS_BIG_ENDIAN == FLOAT_WORDS_BIG_ENDIAN) \
! { \
! (OUT)[0] = ((long *) &in)[0]; \
! (OUT)[1] = ((long *) &in)[1]; \
! } \
! else \
! { \
! (OUT)[1] = ((long *) &in)[0]; \
! (OUT)[0] = ((long *) &in)[1]; \
! } \
! } while (0)
#endif
#endif /* HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT */
--- 283,302 ----
proper word order for the target. */
#ifndef REAL_VALUE_TO_TARGET_DOUBLE
#define REAL_VALUE_TO_TARGET_DOUBLE(IN, OUT) \
! do { \
! union { \
! REAL_VALUE_TYPE f; \
! HOST_WIDE_INT l[2]; \
! } u; \
! if (sizeof(HOST_WIDE_INT) * 2 < sizeof(REAL_VALUE_TYPE)) \
! abort(); \
! u.l[0] = u.l[1] = 0; \
! u.f = (IN); \
! if (HOST_FLOAT_WORDS_BIG_ENDIAN == FLOAT_WORDS_BIG_ENDIAN) \
! (OUT)[0] = u.l[0], (OUT)[1] = u.l[1]; \
! else \
! (OUT)[1] = u.l[0], (OUT)[0] = u.l[1]; \
! } while (0)
#endif
#endif /* HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT */
Index: varasm.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/varasm.c,v
retrieving revision 1.36
diff -c -p -d -r1.36 varasm.c
*** varasm.c 1998/06/25 15:14:30 1.36
--- varasm.c 1998/07/04 00:22:49
*************** immed_real_const_1 (d, mode)
*** 2070,2075 ****
--- 2070,2077 ----
else if (! REAL_VALUE_ISNAN (d) && REAL_VALUES_EQUAL (dconst1, d))
return CONST1_RTX (mode);
+ if (sizeof u == sizeof (HOST_WIDE_INT))
+ return immed_double_const (u.i[0], 0, mode);
if (sizeof u == 2 * sizeof (HOST_WIDE_INT))
return immed_double_const (u.i[0], u.i[1], mode);