Software Optimization Guide for AMD64 Processors

25112 Rev. 3.06 September 2005

10.3Floating-Point Compare Instructions

Optimization

For branches that are dependent on floating-point comparisons, use the FCOMI, FCOMIP, FUCOMI, and FUCOMIP instructions:

Application

This optimization applies to:

32-bit software

64-bit software

Rationale

The FCOMI, FCOMIP, FUCOMI, and FUCOMIP instructions are much faster than the classical approach using FSTSW. When FSTSW cannot be avoided (for example, backward compatibility of code with older processors), no floating-point instruction should occur between an FCOM, FCOMP, FCOMPP, FICOM, FICOMP, FUCOM, FUCOMP, FUCOMPP, or FTST instruction and a dependent FSTSW instruction. This optimization allows the use of a fast-forwarding mechanism for the floating- point condition codes internal to the processor’s floating-point unit and increases performance.

244

x87 Floating-Point Optimizations

Chapter 10

Page 260
Image 260
AMD 250 manual Floating-Point Compare Instructions, 244