summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2023-01-16 12:21:30 -0500
committerBen Gamari <ben@smart-cactus.org>2023-01-16 12:27:41 -0500
commitaf54cf7ddfdd68aa3e628aa63835fb77a7904e1e (patch)
treec9a081f2a748deabbb6b818b76163f6e5cfc9298
parentc79b2b65fff93b4f4e38e5d124f0cb8c6ef704c0 (diff)
downloadhaskell-wip/T22764.tar.gz
nativeGen/X86: MFENCE is unnecessary for release semanticswip/T22764
In #22764 a user noticed that a program implementing a simple atomic counter via an STRef regressed significantly due to the introduction of necessary atomic operations in the MutVar# primops (#22468). This regression was caused by a bug in the NCG, which emitted an unnecessary MFENCE instruction for a release-ordered atomic write. MFENCE is rather only needed to achieve sequentially consistent ordering. Fixes #22764.
-rw-r--r--compiler/GHC/CmmToAsm/X86/CodeGen.hs2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/GHC/CmmToAsm/X86/CodeGen.hs b/compiler/GHC/CmmToAsm/X86/CodeGen.hs
index d407a8a86a..bc0135b920 100644
--- a/compiler/GHC/CmmToAsm/X86/CodeGen.hs
+++ b/compiler/GHC/CmmToAsm/X86/CodeGen.hs
@@ -3936,7 +3936,7 @@ genAtomicWrite width mord addr val = do
code <- assignMem_IntCode (intFormat width) addr val
let needs_fence = case mord of
MemOrderSeqCst -> True
- MemOrderRelease -> True
+ MemOrderRelease -> False
MemOrderAcquire -> pprPanic "genAtomicWrite: acquire ordering on write" empty
MemOrderRelaxed -> False
return $ if needs_fence then code `snocOL` MFENCE else code