sign-extending smaller modes

Geoff Keating geoffk@cygnus.com
Tue Aug 8 12:27:00 GMT 2000


The new trunc_int_for_mode logic seems a little complex.  Wouldn't
it be simpler as:

HOST_WIDE_INT
trunc_int_for_mode (c, mode)
     HOST_WIDE_INT c;
     enum machine_mode mode;
{
  int width = GET_MODE_BITSIZE (mode);

  /* If MODE is smaller than a HOST_WIDE_INT, perform sign-extension.  */

  if (width < HOST_BITS_PER_WIDE_INT)
    c = ((c & (((HOST_WIDE_INT) 1 << (width - 1)) - 1)
	 | -( c & ((HOST_WIDE_INT) 1 << (width - 1))))

  return c;
}

immed_double_const could be changed in a similar way.

Jeffrey A Law <law@cygnus.com> writes:

> Interestingly enough, if I install your change I can't bootstrap the
> PA port, so there's something happening that we don't quite understand.

I suspect this is a bug somewhere else.  One of the structural
problems with gcc is that it doesn't make a proper distinction between
arithmetic on the host and arithmetic on the target for integer
values.  This causes lots and lots of problems whenever they differ.

What was the failure mode?

> FWIW, I think your problem can just as easily be fixed by fixing the
> MIPS backend.  ie, by sign extending constants in the SImode patterns from
> 32 to 64 bits you'll avoid the assembler complaint which originally lead
> you to this problem.

It'd be better to fix the underlying problem, though, which is that we are 
representing (SImode)-1 in multiple different ways.

-- 
- Geoffrey Keating <geoffk@cygnus.com>


More information about the Gcc-patches mailing list