title: Why does GCC use mov/mfence instead of xchg to implement C11's atomic_store?
body: <p>In <a href="http://channel9.msdn.com/Shows/Going+Deep/Cpp-and-Beyond-2012-Herb-Sutter-atomic-Weapons-2-of-2">C++ and Beyond 2012: Herb Sutter - atomic&lt;> Weapons, 2 of 2</a> Herb Sutter argues (around 0:38:20) that one should use <code>xchg</code>, not <code>mov</code>/<code>mfence</code> to implement <code>atomic_store</code> on x86. He also seems to suggest that this particular instruction sequence is what everyone agreed one. However, GCC uses the latter. Why does GCC use this particular implementation?</p>