Use Mmx™ Instructions For Integer-Only Work - AMD Athlon Processor x86 Optimization Manual

X86 code optimization
Table of Contents

Advertisement

22007E/0—November 1999
Use MMX™ Instructions for Integer-Only Work
Use MMX™ Instructions for Integer-Only Work
by 26:
use IMUL
by 27:
LEA
REG2, [REG1*4+REG1]
SHL
REG1, 5
SUB
REG1, REG2
by 28:
MOV
REG2, REG1
SHL
REG1, 3
SUB
REG1, REG2
SHL
REG1, 2
by 29:
LEA
REG2, [REG1*2+REG1]
SHL
REG1, 5
SUB
REG1, REG2
by 30:
MOV
REG2, REG1
SHL
REG1, 4
SUB
REG1, REG2
ADD
REG1, REG1
by 31:
MOV
REG2, REG1
SHL
REG1, 5
SUB
REG1, REG2
by 32:
SHL
REG1, 5
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.
AMD Athlon™ Processor x86 Code Optimization
;3 cycles
;3 cycles
;3 cycles
;3 cycles
;2 cycles
;1 cycle
83

Advertisement

Table of Contents
loading

Table of Contents