GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
match

match: Allow C variable for result code/operation in simplify expressions

Generated code for match patterns is reduced by allowing C variables to define result codes, aiding ARM builds at -O0.

The GCC match system now allows a C variable to define the result code or operation within simplify expressions. This change significantly reduces the size of generated code by eliminating redundant for loops, achieving up to a six-fold reduction in some cases. This is particularly beneficial for enabling ARM builds with the -O0 optimization level, which previously encountered issues due to excessive code size. The new syntax uses an optional with clause to define a C identifier for the result code.

In Details

The match.pd grammar has been extended with an optional with rescmpcode (identifier) clause in simplify expressions. This allows the result of combine_comparisons or invert_comparisons to be stored in a C variable (rescmpcode in the example), which is then used to conditionally return a tree or the result code itself. This avoids the need for extra for loops when dealing with variations in comparison codes, drastically reducing generated code size and aiding builds like ARM at -O0 where combinatorial explosion of patterns was problematic.

For Context
match.pd
A file containing pattern matching rules used by GCC's tree-based optimizers to recognize and transform specific code structures (expressions and statements) into more efficient forms.
simplify
A directive within GCC's pattern matching system that attempts to simplify an expression based on defined rules, potentially folding constants or applying algebraic identities.
combine_comparisons
A GCC internal function that attempts to simplify or combine two comparison operations into a single, equivalent comparison or logical operation.
tree
GCC's primary intermediate representation for expressions and statements. It is a typed, generalized syntax tree used throughout the compiler's optimization phases.
Filed Under: matchcode generationoptimization