https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68908
--- Comment #7 from Andrew Macleod <amacleod at redhat dot com> --- (In reply to Richard Henderson from comment #4) > I think we should rather handle this in the front end than with > quite complex pattern matching. > > If we want to do any complex logic with atomics in the middle-end, > we should change their representation so that we don't have to > struggle with a sequence of builtins. Which is clearly a subject > for gcc7 at minimum. Yes, I think anything more complex than this should be part of an atomics optimization framework using a new set of ATOMIC gimple ops rather than builtins. For the purpose of this PR we ought to just fix it in the FE.