Nonzero Code-Segment Base Values
135
Muxing Constructs
Replacing Branches with Computation
136
MMX Solution Avoid
SSE Solution Preferred
137
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
Example 5 3DNow! Code
Example 5 C Code
140
Loop Instruction
141
Far Control-Transfer Instructions
142
Chapter Scheduling Optimizations
143
Instruction Scheduling by Latency
144
Loop Unrolling
Loop Unrolling
145
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
Address-Generation Interlocks
Address-Generation Interlocks
151
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
Acceptable
Using XOR to Clear Integer Registers
169
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
Binary-to-ASCII Decimal Conversion Retaining Leading Zeros
Efficient Binary-to-ASCII Decimal Conversion
181
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, SI/ESI/RSI/R14
302
Xchg AX/EAX/RAX, DI/EDI/RDI/R15
MMX Technology Instructions
MMX Technology Instructions
303
304
Fmul
305
306
X87 Floating-Point Instructions
X87 Floating-Point Instructions
307
Fadd Fcos
308
Fadd Fcompp
Fdecstp
Fincstp
309
FADD/FMUL Fstore Finit
310
311
312
Fxtract
313
Fxch
FYL2X
314
3DNow! Technology Instructions
3DNow! Technology Instructions
Femms
DNow! Technology Instructions
315
3DNow! Technology Extensions
3DNow! Technology Extensions
316
SSE Instructions
SSE Instructions
317
318
319
320
321
322
Mem64 Prefetchnta mem8 0Fh 18h Mm-000-xxx DirectPath
323
Sfence
324
325
SSE2 Instructions
SSE2 Instructions
326
0FH
327
Fmul Fstore
328
329
Maskmovdqu
330
Fadd Fmul Fstore
331
332
333
Fadd Fmul
334