https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71310
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|target |middle-end --- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Segher Boessenkool from comment #4) > This happens because of > > /* Find the smallest nice mode to use. */ > for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode; > mode = GET_MODE_WIDER_MODE (mode)) > if (GET_MODE_BITSIZE (mode) >= bitsize) > break; > > in stor-layout.c:finish_bitfield_representative . This is what the C++ memory model requires. Thus the question is why the store to skb->csum_valid does not honor it. Note the BIT_FIELD_REF is probably due to fold-const.c:optimize_bit_field_compare (IMHO a premature optimization) that in turn just uses get_best_mode. On x86_64 we seem to use byte accesses, the BIT_FIELD_REPRESENTATIVE is SImode (the bitfield has 24 bits, the representative can be max. DImode). So it seems to me that optimize_bit_field_compare is to blame (not matching what RTL expansion would do). I suppose instead of passing word_mode in /* See if we can find a mode to refer to this field. We should be able to, but fail if we can't. */ nmode = get_best_mode (lbitsize, lbitpos, 0, 0, const_p ? TYPE_ALIGN (TREE_TYPE (linner)) : MIN (TYPE_ALIGN (TREE_TYPE (linner)), TYPE_ALIGN (TREE_TYPE (rinner))), word_mode, false); it needs to pass DECL_MODE (DECL_BIT_FIELD_REPRESENTATIVE (field)).