integer*8 parsing problem

Richard Henderson rth@redhat.com
Fri Aug 27 21:13:00 GMT 2004


On Thu, Aug 26, 2004 at 11:29:27PM -0400, David Edelsohn wrote:
> 	The change to gfc_conv_mpz_to_tree has caused the 19990313-N.f
> testsuite regressions on PowerPC systems.  On PowerPC, mp_limb_t is 32
> bits and HOST_WIDE_INT is 64 bits.  Limbs are stored little endian, but
> the extraction function using mpz_getlimbn shifts the lowest numbered limb
> into the most significant word for each HOST_WIDE_INT.

Oops.

> 	Did you consider using mpz_export instead of extracting the limbs
> explicitly for the various cases of mp_limb_t and HWI?  For example,

mpz_export, unfortunately, requires dynamic allocation to get right,
which I'd like to avoid.

> or iterating from count-1 to 0?

That does seem the best solution.  Apparently all of my targets have
sizeof(mp_limb_t) == sizeof(HOST_WIDE_INT).  Can you test this?


r~



Index: trans-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/trans-const.c,v
retrieving revision 1.14
diff -c -p -d -r1.14 trans-const.c
*** trans-const.c	27 Aug 2004 14:49:34 -0000	1.14
--- trans-const.c	27 Aug 2004 21:11:24 -0000
*************** gfc_conv_mpz_to_tree (mpz_t i, int kind)
*** 195,206 ****
  	{
  	  int shift = sizeof (mp_limb_t) * CHAR_BIT;
  	  int n, count = sizeof (HOST_WIDE_INT) / sizeof (mp_limb_t);
! 	  for (low = n = 0; n < count; ++n)
  	    {
  	      low <<= shift;
  	      low |= mpz_getlimbn (i, n);
  	    }
! 	  for (high = 0, n = count; n < 2*count; ++n)
  	    {
  	      high <<= shift;
  	      high |= mpz_getlimbn (i, n);
--- 195,206 ----
  	{
  	  int shift = sizeof (mp_limb_t) * CHAR_BIT;
  	  int n, count = sizeof (HOST_WIDE_INT) / sizeof (mp_limb_t);
! 	  for (low = 0, n = count-1; n >= 0; --n)
  	    {
  	      low <<= shift;
  	      low |= mpz_getlimbn (i, n);
  	    }
! 	  for (high = 0, n = 2*count-1; n >= count; --n)
  	    {
  	      high <<= shift;
  	      high |= mpz_getlimbn (i, n);



More information about the Fortran mailing list