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

match/fold: Add LT/GT/LE/GE to combine_comparisons

The `combine_comparisons` function now supports less-than, greater-than, less-than-or-equal, and greater-than-or-equal operations.

The combine_comparisons function in GCC’s fold-const.cc has been extended to support the LT, GT, LE, and GE comparison operators. This enhancement, along with a corresponding update in match.pd to use these new capabilities, simplifies the generation of code involving boolean logic and comparisons. It is expected to facilitate better support for phiopt and ifcombine optimizations, particularly for expressions like a > b which can be represented as a & !b.

In Details

The combine_comparisons function, used within fold-const.cc and match.pd, has been augmented to handle LT, GT, LE, and GE comparison codes. Previously, it primarily supported EQ and NE. This change improves the ability to simplify complex conditional expressions and boolean logic, such as representing a > b as a & ~b. The match.pd patterns have been updated to leverage this expanded functionality, which is anticipated to benefit phiopt and ifcombine optimizations.

For Context
combine_comparisons
A GCC internal function that attempts to simplify or combine two comparison operations into a single, equivalent comparison or logical operation.
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.
phiopt
An optimization pass in GCC that deals with PHI nodes in SSA (Static Single Assignment) form, often related to loop-invariant code motion or other control-flow-based optimizations.
ifcombine
An optimization pass in GCC that attempts to combine or simplify conditional statements (if-else structures) and boolean expressions.
SSA
Static Single Assignment form. An intermediate representation where every variable is assigned exactly once, simplifying many data-flow analyses and optimizations.
Filed Under: optimizationpattern matchingboolean logic