On Thu, 13 Oct 2022, Andre Vieira (lists) wrote:

> Added some extra comments to describe what is going on there.

Just to note I was confused and DECL_FIELD_OFFSET can indeed be
different (but then are guaranteed to be constant), so the patch
looks correct.

> On 13/10/2022 09:14, Richard Biener wrote:
> > On Wed, 12 Oct 2022, Andre Vieira (lists) wrote:
> >
> >> Hi,
> >>
> >> The bitposition calculation for the bitfield lowering in loop if conversion
> >> was not
> >> taking DECL_FIELD_OFFSET into account, which meant that it would result in
> >> wrong bitpositions for bitfields that did not end up having representations
> >> starting at the beginning of the struct.
> >>
> >> Bootstrappend and regression tested on aarch64-none-linux-gnu and
> >> x86_64-pc-linux-gnu.
> > +    {
> > +      tree bf_pos = fold_build2 (MULT_EXPR, bitsizetype,
> > +                                DECL_FIELD_OFFSET (field_decl),
> > +                                build_int_cst (bitsizetype, 8));
> > +      bf_pos = fold_build2 (PLUS_EXPR, bitsizetype, bf_pos,
> > +                           DECL_FIELD_BIT_OFFSET (field_decl));
> > +      tree rep_pos = fold_build2 (MULT_EXPR, bitsizetype,
> > +                                 DECL_FIELD_OFFSET (rep_decl),
> > +                                 build_int_cst (bitsizetype, 8));
> > +      rep_pos = fold_build2 (PLUS_EXPR, bitsizetype, rep_pos,
> > +                            DECL_FIELD_BIT_OFFSET (rep_decl));
> >
> > you can use the invariant that DECL_FIELD_OFFSET of rep_decl
> > and field_decl are always the same.  Also please use BITS_PER_UNIT
> > instead of '8'.
> >
> > Richard.
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg,
Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman;
HRB 36809 (AG Nuernberg)

Reply via email to