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: Mon, 17 Feb 2014 14:34:54 +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> <CAFiYyc0DkOJOt=LdhS1kCk1a+=9wm4e3bH8YHRLvD+ZJKz0TUA at mail dot gmail dot com> <4495646 dot AFB2flPmAD at polaris> <1629803 dot uCIxAQNden at polaris>
On Mon, Feb 17, 2014 at 11:27 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> There is nothing obvious I think, i.e. that's debatable. I agree that a VCE
>> from a 32-bit object to a 32-bit integer with 24-bit precision should not
>> clear the upper 8 bits (so the REDUCE_BIT_FIELD part of my patch is wrong).
>> But here we have a VCE from a 24-bit object to a 32-bit integer with 24-bit
>> precision which reads *more bits* than the size of the source type; that I
>> think is plain wrong and is fixed by the bit-field extraction in the patch.
>
> Revised patch along these lines attached. Although I agree that it's a bit of
> a kludge, it's quite localized and plausible IMO.
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)
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.
Thanks,
Richard.
>
> * expr.c (expand_expr_real_1) <case VIEW_CONVERT_EXPR>: For a bit-field
> destination type, extract exactly the number of valid bits if the source
> type isn't integral or has a different precision.
>
>
> --
> Eric Botcazou