-qstrict
Applicable invocations
| Option | xlc (Compiling C) | xlC (Compiling C++) | xlclang (Compiling C) | xlclang++ (Compiling C++) |
|---|---|---|---|---|
| -qstrict | ✓ | ✓ | ✓ | ✓ |
Category
Pragma equivalent
| xlc/xlC and other legacy invocation commands | xlclang/xlclang++ invocation commands |
|---|---|
| #pragma options [no]strict, #pragma option_override (function_name, "opt (suboption_list)") | #pragma option_override (function_name, "opt (suboption_list)") |
Purpose
Ensures that optimizations that are done by default at the -O3 and higher optimization levels, and, optionally at -O2, do not alter the semantics of a program.
This option is intended for situations where the changes in program execution in optimized programs produce different results from unoptimized programs.
Syntax
Defaults
- -qstrict or -qstrict=all is always in effect when the -qnoopt or -O0 optimization level is in effect
- -qstrict or -qstrict=all is the default when the -O2 or -O optimization level is in effect
- -qnostrict or -qstrict=none is the default when the -O3 or higher optimization level is in effect
Parameters
The -qstrict suboptions include the following:
- all | none
- all disables all semantics-changing transformations, including those controlled by the ieeefp, order, library, precision, and exceptions suboptions. none enables these transformations.
- precision | noprecision
- precision disables all transformations that are likely to affect floating-point precision, including those controlled by the subnormals, operationprecision, vectorprecision, association, reductionorder, and library suboptions. noprecision enables these transformations.
- exceptions | noexceptions
- exceptions disables all transformations likely to affect exceptions or be affected by them, including those controlled by the nans, infinities, subnormals, guards, and library suboptions. noexceptions enables these transformations.
- ieeefp | noieeefp
- ieeefp disables transformations that affect IEEE floating-point compliance, including those controlled by the nans, infinities, subnormals, zerosigns, vectorprecision, and operationprecision suboptions. noieeefp enables these transformations.
- nans | nonans
- nans disables transformations that may produce incorrect results in the presence of, or that may incorrectly produce IEEE floating-point NaN (not-a-number) values. nonans enables these transformations.
- infinities | noinfinities
- infinities disables transformations that may produce incorrect results in the presence of, or that may incorrectly produce floating-point infinities. noinfinities enables these transformations.
- subnormals | nosubnormals
- subnormals disables transformations that may produce incorrect results in the presence of, or that may incorrectly produce IEEE floating-point subnormals (formerly known as denorms). nosubnormals enables these transformations.
- zerosigns | nozerosigns
- zerosigns disables transformations that may affect or be affected by whether the sign of a floating-point zero is correct. nozerosigns enables these transformations.
- operationprecision | nooperationprecision
- operationprecision disables transformations that produce approximate results for individual floating-point operations. nooperationprecision enables these transformations.
- vectorprecision | novectorprecision
- vectorprecision disables vectorization in loops where it might produce
different results in vectorized iterations than in nonvectorized residue iterations.
vectorprecision ensures that every loop iteration of identical floating-point
operations on identical data produces identical results.
novectorprecision enables vectorization even when different iterations might produce different results from the same inputs.
- order | noorder
- order disables all code reordering between multiple operations that may affect results or exceptions, including those controlled by the association, reductionorder, and guards suboptions. noorder enables code reordering.
- association | noassociation
- association disables reordering operations within an expression. noassociation enables reordering operations.
- reductionorder | noreductionorder
- reductionorder disables parallelizing floating-point reductions. noreductionorder enables parallelizing these reductions.
- guards | noguards
- Specifying -qstrict=guards has the following effects:
- The compiler does not move operations past guards, which control whether the operations are
executed. That is, the compiler does not move operations past guards of the
ifstatements, out of loops, or past guards of function calls that might end the program or throw an exception. - When the compiler encounters
ifexpressions that contain pointer wraparound checks that can be resolved at compile time, the compiler does not remove the checks or the enclosed operations. The pointer wraparound check compares two pointers that have the same base but have constant offsets applied to them.
Specifying -qstrict=noguards has the following effects:
- The compiler moves operations past guards.
- The compiler evaluates
ifexpressions according to language standards, in which pointer wraparounds are undefined. The compiler removes the enclosed operations of theifstatements when the evaluation results of theifexpressions are false.
- The compiler does not move operations past guards, which control whether the operations are
executed. That is, the compiler does not move operations past guards of the
- library | nolibrary
- library disables transformations that affect floating-point library functions; for example, transformations that replace floating-point library functions with other library functions or with constants. nolibrary enables these transformations.
Usage
The all, precision, exceptions, ieeefp, and order suboptions and their negative forms are group suboptions that affect multiple, individual suboptions. For many situations, the group suboptions will give sufficient granular control over transformations. Group suboptions act as if either the positive or the no form of every suboption of the group is specified. Where necessary, individual suboptions within a group (like subnormals or operationprecision within the precision group) provide control of specific transformations within that group.
- Code that may cause an exception may be rearranged. The corresponding exception might happen at a different point in execution or might not occur at all. (The compiler still tries to minimize such situations.)
- Floating-point operations may not preserve the sign of a zero value. (To make certain that this sign is preserved, you also need to specify -qfloat=rrm or -qfloat=nomaf.)
- Floating-point expressions may be reassociated. For example, (2.0*3.1)*4.2 might become 2.0*(3.1*4.2) if that is faster, even though the result might not be identical.
The optimization functions enabled by -qfloat=fltint:rsqrt. You can turn off
the optimization functions by using the -qstrict option or -qfloat=nofltint:norsqrt. With lower-level or no optimization specified, these optimization
functions are turned off by default.
-qstrict or -qstrict=all sets -qfloat=nofltint:norsqrt:rngchk. -qnostrict or
-qstrict=none sets -qfloat=fltint:rsqrt:norngchk.
-qstrict=operationprecision or -qstrict=exceptions
sets -qfloat=nofltint. Specifying both
-qstrict=nooperationprecision and -qstrict=noexceptions sets
-qfloat=fltint.- -qstrict=infinities, -qstrict=operationprecision, or -qstrict=exceptions sets -qfloat=norsqrt.
- -qstrict=noinfinities:nooperationprecision:noexceptions sets -qfloat=rsqrt.
- -qstrict=nans, -qstrict=infinities, -qstrict=zerosigns, or -qstrict=exceptions sets -qfloat=rngchk. Specifying all of -qstrict=nonans:nozerosigns:noexceptions or -qstrict=noinfinities:nozerosigns:noexceptions, or any group suboptions that imply all of them, sets -qfloat=norngchk.
To override any of these settings, specify the appropriate -qfloat suboptions after the -qstrict option on the command line.
Predefined macros
None.
Examples

myprogram.c so that the aggressive optimization of -O3
are turned off, range checking is turned off (-qfloat=fltint),
and division by the result of a square root is replaced by multiplying by the reciprocal
(-qfloat=rsqrt), enter:
xlc myprogram.c -O3 -qstrict -qfloat=fltint:rsqrt
xlc myprogram.c -qstrict=none:precisionxlc myprogram.c -qstrict=all:nonans:noinfinitiesif
expression contains a pointer wraparound check. If you compile the code with the
-qstrict=guards option in effect, the compiler keeps the enclosed
foo() function; otherwise, the compiler removes the enclosed foo()
function.void foo()
{
// You can add some operations here.
}
int main()
{
char *p = "a";
int k = 100;
if(p + k < p) // This if expression contains a pointer wraparound check.
{
foo(); // foo() is the enclosed operation of the if statement.
}
return 0;
}
