Attached patch emits XCHG instead of store+MFENCE on big cores and generic tuning m_CORE_ALL | m_BDVER | m_ZNVER | m_GENERIC (The tune can be added for other targets, too.) 2019-09-16 Uroš Bizjak PR target/91719 * config/i386/i386.h (TARGET_USE_XCHG_FOR_ATOMIC_STORE): New macro. * config/i386/x86-tune.def (X86_TUNE_USE_XCHG_FOR_ATOMIC_STORE): New. * config/i386/sync.md (atomic_store): emit XCHG for TARGET_USE_XCHG_FOR_ATOMIC_STORE. Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. Committed to mainline SVN. Uros.