238 x87 Floating-Point Optimizations Chapter 10
25112 Rev. 3.06 September 2005
Software Optimization Guide for AMD64 Processors
10.1 Using Multiplication Rather Than Division
Optimization
If accuracy requirements allow, convert floating-point division by a constant to multiplication by the
reciprocal.
Application
This optimization applies to:
32-bit software
64-bit software
Rationale
Divisors that are powers of two—and their reciprocals—are exactly representable, and therefore do
not cause an accuracy issue, except for the rare case in which the reciprocal overflows or underflows.
Unless such an overflow or underflow occurs, always convert a division by a power of two for
multiplication. Although the AMDA thlon 64 and AMDO pteron processors have high-performance
division, multiplication is significantly faster than division.