Optimization
To improve the efficiency of the generated code, you can
use the OPTIMIZE(1)
or OPTIMIZE(2)
compiler option.
OPTIMIZE(1)
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
PERFORM
statement. The compiler replicates thePERFORM
a number of times to avoid linkage code. - 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. - Delete from the program, and identify with a warning message, code that can never be performed (unreachable code elimination).
- Discard unreferenced data items from the
DATA DIVISION
, and suppress generation of code to initialize these data items to theirVALUE
clauses. (The optimizer takes this action only when you use theSTGOPT
option.)
OPTIMIZE(2)
causes
the COBOL optimizer to do further optimizations:- Simplify operations more aggressively and schedule instructions.
- Do interblock optimizations such as global value propagation and loop invariant code motion.