Floating-point Arithmetic Precision

Options for IA-32 and Itanium®-based Systems

-mp Option

The -mp option restricts optimization to maintain declared precision and to ensure that floating-point arithmetic conforms more closely to the ANSI and IEEE standards. For most programs, specifying this option adversely affects performance. If you are not sure whether your application needs this option, try compiling and running your program both with and without it to evaluate the effects on both performance and precision. Specifying the -mp option has the following effects on program compilation:

-mp1 Option

Use the -mp1 option to improve floating-point precision. -mp1 disables fewer optimizations and has less impact on performance than -mp.

Options for IA-32 Only

Caution

A change of the default precision control or rounding mode (for example, by using the -pc32 flag or by user intervention) may affect the results returned by some of the mathematical functions.

-long_double Option

Use -long_double to change the size of the long double type to 80 bits. The Intel compiler's default long double type is 64 bits in size, the same as the double type. This option introduces a number of incompatibilities with other files compiled without this option and with calls to library routines. Therefore, Intel recommends that the use of long double variables be local to a single file when you compile with this option.

-prec_div Option

With some optimizations, such as -xK and -xW, the Intel® C++ Compiler changes floating-point division computations into multiplication by the reciprocal of the denominator. For example, A/B is computed as A x (1/B) to improve the speed of the computation. However, for values of B greater than 2126, the value of 1/B is "flushed" (changed) to 0. When it is important to maintain the value of 1/B, use -prec_div to disable the floating-point division-to-multiplication optimization. The result of -prec_div is greater accuracy with some loss of performance.

-pcn Option

Use the -pcn option to enable floating-point significand precision control. Some floating-point algorithms are sensitive to the accuracy of the significand or fractional part of the floating-point value. For example, iterative operations like division and finding the square root can run faster if you lower the precision with the -pcn option. Set n to one of the following values to round the significand to the indicated number of bits:

The default value for n is 80, indicating double precision. This option allows full optimization. Using this option does not have the negative performance impact of using the -Op option because only the fractional part of the floating-point value is affected. The range of the exponent is not affected.  The -pcn option causes the compiler to change the floating point precision control when the main() function is compiled. The program that uses -pcn  must use main() as its entry point, and the file containing main() must be compiled with -pcn.

-rcd Option

The Intel compiler uses the -rcd option to improve the performance of code that requires floating-point-to-integer conversions. The optimization is obtained by controlling the change of the rounding mode. The system default floating point rounding mode is round-to-nearest. This means that values are rounded during floating point calculations. However, the C language requires floating point values to be truncated when a conversion to an integer is involved. To do this, the compiler must change the rounding mode to truncation before each floating-point-to-integer conversion and change it back afterwards. The -rcd option disables the change to truncation of the rounding mode for all floating point calculations, including floating point-to-integer conversions. Turning on this option can improve performance, but floating point conversions to integer will not conform to C semantics.

-fp_port Option

The -fp_port option rounds floating-point results at assignments and casts. An impact on speed may result.

-fpstkchk Option

When a function call returns a floating-point value, the return value should be placed at the top of the FP stack.  If the return value is unused, the compiler pops the value off the stack to keep the FP stack in the correct state.  However, if the application leaves out the function's prototype or incorrectly prototypes the function, then the return value may remain on the stack. This may result in the FP stack filling up and eventually overflowing.

Generally, when the FP stack overflows, a NaN value is put into FP calculations, and the program's results differ. Unfortunately, the overflow point can be far away from the point of the actual bug.  The -fpchkstk option places code that would access violate immediately after an incorrect call occurred, thus making it easier to locate these issues.