This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] Fix wrong code with VCE to bit-field type at -O
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Eric Botcazou <ebotcazou at adacore dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Martin Jambor <mjambor at suse dot cz>
- Date: Wed, 19 Feb 2014 13:22:33 +0100
- Subject: Re: [patch] Fix wrong code with VCE to bit-field type at -O
- Authentication-results: sourceware.org; auth=none
- References: <1407954 dot 7L4M0YkQRE at polaris> <1629803 dot uCIxAQNden at polaris> <CAFiYyc0vfGTJJEf-OAn=QMwVyB9BguWpu6dZ2SyqT8+MbyP2rg at mail dot gmail dot com> <1794584 dot qd02N220UF at polaris>
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