On Mon, Jul 25, 2011 at 4:56 PM, Sebastian Pop <seb...@gmail.com> wrote:
> On Mon, Jul 25, 2011 at 03:41, Richard Guenther <rguent...@suse.de> wrote:
>> I think we also need to care for non-integral PHIs where TYPE_PRECISION
>> and TYPE_UNSIGNED are not applicable (seems the original code is also
>> buggy here?).  So, sth like
>>
>>  type = TREE_TYPE (res);
>>  if (!is_gimple_reg (res)
>>      || !INTEGRAL_TYPE_P (type)
>>      || TYPE_PRECISION (type) < precision)
>>    continue;
>>
>>  precision = TYPE_PRECISION (type);
>>  unsigned_p |= TYPE_UNSIGNED (type);
>> }
>>
>
> This would not work optimally on the following sequence:
> unsigned char
> signed short
> as we would set the unsigned_p to true for the "unsigned char" and
> then we would not reset the value of unsigned_p when the precision
> increases.  So what about doing this instead:
>
>  type = TREE_TYPE (res);
>  if (!is_gimple_reg (res)
>      || !INTEGRAL_TYPE_P (type)
>      || TYPE_PRECISION (type) < precision)
>    continue;
>
>  if (TYPE_PRECISION (type) > precision)
>    unsigned_p = TYPE_UNSIGNED (type);
>  else
>    unsigned_p |= TYPE_UNSIGNED (type);
>
>  precision = TYPE_PRECISION (type);

Ah, indeed.  Yes, fine with me.

Thanks,
Richard.

> Thanks,
> Sebastian
>

Reply via email to