
Use MMX™ Instructions for Integer-Only Work
83
22007E/0—November 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 m any prog ram s it can be advantag eous 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.
Summary of Contents for Athlon Processor x86
Page 1: ...AMD Athlon Processor x86 Code Optimization Guide TM...
Page 12: ...xii List of Figures AMD Athlon Processor x86 Code Optimization 22007E 0 November 1999...
Page 16: ...xvi Revision History AMD Athlon Processor x86 Code Optimization 22007E 0 November 1999...
Page 202: ...186 Page Attribute Table PAT AMD Athlon Processor x86 Code Optimization 22007E 0 November 1999...
Page 252: ...236 VectorPath Instructions AMD Athlon Processor x86 Code Optimization 22007E 0 November 1999...
Page 256: ...240 Index AMD Athlon Processor x86 Code Optimization 22007E 0 November 1999...