memory-barriers

Are loads and stores the only instructions that gets reordered?

点点圈 提交于 2019-11-26 00:17:06
问题 I have read many articles on memory ordering, and all of them only say that a CPU reorders loads and stores. Does a CPU (I\'m specifically interested in an x86 CPU) only reorders loads and stores, and does not reorder the rest of the instructions that it have? 回答1: Out-of-order execution preserves the illusion of running in program order for a single thread/core . This is like the C/C++ as-if optimization rule: do whatever you want internally as long as visible effects are the same. Separate