-qfloat

Purpose

Selects different strategies for speeding up or improving the accuracy of floating-point calculations.

Syntax

Read syntax diagramSkip visual syntax diagram
                  .-:-------------------.   
                  | .-nosubnormals----. |   
                  | +-nospnans--------+ |   
                  | +-norsqrt---------+ |   
                  | +-norrm-----------+ |   
                  | +-rngchk----------+ |   
                  | +-norelax---------+ |   
                  | +-nonans----------+ |   
                  | +-maf-------------+ |   
                  | +-nohsflt---------+ |   
                  | +-nohscmplx-------+ |   
                  | +-gcclongdouble---+ |   
                  | +-fold------------+ |   
                  V +-nofenv----------+ |   
>>- -q--float--=----+-fenv------------+-+----------------------><
                    +-nofold----------+     
                    +-nogcclongdouble-+     
                    +-hscmplx---------+     
                    +-hsflt-----------+     
                    +-nomaf-----------+     
                    +-nans------------+     
                    +-relax-----------+     
                    +-norngchk--------+     
                    +-rrm-------------+     
                    +-rsqrt-----------+     
                    +-spnans----------+     
                    '-subnormals------'     

Defaults

  • -qfloat=nofenv:fold:gcclongdouble:nohscmplx:nohsflt:maf:nonans:norelax: rngchk:norrm:norsqrt:nospnans:nosubnormals
  • -qfloat=rsqrt:norngchk when -qnostrict, -qstrict=nooperationprecision:noexceptions, or the -O3 or higher optimization level is in effect.

Parameters

fenv | nofenv
Specifies whether the code depends on the hardware environment and whether to suppress optimizations that could cause unexpected results due to this dependency.

Certain floating-point operations rely on the status of Floating-Point Status and Control Register (FPSCR), for example, to control the rounding mode or to detect underflow. In particular, many compiler built-in functions read values directly from the FPSCR.

When nofenv is in effect, the compiler assumes that the program does not depend on the hardware environment, and that aggressive compiler optimizations that change the sequence of floating-point operations are allowed. When fenv is in effect, such optimizations are suppressed.

You should use fenv for any code containing statements that read or set the hardware floating-point environment, to guard against optimizations that could cause unexpected behavior.

Any directives specified in the source code (such as the standard C FENV_ACCESS pragma) take precedence over the option setting.

fold | nofold
Evaluates constant floating-point expressions at compile time, which may yield slightly different results from evaluating them at run time. The compiler always evaluates constant expressions in specification statements, even if you specify nofold.
gcclongdouble | nogcclongdouble
Specifies whether the compiler uses GCC-supplied or IBM-supplied library functions for 128-bit long double operations.

gcclongdouble ensures binary compatibility with GCC for mathematical calculations. If this compatibility is not important in your application, you should use nogcclongdouble for better performance.

Note: Passing results from modules compiled with nogcclongdouble to modules compiled with gcclongdouble may produce different results for numbers such as Inf, NaN, and other rare cases. To avoid such incompatibilities, the compiler provides built-in functions to convert IBM long double types to GCC long double types; see Binary floating-point built-in functions for more information.
hscmplx | nohscmplx
Speeds up operations involving complex division and complex absolute value. This suboption, which provides a subset of the optimizations of the hsflt suboption, is preferred for complex calculations.
hsflt | nohsflt
Speeds up calculations by preventing rounding for single-precision expressions and by replacing floating-point division by multiplication with the reciprocal of the divisor. hsflt implies hscmplx.

The hsflt suboption overrides the nans and spnans suboptions.

