Instruction reordering
CPU optimization that executes instructions in a different order than the program text, if it doesn't affect single-threaded correctness.
Modern CPUs execute instructions out-of-order to hide memory latency and keep the pipeline full. Instruction D might run before instruction B if they don't depend on each other. In single-threaded code this is invisible (same result). In multithreaded code it's catastrophic: two threads can observe writes in opposite orders, violating the assumption of a globally ordered state. Memory barriers forbid reordering across them. This is why sequential consistency is slow—you need barriers everywhere—and why weaker models like acquire/release exist: they allow reordering where it's safe (within a single thread's dependencies) but prevent it where it matters (between threads).
Textbook example: Thread 1 writes X=1 then Y=1; Thread 2 reads Y then X. Without barriers, Thread 2 can see Y=1 but X=0—a reordering invisible to Thread 1 alone.