https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116599
Bug ID: 116599 Summary: volatile generates unexpected RMW on global Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: andi-gcc at firstfloor dot org Target Milestone: --- On x86_64-linux: volatile int a; void f1(void) { a++; } int b; void f2(void) { b++; } generates f1: movl a(%rip), %eax addl $1, %eax movl %eax, a(%rip) ret f2: addl $1, b(%rip) ret I would expect f1 to have the same code as f2.