AMD 250 Computer Hardware User Manual


 
206 Optimizing with SIMD Instructions Chapter 9
25112 Rev. 3.06 September 2005
Software Optimization Guide for AMD64 Processors
9.6 Avoid Moving Data Directly Between
General-Purpose and MMX™ Registers
Optimization
Avoid moving data directly between general-purpose registers and MMX™ registers; this operation
requires the use of the MOVD instruction. If it is absolutely necessary to move data between these
two types of registers, use separate store and load instructions to move the data from the source
register to a temporary location in memory and then from memory into the destination register,
separating the store and the load by at least 10 instructions.
Application
This optimization applies to:
32-bit software
64-bit software
Rationale
The register-to-register forms of the MOVD instruction are either VectorPath or DirectPath Double
instructions. When compared with DirectPath Single instructions, VectorPath and DirectPath Double
instructions have comparatively longer execution latencies. In addition, VectorPath instructions
prevent the processor from simultaneously decoding other insructions.
Example
Avoid code like this, which copies a value directly from an MMX register to a general-purpose
register:
movd eax, mm2
If it is absolutely necessary to copy a value from an MMX register to a general-purpose register (or
vice versa), use separate store and load instructions, separating them by at least 10 instructions:
movd DWORD PTR temp, mm2 ; Store the value in memory.
...
; At least 10 other instructions appear here.
...
mov eax, DWORD PTR temp ; Load the value from memory.