https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113106
--- Comment #7 from Uroš Bizjak <ubizjak at gmail dot com> --- (In reply to Richard Biener from comment #6) > > BTW: I also checked with clang, and it creates expected code in all cases. > > But you don't get > > movl %gs:b(%rip), %eax > addl %eax, %eax > > or > > movl b(%rip), %eax > addl %eax, %eax > > which I think would be wrong. The volatile access doesn't need to yield > the same value as the non-volatile one so we can't value-number them the > same. The above is the code that clang produces for the testcases in Comment #2 and Comment #0. clang version 15.0.7 (Fedora 15.0.7-2.fc37)