244 x87 Floating-Point Optimizations Chapter 10
25112 Rev. 3.06 September 2005
Software Optimization Guide for AMD64 Processors
10.3 Floating-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.