Sun Studio 12: C++ User's Guide

A.2.27 –fsimple[=n]

Selects floating-point optimization preferences.

This option allows the optimizer to make simplifying assumptions concerning floating-point arithmetic.

A.2.27.1 Values

If n is present, it must be 0, 1, or 2.

Table A–13 The -fsimple Values

Value 

Meaning  

0

Permit no simplifying assumptions. Preserve strict IEEE 754 conformance. 

1

Allow conservative simplification. The resulting code does not strictly conform to IEEE 754, but numeric results of most programs are unchanged. 

With -fsimple=1, the optimizer can assume the following:

  • IEEE754 default rounding/trapping modes do not change after process initialization.

  • Computation producing no visible result other than potential floating-point exceptions can be deleted.

  • Computation with infinities or NaNs as operands needs to propagate NaNs to their results; that is, x*0 can be replaced by 0.

  • Computations do not depend on sign of zero.

    With -fsimple=1, the optimizer is not allowed to optimize completely without regard to roundoff or exceptions. In particular, a floating-point computation cannot be replaced by one that produces different results when rounding modes are held constant at runtime.

2

Includes all the functionality of -fsimple=1 and also permits aggressive floating-point optimization that can cause many programs to produce different numeric results due to changes in rounding. For example, permit the optimizer to replace all computations of x/y in a given loop with x*z, where x/y is guaranteed to be evaluated at least once in the loop z=1/y, and the values of y and z are known to have constant values during execution of the loop.

Defaults

If –fsimple is not designated, the compiler uses -fsimple=0.

If -fsimple is designated but no value is given for n, the compiler uses -fsimple=1.

Interactions

-fast implies– fsimple=2.

Warnings

This option can break IEEE 754 conformance.

See also

-fast

Techniques for Optimizing Applications: High Performance Computing written by Rajat Garg and Ilya Sharapov for a more detailed explanation of how optimization can impact precision.