3.5. Managing Floating Point Support

Assuming that a floating-point ABI has been selected with the -mfloat-abi option and, if floating-point hardware is available, it has been made known to the compiler via the -mfpu option, then the following command-line options can be used to further refine the compiler’s assumptions about what floating-point characteristics are enabled.

cl2000 Option

c29clang Option

--float_operations_allowed=<all|none|32|64>

not supported

The cl2000 compiler supports a --float_operations_allowed option, which allows you to indicate to the compiler the maximum floating-point precision that can be assumed for a floating-point type data object. For example, you can specify ‘--float_operations_allowed=32’, causing the cl2000 compiler to flag an error if an attempt is made to use a floating-point type whose size is greater than 32-bits.

The c29clang compiler does not provide a mechanism to restrict the use of floating-point types by type size. The c29clang compiler assumes that all legal floating-point types are supported. This matches the cl2000 compiler’s default behavior (e.g. --float_operations_allowed=all).

cl2000 Option

c29clang Option

--fp_mode=<relaxed|strict>

-ffp-model=<precise|strict|fast>

-ffast-math

-fno-fast-math

-ffp_contract=[on|off]

-frounding-math

-fno-rounding-math

-ffp-exception-behavior=<ignore>

By default, the cl2000 compiler supports ‘strict’ conformance to the IEEE-754 floating-point standard, but you can also use the ‘--fp_mode=relaxed’ option to allow the compiler to be more aggressive about using floating-point hardware instructions, allow floating-point arithmetic reassociation, and aggressively convert double-precision floating-point terms in an expression to single-precision when the result type is single-precision.

The c29clang compiler provides an ‘-ffp-model’ option that allows you to instruct the compiler to assume a general set of rules for generating code that implements floating-point math. Each of the available arguments to the ‘-ffp-model’ option will effect the settings for other, single-purpose, floating-point options.

The available arguments to the -ffp-model option are:

  • precise - If no ‘-ffp-model’ option is explicitly specified on the c29clang command-line, then the compiler will assume the ‘precise’ floating-point model by default.

    ‘-ffp-model=precise’ is the recommended c29clang compiler option to be used in place of cl2000’s ‘--fp_mode=strict’ option.

    When the ‘precise’ floating-point model is in effect, all optimizations that are not value-safe on floating-point data are disabled. However, if the indicated C29x processor’s floating-point unit (FPU) supports a fused multiply and add (FMA) instruction, then the compiler will assume that any floating-point contraction optimizations are safe (-ffp-contract=on).

  • strict - Specifying ‘strict’ as the argument to the -ffp-model option enables floating-point rounding (-frounding-math). However, floating-point contraction optimizations are disabled (-ffp-contract=off). Also, no ‘fast-math’ optimizations are enabled (-fno-fast-math).

  • fast - Specifying ‘fast’ as the argument to the -ffp_model option will enable all ‘fast math’ optimizations (-ffast-math) and it will enable more aggressive floating-point contraction optimizations (-fp-contract=fast).

    The c29clang ‘-ffp-model=fast’ option is the most functionally similar to the cl2000 ‘--fp_mode=relaxed’ option among the available arguments to the ‘-ffp-model’ option.

For more detailed information about the separate, single purpose floating-point options mentioned here, please see the Floating-Point Arithmetic section of the Optimization Options chapter.

cl2000 Option

c29clang Option

--fp_reassoc

not supported

The c29clang compiler does not provide an option that controls whether reassociation is allowed in floating-point operations. Instead, the c29clang’s -ffp-mode=std option can be used to disallow reassociation (the default), and c29clang’s -ffp-mode=fast option can be used to allow reassociation.

cl2000 Option

c29clang Option

--fp_single_precision_constant

-cl-single-precision-constant

The cl2000 compiler supports a --fp_single_precision_constant option, which causes all unsuffixed floating-point constants to be treated as single-precision values instead of as double-precision constants.

The -cl-single-precision-constant option can be used with the c29clang compiler to treat double precision floating-point constants as single precision constants.