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