Nonzero Code-Segment Base Values
135
136
Replacing Branches with Computation
Muxing Constructs
137
SSE Solution Preferred
MMX Solution Avoid
Example 1 3DNow! Code
Sample Code Translated into AMD64 Code
Example 1 C Code
Example 2 C Code
Example 4 C Code
Example 3 C Code
Example 3 3DNow! 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
Partial Loop Unrolling
Complete Loop Unrolling
Example Complete 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
Signed Division Utility
Replacing Division with Multiplication
Multiplication by Reciprocal Division Utility
Unsigned Division Utility
Algorithm Divisors 231 = d
Unsigned Division by Multiplication of Constant
Algorithm Divisors 1 = d 231, Odd d
161
Algorithm Divisors 2 = d
Signed Division by Multiplication of Constant
Simpler Code for Restricted Dividend
Signed Division by
Remainder of Signed Division by 2 or
Signed Division by 2n
Signed Division by -2n
Remainder of Signed Division by 2n or -2n
Alternative Code for Multiplying by a Constant
164
165
166
Guidelines for Repeated String Instructions
Repeated String Instructions
Latency of Repeated String Instructions
167
Use the Largest Possible Operand Size
168
169
Using XOR to Clear Integer Registers
Acceptable
Bit Subtraction
Efficient 64-Bit Integer Arithmetic in 32-Bit Mode
Bit Addition
Bit Negation
Bit Unsigned Division
Bit Right Shift
Bit Multiplication
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
Rdpmc
293
Rdmsr
Rdtsc
294
Sahf
295
SBB reg16/32/64, mem16/32/64
296
297
298
STD
299
STC
STI
Sysenter
300
Syscall
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
Fadd Fcos
308
Fadd Fcompp
Fdecstp
FADD/FMUL Fstore Finit
309
Fincstp
310
311
312
Fxtract
313
Fxch
FYL2X
314
3DNow! Technology Instructions
3DNow! Technology Instructions
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