AMD Athlon Processor x86 Optimization Manual page 4

X86 code optimization
Table of Contents

Advertisement

AMD Athlon™ Processor x86 Code Optimization
Switch Statement Usage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Use Prototypes for All Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Use Const Type Qualifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Generic Loop Hoisting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Declare Local Functions as Static . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Dynamic Memory Allocation Consideration . . . . . . . . . . . . . . . . . . . 25
Introduce Explicit Parallelism into Code . . . . . . . . . . . . . . . . . . . . . . 25
Explicitly Extract Common Subexpressions . . . . . . . . . . . . . . . . . . . 26
C Language Structure Component Considerations . . . . . . . . . . . . . . 27
Avoid Unnecessary Integer Division. . . . . . . . . . . . . . . . . . . . . . . . . . 31
Local Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Select DirectPath Over VectorPath Instructions. . . . . . . . . . . . . . . . 34
Load-Execute Instruction Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Align Branch Targets in Program Hot Spots . . . . . . . . . . . . . . . . . . . 36
Use Short Instruction Lengths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Avoid Partial Register Reads and Writes. . . . . . . . . . . . . . . . . . . . . . 37
Use 8-Bit Sign-Extended Immediates . . . . . . . . . . . . . . . . . . . . . . . . . 38
iv
Optimize Switch Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Use Load-Execute Integer Instructions . . . . . . . . . . . . . . . . . . 34
Floating-Point Operands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Integer Operands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
22007E/0-November 1999
33
Contents

Advertisement

Table of Contents
loading

Table of Contents