https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114284
Bug ID: 114284 Summary: [14 Regression] arm: Load of volatile short gets miscompiled (loaded twice) Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: acoplan at gcc dot gnu.org Target Milestone: --- The following is a wrong code regression in GCC 14: volatile short x; short foo() { return x; } with -march=armv8-m.base -O2 on the trunk we get: foo: movw r3, #:lower16:.LANCHOR0 movt r3, #:upper16:.LANCHOR0 ldrh r2, [r3] movs r0, #0 ldrsh r0, [r3, r0] bx lr i.e. x is loaded twice, but with GCC 13 we get: foo: movw r3, #:lower16:.LANCHOR0 movt r3, #:upper16:.LANCHOR0 ldrh r0, [r3] sxth r0, r0 bx lr I suppose ideally we would have just one ldrsh, but the GCC 13 code is OK.