Optimizing Floating-Point Calculations

Special compiler options exist for handling floating-point calculations efficiently. By default, the compiler makes a trade-off to violate certain IEEE floating-point rules in order to improve performance. For example, multiply-add instructions are generated by default because they are faster and produce a more precise result than separate multiply and add instructions. Floating-point exceptions, such as overflow or division by zero, are masked by default. If you need to catch these exceptions, you have the choice of enabling hardware trapping of these exceptions or using software-based checking. The option -qflttrap enables software-based checking. On the POWER4, POWER5, or PowerPC 970 processor, hardware trapping is recommended.

Options for handling floating-point calcluations
Option Description
-qfloat Provides precise control over the handling of floating-point calculations.
-qflttrap Enables software checking of IEEE floating-point exceptions. This technique is sometimes more efficient than hardware checking because checks can be executed less frequently.

To understand the performance considerations for floating-point calculations with different combinations of compiler options, see Maximizing Floating-Point Performance and Minimizing the Performance Impact of Floating-Point Exception Trapping.

Related Information:
IBM Copyright 2003