Note: Use -qfloat=hsflt on applications that perform complex division and floating-point conversions where floating-point calculations have known characteristics. In particular, all floating-point results must be within the defined range of representation of single precision. Use with discretion, as this option may produce unexpected results without warning. For complex computations, it is recommended that you use the hscmplx suboption (described above), which provides equivalent speed-up without the undesirable results of hsflt.
maf | nomaf
Makes floating-point calculations faster and more accurate by using floating-point multiply-add instructions where appropriate. The results may not be exactly equivalent to those from similar calculations performed at compile time or on other types of computers. Negative zero results may be produced. Rounding towards negative infinity or positive infinity will be reversed for these operations. This suboption may affect the precision of floating-point intermediate results. If -qfloat=nomaf is specified, no multiply-add instructions will be generated unless they are required for correctness.
nans | nonans
Allows you to use the -qflttrap=invalid:enable option to detect and deal with exception conditions that involve signaling NaN (not-a-number) values. Use this suboption only if your program explicitly creates signaling NaN values, because these values never result from other floating-point operations.
relax | norelax
Relaxes strict IEEE conformance slightly for greater speed, typically by removing some trivial floating-point arithmetic operations, such as adds and subtracts involving a zero on the right. These changes are allowed if either -qstrict=noieeefp or -qfloat=relax is specified.
rngchk | norngchk
At optimization level -O3 and above, and without -qstrict, controls whether range checking is performed for input arguments for software divide and inlined square root operations. Specifying norngchk instructs the compiler to skip range checking, allowing for increased performance where division and square root operations are performed repeatedly within a loop.
Note that with norngchk in effect the following restrictions apply:
  • The dividend of a division operation must not be +/-INF.
  • The divisor of a division operation must not be 0.0, +/- INF, or denormalized values.
  • The quotient of dividend and divisor must not be +/-INF.
  • The input for a square root operation must not be INF.
If any of these conditions are not met, incorrect results may be produced. For example, if the divisor for a division operation is 0.0 or a denormalized number (absolute value < 2-1022 for double precision, and absolute value < 2-126 for single precision), NaN, instead of INF, may result; when the divisor is +/- INF, NaN instead of 0.0 may result. If the input is +INF for a sqrt operation, NaN, rather than INF, may result.

norngchk is only allowed when -qnostrict is in effect. If -qstrict, -qstrict=infinities, -qstrict=operationprecision, or -qstrict=exceptions is in effect, norngchk is ignored.

rrm | norrm
Prevents floating-point optimizations that require the rounding mode to be the default, round-to-nearest, at run time, by informing the compiler that the floating-point rounding mode may change or is not round-to-nearest at run time. You should use rrm if your program changes the runtime rounding mode by any means; otherwise, the program may compute incorrect results.
rsqrt | norsqrt
Speeds up some calculations by replacing division by the result of a square root with multiplication by the reciprocal of the square root.

rsqrt has no effect unless -qignerrno is also specified; errno will not be set for any sqrt function calls.

If you compile with the -O3 or higher optimization level, rsqrt is enabled automatically. To disable it, also specify -qstrict, -qstrict=nans, -qstrict=infinities, -qstrict=zerosigns, or -qstrict=exceptions.

spnans | nospnans
Generates extra instructions to detect signalling NaN on conversion from single-precision to double-precision.
subnormals | nosubnormals
Specifies whether the code uses subnormal floating point values, also known as denormalized floating point values. Whether or not you specify this suboption, the behavior of your program will not change, but the compiler uses this information to gain possible performance improvements.
Note: For details about the relationship between -qfloat suboptions and their -qstrict counterparts, see -qstrict.

Usage

Using -qfloat suboptions other than the default settings might produce incorrect results in floating-point computations if the system does not meet all required conditions for a given suboption. Therefore, use this option only if the floating-point calculations involving IEEE floating-point values are manipulated and can properly assess the possibility of introducing errors in the program.

If the -qstrict | -qnostrict and float suboptions conflict, the last setting specified is used.

Predefined macros

None.

Examples

To compile myprogram.c so that the constant floating-point expressions are evaluated at compile time and multiply-add instructions are not generated, enter:
xlc myprogram.c -qfloat=fold:nomaf


Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us