This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch 1/4] change specific int128 -> generic intN


> No stor-layout.c listed here but...

I knew I'd miss at least one in the split-up...

> > Index: gcc/stor-layout.c
> > ===================================================================
> > --- gcc/stor-layout.c	(revision 211858)
> > +++ gcc/stor-layout.c	(working copy)
> > @@ -2123,13 +2142,13 @@ layout_type (tree type)
> > 
> >      case BOOLEAN_TYPE:
> >      case INTEGER_TYPE:
> >      case ENUMERAL_TYPE:
> >        SET_TYPE_MODE (type,
> >  		     smallest_mode_for_size (TYPE_PRECISION (type), MODE_INT));
> > -      TYPE_SIZE (type) = bitsize_int (GET_MODE_BITSIZE (TYPE_MODE (type)));
> > +      TYPE_SIZE (type) = bitsize_int (GET_MODE_PRECISION (TYPE_MODE
> > (type))); TYPE_SIZE_UNIT (type) = size_int (GET_MODE_SIZE (TYPE_MODE
> > (type))); break;
> 
> This doesn't look correct, you might end up with types smaller than their 
> modes and breaking the TYPE_SIZE/TYPE_SIZE_UNIT relationship.

The whole point of using _PRECISION is to have the size be exactly the
same as the mode (bitsize is bigger than the mode for partial-int
modes).  TYPE_SIZE_UNIT should be its storage size, right?  If the
type is not a multiple of BITS_PER_UNIT, the actual size and
stored-in-memory size are going to be different.

The problem in the old code is that BITSIZE is not the size in bits of
the type, it's the size in bytes times BITS_PER_UNIT.  This meant that
all partial-int modes would be converted into their non-partial modes
eventually.  Most of my patch is about avoiding that.

If you still disagree, let's first figure out what the right
relationship between TYPE_SIZE and TYPE_SIZE_UNIT is, for types that
aren't a multiple of BITS_PER_UNIT.

> > @@ -2516,16 +2535,33 @@ initialize_sizetypes (void)
> >      precision = LONG_TYPE_SIZE;
> >    else if (strcmp (SIZETYPE, "long long unsigned int") == 0)
> >      precision = LONG_LONG_TYPE_SIZE;
> >    else if (strcmp (SIZETYPE, "short unsigned int") == 0)
> >      precision = SHORT_TYPE_SIZE;
> >    else
> >     gcc_unreachable ();
> > 
> >    bprecision
> > -    = MIN (precision + BITS_PER_UNIT_LOG + 1, MAX_FIXED_MODE_SIZE);
> > +    = MIN (precision, MAX_FIXED_MODE_SIZE);
> >    bprecision
> >      = GET_MODE_PRECISION (smallest_mode_for_size (bprecision, MODE_INT));
> >    if (bprecision > HOST_BITS_PER_DOUBLE_INT)
> >      bprecision = HOST_BITS_PER_DOUBLE_INT;
> > 
> >    /* Create stubs for sizetype and bitsizetype so we can create constants. 
> 
> Why are you reducing the precision here?

I'm not reducing it, I'm removing a case where it's rounded up.
Rounding up a 20-bit PSImode gives you SImode eventually.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]