Prefixes that do not apply to the command are ignored. However, future processors may use this sequence of bytes to encode a new instruction. (Yes, the x86 operations space is so limited that they do crazy things like this, and yes, it complicates the decoders.)
In this case, this means that you can use pause in spinloops without breaking compatibility . Older processors that are not aware of pause will decode it as NOP without prejudice. On new processors, you get the advantage of energy-saving / HT friendliness, and you avoid mistakenly speculating with memory when the memory you rotate into changes and you leave the spin cycle.
Links to Intel manuals and many other useful materials on the wiki x86 help page: / tags / x86 / info
Another case of the meaningless rep prefix, which becomes a new instruction for new processors: lzcnt - F3 0F BD /r . On processors that do not support this instruction (there is no LZCNT function flag in their CPUID), it is decoded as rep bsr , which works the same as bsr . Thus, on older processors, it produces 32 - expected_result and undefined when the input signal was zero.
One case of a meaningless rep prefix that probably will never decode differently: rep ret is used by default by gcc when targeting βsharedβ CPUs (ie, not targeting a specific processor with -march or -mtune ), and don't target AMD K8 or K10.) It will be several decades before anyone can make a processor that decodes rep ret as something other than ret because it is present in most binaries on most Linux distributions. See What does `rep ret` mean?
Peter Cordes Nov 10 '15 at 20:46 2015-11-10 20:46
source share