https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94600
Bug ID: 94600 Summary: Ignored volatile specifier on loop unrolling and bitfield misoptimization Product: gcc Version: 10.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: hp at gcc dot gnu.org Target Milestone: --- Host: x86_64-unknown-linux-gnu Target: arm-eabi, cris-elf, aarch64-linux Created attachment 48275 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48275&action=edit test-case in need of decoration for the gcc test-suite. Compile e.g. at -O2 or -Os. Observe the unwieldy code in function foo compiled at -O2 or -Os for any of the listed targets (and likely many more, except curiously not x86_64 and i386). Compare this to the compiled bar; nice as expected. Note in particular the reads in the generated code from the LHS specified as volatile and which is only stored into in the source code. Note also the smaller-than-struct-sized stores. The latter may be target-dependent but the reads should not happen anywhere.