22007E/0—November 1999
AMD Athlon™ Processor x86 Code Optimization
Replace Divides with Multiplies
77
8
Integer Optimizations
This chapter describes ways to improve integer performance
through optimized programming techniques. The guidelines are
listed in order of importance.
Replace Divides with Multiplies
Replace integer division by constants with multiplication by
the reciprocal. Because the AMD Athlon™ processor has a very
fast integer multiply (5–9 cycles signed, 4–8 cycles unsigned)
and the integer division delivers only one bit of quotient per
cycle (22–47 cycles signed, 17–41 cycles unsigned), the
equivalent code is much faster. The user can follow the
examples in this chapter that illustrate the use of integer
division by constants, or access the executables in the
opt_utilities directory in the AMD documentation CD-ROM
(order# 21860) to find alternative code for dividing by a
constant.
Multiplication by Reciprocal (Division) Utility
The code for the utilities can be found at “Derivation of
Multiplier Used for Integer Division by Constants” on page 93.
All utilities were compiled for the Microsoft Windows
®
95,
Windows 98, and Windows NT
®
environments. All utilities are
provided ‘as is’ and are not supported by AMD.
Summary of Contents for Athlon Processor x86
Page 1: ...AMD Athlon Processor x86 Code Optimization Guide TM...
Page 12: ...xii List of Figures AMD Athlon Processor x86 Code Optimization 22007E 0 November 1999...
Page 16: ...xvi Revision History AMD Athlon Processor x86 Code Optimization 22007E 0 November 1999...
Page 202: ...186 Page Attribute Table PAT AMD Athlon Processor x86 Code Optimization 22007E 0 November 1999...
Page 252: ...236 VectorPath Instructions AMD Athlon Processor x86 Code Optimization 22007E 0 November 1999...
Page 256: ...240 Index AMD Athlon Processor x86 Code Optimization 22007E 0 November 1999...