Speed up COMPUTE C = A <op> B statement in COBOL
Optimizes COBOL COMPUTE statements for two operands, making them 2-3x faster by using simpler ADD/SUBTRACT logic.
The performance of COBOL COMPUTE C = A <op> B statements has been significantly improved, with execution speeds now 2-3 times faster. This optimization detects when a COMPUTE operation involves only two operands and can be safely performed using the more efficient underlying ADD or SUBTRACT logic, rather than the more complex COMPUTE machinery. The new parser_as_two() function identifies these opportunities.
In Details
The COBOL compiler backend now includes an optimization to speed up COMPUTE C = A <op> B statements. The parser_as_two() function in genapi.h determines if a COMPUTE operation can be directly mapped to a simpler ADD or SUBTRACT operation. This is possible when the COMPUTE statement is essentially a binary operation without complex clauses like ROUNDED or SIZE ERROR. If applicable, fast_add or fast_subtract are used, leading to a 2-3x performance improvement for these common arithmetic operations.
- COBOL
- A compiled programming language designed for business applications. It is known for its verbose syntax and focus on data manipulation and financial calculations.
- COMPUTE statement
- A statement in COBOL used to perform arithmetic operations, similar to assignment statements in other languages. It can handle complex expressions.
- ADD statement
- A basic arithmetic statement in COBOL for performing addition. It is generally more efficient than a full COMPUTE statement for simple additions.
- optimization
- The process of modifying a program to increase its efficiency, such as reducing execution time or memory footprint, without changing its functional behavior.