Commit f058e367 authored by Ben Gamari's avatar Ben Gamari 🐢 Committed by Marge Bot
Browse files

nativeGen/X86: MFENCE is unnecessary for release semantics

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.
parent 981ff7c4
Pipeline #61806 canceled with stages
in 31 seconds
......@@ -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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment