https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110061
--- Comment #9 from Wilco <wilco at gcc dot gnu.org> --- (In reply to Xi Ruoyao from comment #8) > (In reply to Wilco from comment #7) > > I don't see the issue you have here. GCC for x86/x86_64 has been using > > compare exchange for atomic load (which always does a write even if the > > compare fails) for many years. > > No we don't, since r7-6454. Incorrect - libatomic still uses cmpxchg16b depending on the CPU. > > The question is, do you believe compilers should provide users with fast and > > efficient atomics they need? Or do you want to force every application to > > implement their own version of 128-bit atomics? > > But a compiler must generate correct code first. They can use the wonderful > inline assembly because they know CAS is safe in their case, but the > compiler does not know. Many developers consider locking atomics fundamentally incorrect. If we emit lock-free atomics they don't need to write inline assembler.