GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
cobol Performance Win

COBOL COMPUTE statements now use Reverse Polish Notation.

COBOL COMPUTE statements are refactored to use RPN, improving efficiency and reducing middle-end load.

This commit refactors the COBOL COMPUTE statement to use Reverse Polish Notation (RPN) for expression evaluation. Previously, complex expressions like ‘z = a * b + c * d’ would generate numerous temporary variables. The new RPN-based approach utilizes a stack, which is processed by the libgcobol library, leading to more efficient computation and a reduced burden on the GCC middle end.

In Details

The COBOL front-end's COMPUTE statement implementation was modified to generate RPN stacks instead of intermediate GCC trees. These RPN stacks are then reduced by a new libgcobol function. This change offloads expression evaluation from the GCC middle-end to libgcobol, aiming for improved performance and simplified middle-end code.

For Context
COMPUTE statement
A COBOL statement that evaluates an arithmetic expression and assigns the result to one or more variables.
Reverse Polish Notation (RPN)
A mathematical notation in which operators follow their operands, avoiding the need for parentheses or other grouping symbols. It is often used for efficient evaluation using a stack.
libgcobol
A library associated with the GNU COBOL compiler, likely providing runtime support and specific language features.
GCC middle end
The part of the GCC compiler that performs optimizations and transformations on the code after initial parsing and before machine-specific code generation. It operates on an intermediate representation (IR).
Filed Under: coboloptimizationbackend