General Optimization Guidelines
2
2-81
•
Processing an instruction with the 0x66 prefix that (i) has a modr/m
byte in its encoding and (ii) the opcode byte of the instruction
happens to be aligned on byte 14 of an instruction fetch line. The
performance delay in this case is approximately twice of those other
two situations.
Assembly/Compiler Coding Rule 49. (ML impact, M generality) Avoid
using a length changing prefix on instructions with immediate values. The most
common scenario for this is using an 0x66 prefix for 16-bit immediate in 32-bit
code. Also avoid using the 0x66 prefix in conjunction with the 0xF7 opcode
group of instructions.
Assembly/Compiler Coding Rule 50. (ML impact, L generality) When there
is a need to use 0x66 prefix in an instruction requiring a modr/m byte, consider
adjusting code alignment by adding a nop before the instruction to avoid the
opcode byte aligning on byte 14 from the beginning of an instruction fetch line.
REP Prefix and Data Movement
The REP prefix is commonly used with string move instructions for
memory related library functions such as memcpy (using rep movsd) or
memset (using rep stos). These string/mov instructions with the REP
prefixes are implemented in MS-ROM and have several implementation
variants with different performance levels.
The specific variant of the implementation is chosen at execution time
based on data layout, alignment and the counter (ecx) value. For
example, movsb/stosb with REP prefix should be used with counter
value less or equal than three for best performance.
Table 2-4
Avoiding False LCP Delays with 0xF7 Group Instructions
A Sequence Causing Delay
in the Decoder
Alternate Sequence to Avoid Delay
neg word ptr a
movsx eax,word ptr a
neg eax
mov word ptr a,ax
Summary of Contents for ARCHITECTURE IA-32
Page 1: ...IA 32 Intel Architecture Optimization Reference Manual Order Number 248966 013US April 2006...
Page 220: ...IA 32 Intel Architecture Optimization 3 40...
Page 434: ...IA 32 Intel Architecture Optimization 9 20...
Page 514: ...IA 32 Intel Architecture Optimization B 60...
Page 536: ...IA 32 Intel Architecture Optimization C 22...