Optimization
To
improve the efficiency of the generated code, you can use the OPTIMIZE
compiler option.
OPTIMIZE causes the COBOL optimizer to do the following
optimizations:
- Eliminate unnecessary transfers of control and inefficient branches,
including those generated by the compiler that are not evident from looking
at the source program.
- Simplify the compiled code for a CALL statement to a contained (nested)
program. Where possible, the optimizer places the statements inline,
eliminating the need for linkage code. This optimization is known as procedure
integration. If procedure integration cannot be done, the optimizer
uses the simplest linkage possible (perhaps as few as two instructions) to
get to and from the called program.
- Eliminate duplicate computations (such as subscript computations and
repeated statements) that have no effect on the results of the program.
- Eliminate constant computations by performing them when the program is
compiled.
- Eliminate constant conditional expressions.
- Aggregate moves of contiguous items (such as those that often occur with
the use of MOVE CORRESPONDING) into a single move. Both the source
and target must be contiguous for the moves to be aggregated.
- Discard unreferenced data items from the DATA DIVISION, and
suppress generation of code to initialize these data items to their VALUE
clauses. (The optimizer takes this action only when you use the FULL
suboption.)
Contained program procedure integration
In
contained program procedure integration, the contained program code replaces a CALL
to a contained program. The resulting program runs faster without the overhead
of CALL linkage and with more linear control flow.
Program size: If several CALL statements call
contained programs and these programs replace each such statement, the
containing program can become large. The optimizer limits this increase to no
more than 50 percent, after which it no longer integrates the programs. The
optimizer then chooses the next best optimization for the CALL
statement. The linkage overhead can be as few as two instructions.
Unreachable code: As a result of this integration, one
contained program might be repeated several times. As further optimization
proceeds on each copy of the program, portions might be found to be unreachable,
depending on the context into which the code was copied.
related concepts
Optimization of table references
related references
OPTIMIZE
|