Software Optimization Guide for AMD64 Processors

25112 Rev. 3.06 September 2005

10.1Using 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 AMD Athlon 64 and AMD Opteron processors have high-performance division, multiplication is significantly faster than division.

238

x87 Floating-Point Optimizations

Chapter 10

Page 254
Image 254
AMD 250 manual Using Multiplication Rather Than Division, 238