The mfence documentation says the following:
Performs a serializing operation on all load-from-memory and store-to-memory instructions that were issued prior the MFENCE instruction. This serializing operation guarantees that every load and store instruction that precedes the MFENCE instruction in program order becomes globally visible before any load or store instruction that follows the MFENCE instruction.
As far as I know, there is no fence instruction in x86 that prevents the reordering of non read and non write instructions.
Now if my program only have one thread, even if the instructions are reordered, it would still seem as if the instructions are executing in order.
But what if my program have multiple threads, and in one of the threads the non read and non write instructions are reordered, will the other threads notice this reordering (I assume the answer is No, or else there would be a fence instruction to stop the non read and non write instructions reordering, or maybe I'm missing something)?
rdtsc, then the difference becomes architecturally-visible as a value in a register. But that's a very specific case. Fun fact: on Skylake at least,mfencein practice does prevent reordering of all instructions, likelfence. Are loads and stores the only instructions that gets reordered?. This is an implementation detail though; on paper it only blocks reordering of memory instructions. (But it's part of why the Linux kernel for example has reverted tolock or [rsp], 0instead of MFENCE) - Peter Cordes