Advanced optimization
In addition to deep architecture exploitation, Enterprise COBOL V6 improves performance of your application by employing a suite of advanced optimizations. In V4, the OPTIMIZE option has three settings; however, the kind and number of optimizations enabled in V6 is quite different.
Specifying OPTIMIZE(1) or OPTIMIZE(2) enables a range of general and COBOL specific optimizations.
For example, specifying
OPTIMIZE(1) enables optimizations including:
- Strength reduction of complex and expensive operations, such as:
- Reducing decimal multiply and divide by powers of ten, to simpler and better performing decimal shift operations
- Reducing binary multiply and divide by powers of two to less expensive shift operations
- Reducing exponentiation operations with a constant exponent to series of multiplications
- Refactoring and redistributing arithmetic
- Eliminate common sub expressions, so computations are not duplicated
- Inline out-of-line PERFORM statements to save the branching overhead and expose other optimization opportunities for the surrounding code
- Coalesce sequential stores of constant values to a single larger store to reduce path length
- Coalesce individual loads/stores from/to sequential storage to a single larger move operation to reduce path length and reduce overall object size
- Simplify code to remove unneeded computations
- Remove unreachable code
- Propagate the VALUE OF clause literal over the entire program for data items that are read but never written
- Move nested programs inline to reduce CALL overhead and expose other optimization opportunities for the surrounding code
- Compute constant expressions, including the full range of arithmetic, data type conversions and branches, at compile-time
- Use a better performing branchless sequence for conditionally setting level-88 variables
- Convert some packed and zoned decimal computations to use better performing Decimal Floating Point types
- Perform comparisons of small DISPLAY and COMP-3 items in registers, instead of in memory
- Generate faster code for moves to numeric-edited items
- Use a better-performing sequence for DIVIDE GIVING REMAINDER
When specifying OPTIMIZE(2), all the optimizations above
are enabled plus additional optimizations, including:
- Propagate values and ranges of values over the entire program to expose constants and enable simpler sequences of instructions to be used
- Propagate sign values, including the "unsigned" sign encoding, over the entire program to eliminate redundant sign correction
- Allocate global registers for accessing indexed tables, and control PERFORM 'N' TIMES looping constructs to reduce path length
- Remove redundant sign correction operations globally. For example, if a sign correction for a data item in a loop is dominated by one outside of a loop to the same data item, then these sign-correcting instructions in the loop will be removed