user manual

Use MMX Instructions for Integer-Only Work 83
22007E/0November 1999 AMD Athlon Processor x86 Code Optimization
by 26: use IMUL
by 27: LEA REG2, [REG1*4+REG1] ;3 cycles
SHL REG1, 5
SUB REG1, REG2
by 28: MOV REG2, REG1 ;3 cycles
SHL REG1, 3
SUB REG1, REG2
SHL REG1, 2
by 29: LEA REG2, [REG1*2+REG1] ;3 cycles
SHL REG1, 5
SUB REG1, REG2
by 30: MOV REG2, REG1 ;3 cycles
SHL REG1, 4
SUB REG1, REG2
ADD REG1, REG1
by 31: MOV REG2, REG1 ;2 cycles
SHL REG1, 5
SUB REG1, REG2
by 32: SHL REG1, 5 ;1 cycle
Use MMX Instructions for Integer-Only Work
In many programs it can be advantageous to use MMX
instructions to do integer-only work, especially if the function
already uses 3DNow! or MMX code. Using MMX instructions
relieves register pressure on the integer registers. As long as
data is simply loaded/stored, added, shifted, etc., MMX
instructions are good substitutes for integer instructions.
Integer registers are freed up with the following results:
May be able to reduce the number of integer registers to
saved/restored on function entry/edit.
Free up integer registers for pointers, loop counters, etc., so
that they do not have to be spilled to memory, which
reduces memory traffic and latency in dependency chains.
Be careful with regards to passing data between MMX and
integer registers and of creating mismatched store-to-load
forwarding cases. See Unrolling Loops on page 67.