Yes, he's showing xchg
there (full barrier and an RMW operation), not just a mov
store - a plain mov
would be below the SC-DRF bar because it doesn't provide sequential consistency on its own without mfence
or other barrier.
Compare ARM64 stlr
/ ldar
- they can't reorder with each other (not even StoreLoad), but stlr
can reorder with other later operations, except of course other release-store operations, or some fences. (Like I mentioned in answer to your previous question). See also Does STLR(B) provide sequential consistency on ARM64? re: interaction with ldar
for SC vs. ldapr
for just acquire
/ release
or acq_rel
. Also Possible orderings with memory_order_seq_cst and memory_order_release for another example of how AArch64 compiles (without ARMv8.3 LDAPR).
But x86 seq_cst stores drain the store buffer on the spot, even if there is no later seq_cst load, store, or RMW in the same thread. This lack of reordering with later non-SC or non-atomic loads/stores is what makes it stronger (and more expensive) than necessary.
Herb Sutter explained this earlier in the video, at around 36:00. He points out xchg
is stronger than necessary, not just an SC-release that can one-way reorder with later non-SC operations. "So what we have here, is overkill. Much stronger than is necessary" at 36:30
(Side note: right around 36:00, he mis-spoke: he said "we're not going to use these first 3 guarantees" (that x86 doesn't reorder loads with loads or stores with stores, or stores with older loads). But those guarantees are why SC load can be just a plain mov
. Same for acq/rel being just plain mov
for both load and store. That's why as he says, lfence
and sfence
are irrelevant for std::atomic.)
So anyway, ARM64 can hit the sweet spot with no extra barrier instructions, being exactly strong enough for seq_cst but no stronger. (ARMv8.3 with ldapr
is slightly stronger than acq_rel
requires, e.g. ARM64 still forbids IRIW reordering, but only a few machines can do that in practice, notably POWER)
Other ISAs with both L and S below the bar need extra barriers as part of their seq_cst load and seq_cst store recipes (https://www.cl.cam.ac.uk/~pes20/cpp/cpp0xmappings.html).