On Mon, May 13, 2013 at 7:23 PM, DJ Delorie <d...@redhat.com> wrote:
>
>> Can you add that (partial int modes have fewer bits than int modes)
>> as verification to genmodes.c:make_partial_integer_mode?
>
> I could, but it would be a no-op for PARTIAL_INT_MODE()
>
>> I wonder if this should not use GET_MODE_PRECISION - after all it is
>> the precision that determines whether we have to extend / truncate?
>> Or is precision a so much unused term on RTL that this would cause
>> problems?
>
> The problem is, the precision of PSImode *is* the same as SImode,
> if you just use PARTIAL_INT_MODE() in *-modes.def

How can you then ever "truncate" from SImode to PSImode?  That is,
currently we have

          if (GET_MODE_BITSIZE (GET_MODE (op0)) < GET_MODE_BITSIZE
(GET_MODE (op1)))
            op1 = simplify_gen_unary (TRUNCATE, GET_MODE (op0), op1,
                                      GET_MODE (op1));
          else
            /* We always sign-extend, regardless of the signedness of
               the operand, because the operand is always unsigned
               here even if the original C expression is signed.  */
            op1 = simplify_gen_unary (SIGN_EXTEND, GET_MODE (op0), op1,
                                      GET_MODE (op1));

but the case of same precision/bitsize is not handled here.  So, shouldn't it
be then

           if (GET_MODE_BITSIZE (GET_MODE (op0)) == GET_MODE_BITSIZE
(GET_MODE (op1)))
             op1 = convert_move (GET_MODE (op0), op1);
           else if (....

?

That said, special casing PARTIAL_INT_MODEs anywhere looks bogus to me.
Which might mean that PARTIAL_INT_MODEs are bogus... what are they
useful for if they do not even have a precision and share the same bitsize
as their base mode?  Do they even have a "precision"?

> grep PARTIAL_INT_MODE config/*/*.def
config/bfin/bfin-modes.def:PARTIAL_INT_MODE (DI);
config/m32c/m32c-modes.def:PARTIAL_INT_MODE (SI);
config/rs6000/rs6000-modes.def:PARTIAL_INT_MODE (TI);
config/sh/sh-modes.def:PARTIAL_INT_MODE (SI);
config/sh/sh-modes.def:PARTIAL_INT_MODE (DI);

so it shouldn't be difficult to fix that precision thing by adjusting genmodes.c
and the few occurences above?  Make it

config/bfin/bfin-modes.def:PARTIAL_INT_MODE (DI, 40);

btw, what's the relation to fractional int modes?

Richard.

Reply via email to