Integer Optimizations; Replace Divides With Multiplies; Multiplication By Reciprocal (Division) Utility - AMD Athlon Processor x86 Optimization Manual

X86 code optimization
Table of Contents

Advertisement

22007E/0—November 1999

Replace Divides with Multiplies

Multiplication by Reciprocal (Division) Utility

Replace Divides with Multiplies

Integer Optimizations

This chapter describes ways to improve integer performance
through optimized programming techniques. The guidelines are
listed in order of importance.
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.
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
Windows 98, and Windows NT
provided 'as is' and are not supported by AMD.
AMD Athlon™ Processor x86 Code Optimization
®
environments. All utilities are
8
®
95,
77

Advertisement

Table of Contents
loading

Table of Contents