Nonzero Code-Segment Base Values
135
136
Replacing Branches with Computation
Muxing Constructs
137
SSE Solution Preferred
MMX Solution Avoid
Sample Code Translated into AMD64 Code
Example 1 C Code
Example 1 3DNow! Code
Example 2 C Code
Example 3 C Code
Example 3 3DNow! Code
Example 4 C Code
Example 4 3DNow! Code
140
Example 5 C Code
Example 5 3DNow! Code
Loop Instruction
141
Far Control-Transfer Instructions
142
Chapter Scheduling Optimizations
143
Instruction Scheduling by Latency
144
145
Loop Unrolling
Loop Unrolling
Complete Loop Unrolling
Example Complete Loop Unrolling
Partial Loop Unrolling
Example Partial Loop Unrolling
Fadd
147
Deriving the Loop Control for Partially Unrolled Loops
148
Inline Functions
149
Additional Recommendations
150
151
Address-Generation Interlocks
Address-Generation Interlocks
152
Movzx and Movsx
153
Pointer Arithmetic in Loops
154
155
156
Pushing Memory Data Directly onto the Stack
157
158
Chapter Integer Optimizations
159
Replacing Division with Multiplication
Multiplication by Reciprocal Division Utility
Signed Division Utility
Unsigned Division Utility
Unsigned Division by Multiplication of Constant
Algorithm Divisors 1 = d 231, Odd d
Algorithm Divisors 231 = d
161
Signed Division by Multiplication of Constant
Simpler Code for Restricted Dividend
Algorithm Divisors 2 = d
Signed Division by
Signed Division by 2n
Signed Division by -2n
Remainder of Signed Division by 2 or
Remainder of Signed Division by 2n or -2n
Alternative Code for Multiplying by a Constant
164
165
166
Repeated String Instructions
Latency of Repeated String Instructions
Guidelines for Repeated String Instructions
167
Use the Largest Possible Operand Size
168
169
Using XOR to Clear Integer Registers
Acceptable
Efficient 64-Bit Integer Arithmetic in 32-Bit Mode
Bit Addition
Bit Subtraction
Bit Negation
Bit Right Shift
Bit Multiplication
Bit Unsigned Division
171
172
Bit Signed Division
173
Bit Unsigned Remainder Computation
174
175
Bit Signed Remainder Computation
176
177
178
179
Integer Version
180
181
Efficient Binary-to-ASCII Decimal Conversion
Binary-to-ASCII Decimal Conversion Retaining Leading Zeros
182
Binary-to-ASCII Decimal Conversion Suppressing Leading Zeros
183
184
285
Lahf
286
287
Mfence
288
289
NOP Xchg EAX, EAX
290
291
292
293
Rdmsr
Rdpmc
Rdtsc
294
Sahf
295
SBB reg16/32/64, mem16/32/64
296
297
298
299
STC
STD
STI
300
Syscall
Sysenter
Sysexit
301
Xchg AX/EAX/RAX, DI/EDI/RDI/R15
302
Xchg AX/EAX/RAX, SI/ESI/RSI/R14
303
MMX Technology Instructions
MMX Technology Instructions
304
Fmul
305
306
307
X87 Floating-Point Instructions
X87 Floating-Point Instructions
308
Fadd Fcompp
Fadd Fcos
Fdecstp
FADD/FMUL Fstore Finit
309
Fincstp
310
311
312
313
Fxch
Fxtract
FYL2X
3DNow! Technology Instructions
3DNow! Technology Instructions
314
Femms
DNow! Technology Instructions
315
316
3DNow! Technology Extensions
3DNow! Technology Extensions
317
SSE Instructions
SSE Instructions
318
319
320
321
322
Mem64 Prefetchnta mem8 0Fh 18h Mm-000-xxx DirectPath
323
Sfence
324
325
326
SSE2 Instructions
SSE2 Instructions
Fmul Fstore
327
0FH
328
329
Maskmovdqu
330
Fadd Fmul Fstore
331
332
333
Fadd Fmul
334