If none of the following optimization options are specified, the compiler does not carry out any optimization. This corresponds to the SDF LEVEL=*LOW
option.
The separate optimization options and their effects are described in detail in the C/C++ User Guide [4] in the section “Optimization”.
-O
-F O2
These options enable the standard optimization of the compiler. The only difference between the two options is that every optimization strategy is internally executed only once for -O
, but several times for -F O2
. Consequently, the overall compile time at
the -O
optimization level is significantly less than the compile time required for the “highly-optimized” -F O2
level.
The following standard optimizations are performed by the compiler:
calculates constant expressions at compilation time
optimizes the indexing in loops
eliminates unnecessary assignments
propagates constant expressions
eliminates redundant expressions
optimizes jumps and unconditional jump commands
In addition, registers are also optimized.
In contrast to the SDF option (where the optimization level can be set as *HIGH or *VERY-HIGH without parameters), loop unrolling is disabled here.
If the standard optimization has not been explicitly enabled with -O
or -F O2
, it is automatically activated at level -O
if the -F loopunroll
(loop expansion) or -F i
, -F inline_by_source
(inline substitution of user-defined functions) options are specified.
-F I
[name]
This option allows you to specify the C library functions for which the implementation in CRTE can be assumed. This permits better optimization of the program.
When -F I is specified without name, all calls for known C library functions are handled separately.
When the -F I option is not specified, no call is handled separately.
When -F Iname is specified (without a separating blank), only the name function is handled separately.
If several functions are to be handled separately, the -F Iname option must be specifed several times.
The -F I option can be specified independently of normal optimization.
The compiler achieves the greatest effect by means of inline generation of a function. In this case the function code is inserted directly in place of the function call. This eliminates time-consuming management activities required of the runtime system (e.g. saving and restoring registers or returning from the function), thus shortening program runtime.
The following C library functions can be generated inline:
|
|
|
|
|
|
|
|
|
|
|
Functions which are generated inline cannot be replaced by other functions at linkage time, nor can they be used as test points when debugging with AID.
The default compiler optimization does not have to be activated for generating C library functions inline.
The compiler knows the semantics of the CRTE library functions. With the -F I
name option you command the compiler to generate optimized functions that observe the CRTE library function semantics. If no name is specified, then the compiler should use all its knowledge of the CRTE functions (the compiler knows of about 150 functions).
Functions which are not generated inline are retained as calls. However, optimizations are possible which are not feasible with the user functions. For example, the compiler can use the information that the isdigit()
function has no side effects.
Some functions are highly specialized since they are generated to be completely inline. For these functions the compiler creates the code directly without passing it to CRTE. These functions are listed in the table above.
In some cases this optimization may not be desired. If the program is to be debugged, you may need to set a breakpoint in such a function. This is not possible for functions generated to be completely inline, or more precisely, you can set a breakpoint, but it will not be reached. The code generated by the compiler is used and not the function where the breakpoint was set.
Another case is when a function is defined with a name that is already known to the compiler. In most cases this function will use semantics different from the CRTE semantics. If a conflict between such a function and this option arises, then all calls assume the CRTE semantics. Warning CFE2067 is output in this case.
Note that the CRTE semantics are used in every compilation unit. The warning is only output in the compilation unit that contains the private definition.
-F i
[name]-F inline_by_source
These alternative options control the inline substitution of user-defined functions. As in the case of some C library functions from the standard library (see -F I
), each call to an inline function is replaced by the corresponding function code. This saves the code sequence for the call and return and thus results in faster execution times. Specifying the -F i
, -F i
name or -F inline_by_source
options automatically activates the standard optimization (-O
) as well, unless -F O2
was explicitly set.
-F i
and -F i
name
When -F i
is specified with or without name, the compiler selects functions for inline substitution in accordance with its own criteria. Any existing inline pragmas and C++-specific inline functions in the source program are automatically considered by the compiler in the search for suitable candidates (see also -F inline_by_source
).
If name is specified (without a leading blank!), the function name will also be inlined. If multiple user-selected functions are to be considered by the compiler for inline substitution, the -F i
name option must be specified more than once.
The -F i
name option is ignored for C++ compilations, i.e. by the CC
command.
-F inline_by_source
If this option is specified, only the following user-defined functions are inlined:
For C compilations (
cc
,c11
,c89
): C functions declared with the#pragma inline
name directive (see also the section “inline pragma” in the C/C++ User Guide [4]). The inline pragma in not supported in C++.For C++ compilations (
CC
): the C++-specific inline functions. These are the functions defined within classes and functions with theinline
attribute.
Note on inline functions in C++
The inline substitution of C++-specific inline functions is also performed when optimization is not enabled or if the -F i
or -F inline_by_source
options are not set. This can be suppressed with the -F no_inlining
option.
-F loopunroll
[,
n]
This option controls loop unrolling. Multiple unrolling of the loop body speeds up loop execution. This optimization option is not used by default. If it is specified, it automatically activates the standard optimization (-O
), unless -F O2
was explicitly set.
If -F loopunroll
is specified without n, the compiler unrolls loop bodies four times.You can use n to specify your own unroll factor, where n can be set to a value between 1 and 100.
Specifying -F loopunroll[,
n]
does not guarantee that the optimizer will always carry out the loop expansion. The optmizer decides whether or not to run the loop expansion on the basis of the loop structure and specified factor n.
-F no_inlining
This option suppresses the inline substitution of C++-specific inline functions, which is performed by default even if the -F i
or -F inline_by_source
options have not been specified.
If the -F no_inlining
option in combination with the -F i
or -F inline_by_source
option, the last specification on the command line applies.
If -F no_inlining
is the last specified option, even the originally requested inlining of user-defined C functions is suppressed (however, the implicitly set -O
optimization remains enabled).
The inlining of C library functions set with the -F I
option is not affected by -F no_inlining
.