https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68616
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hubicka at gcc dot gnu.org --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- arrive_and_wait is known to not clobber ptr and thus GCC can happily CSE ptr over the call. IPA reference computes this for non-address-taken global statics. It's hard to "fix" IPA reference here because it nowadays operates on the IPA-ref list and IIRC there are no "may-ref-all" things we could inject here for atomics. OTOH IIRC nothing was "designed" to handle synchronization points but instead the idea was to rely on aliasing barriers which as can be seen here is not fully sufficient. That said, do we have sth like a "barrier" detection? Because a single atomic load or store certainly isn't one(?). AFAICS only globals that don't have their address taken (thus statics without LTO and some more with LTO) have this issue. IPA-PTA might also compute "interesting" mod/ref info if it were to handle the atomics in some way (I never committed a patch that tried to improve things there because of doubts of semantics...)