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] Fix wrong code with VCE to bit-field type at -O


On Wed, Feb 19, 2014 at 12:55 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> Woudln't it be better to do this in the series of "conversions", that is
>> inside the preceeding if-statement?  (the integral type case using
>> convert_modes looks weird enough, so adding this kind-of "less"
>> weird one there looks sensible)
>
> Yes, the integral type case is very strange: it was introduced in r103660 as
>
> +      /* If both modes are integral, then we can convert from one to the
> +        other.  */
> +      else if (SCALAR_INT_MODE_P (GET_MODE (op0))
> +              && SCALAR_INT_MODE_P (TYPE_MODE (type)))
> +       op0 = convert_modes (TYPE_MODE (type), GET_MODE (op0), op0,
> +                            TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp,
> 0))));
>
> which was very problematic (to say the least), so I've restricted it to
> integral types in r158675.  I don't think that we should touch it here.
>
> Something like the attached patch?  This seems to work fine too.

Yes.  That looks fine.

Thanks,
Richard.

>> Ok with moving it there (before the else if (!MEM_P (op0))).  You
>> probably want to guard with INTEGRAL_TYPE_P (type) as well,
>> not only GET_MODE (op0) != mode - just to prepare for weird
>> stuff like a vector-type where TYPE_PRECISION means sth else.
>
> It's already guarded since reduce_bit_field => INTEGRAL_TYPE_P (type).
>
> --
> Eric Botcazou


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