User's Manual

Index 237
22007E/0November 1999 AMD Athlon Processor x86 Code Optimization
Index
Numerics
3DNow! Instructions . . . . . . . . . . . . . . . . . . . . . . . . . .10, 107
3DNow! and MMX Intra-Operand Swapping . . . . . . . 112
Clipping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
Fast Division . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Fast Square Root and Reciprocal Square Root . . . . . . . 110
FEMMS Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
PAVGUSB for MPEG-2 Motion Compensation. . . . . . . . 123
PFCMP Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
PFMUL Instruction. . . . . . . . . . . . . . . . . . . . . . . . . . 113
114
PI2FW Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
PREFETCH and PREFETCHW Instructions. 8
, 4647, 49
PSWAPD Instruction . . . . . . . . . . . . . . . . . . . . . . . .112
, 126
Scalar Code Translated into 3DNow! Code . . . . . . . . 61
64
A
Address Generation Interlocks . . . . . . . . . . . . . . . . . . . . . . . 72
AMD Athlon Processor
Branch-Free Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Code Padding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Family. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Microarchitecture . . . . . . . . . . . . . . . . . . . . . . . . .4
, 129130
AMD Athlon System Bus . . . . . . . . . . . . . . . . . . . . . . . . . 139
B
Blended Code, AMD-K6 and AMD Athlon Processors
3DNow! and MMX Intra-Operand Swapping . . . . . . . . . 112
Block Copies and Block Fills . . . . . . . . . . . . . . . . . . . . . . 115
Branch Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Code Padding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Signed Words to Floating-Point Example. . . . . . . . . . . . 113
Branches
Align Branch Targets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Compound Branch Conditions. . . . . . . . . . . . . . . . . . . . . . 20
Dependent on Random Data . . . . . . . . . . . . . . . . . . . .10
, 57
Prediction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
Replace with Computation in 3DNow! Code . . . . . . . . . . 60
C
C Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Array-Style Over Pointer-Style Code . . . . . . . . . . . . . . . . 15
C Code to 3DNow! Code Examples . . . . . . . . . . . . . . . 6164
Structure Component Considerations . . . . . . . . . . . .27
, 55
Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
64-Byte Cache Line. . . . . . . . . . . . . . . . . . . . . . . . . . . .11
, 50
Cache and Memory Optimizations . . . . . . . . . . . . . . . . . . 45
CALL and RETURN Instructions . . . . . . . . . . . . . . . . . . . . . 59
Code Padding Using Neutral Code Fillers . . . . . . . . . . . . . . 39
Code Sample Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Complex Number Arithmetic . . . . . . . . . . . . . . . . . . . . . . . 126
Const Type Qualifier. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Constant Control Code, Multiple . . . . . . . . . . . . . . . . . . . . . 23
D
Data Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
Decoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
, 133
Dependencies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
DirectPath
Decoder. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
DirectPath Over VectorPath Instructions . . . . . . 9
, 34, 219
Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
Displacements, 8-Bit Sign-Extended . . . . . . . . . . . . . . . . . . 39
Division . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
80, 93, 95
Replace Divides with Multiplies, Integer . . . . . . . . . 31
, 77
Using 3DNow! Instructions . . . . . . . . . . . . . . . . . . . 108
109
Dynamic Memory Allocation Consideration . . . . . . . . . . . . 25
E
Event and Time-Stamp Monitoring Software . . . . . . . . . . 168
Execution Unit Resources. . . . . . . . . . . . . . . . . . . . . . . . . . 148
Extended-Precision Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
F
Far Control Transfer Instructions. . . . . . . . . . . . . . . . . . . . . 65
Fetch and Decode Pipeline Stages . . . . . . . . . . . . . . . . . . . 141
FFREEP Macro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Floating-Point
Compare Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Divides and Square Roots. . . . . . . . . . . . . . . . . . . . . . . . . 29
Execution Unit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Optimizations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Pipeline Operations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
Pipeline Stages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Scheduler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Subexpression Elimination. . . . . . . . . . . . . . . . . . . . . . . 103
To Integer Conversions . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Variables and Expressions are Type Float . . . . . . . . . . . 13
FRNDINT Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
FSINCOS Instruction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
FXCH Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
, 103
G
Group I Essential Optimizations . . . . . . . . . . . . . . . . . . 78
Group II Secondary Optimizations . . . . . . . . . . . . . . . . 7
, 9
I
If Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Immediates, 8-Bit Sign-Extended. . . . . . . . . . . . . . . . . . . . . 38
Inline Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
, 72, 86
Inline REP String with Low Counts. . . . . . . . . . . . . . . . . . . 85