User's Manual

22007E/0November 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 (59 cycles signed, 48 cycles unsigned)
and the integer division delivers only one bit of quotient per
cycle (2247 cycles signed, 1741 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.