https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66364
Bug ID: 66364 Summary: poor optimization of packed structs containing bitfields Product: gcc Version: 5.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: rogero at howzatt dot demon.co.uk Target Milestone: --- Target: x86_64-redhat-linux Created attachment 35667 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35667&action=edit Simple program demonstrating the issue Code accessing bitfields in packed structures seem to load the value a byte at a time and build the value up using shifts and ors even with -O3. On x64 it could load the value using a single mov instruction as it does when the struct is not packed or when the field is not a bitfield.