GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
match.pd

match.pd: Remove redundant ORDERED & NE to LTGT fold

Redundant pattern matching rule removed from match.pd, simplifying comparison folding.

A redundant pattern matching rule in match.pd, which folded ORDERED & NE comparisons to LTGT, has been removed. The existing generic pattern already handles these cases through combine_comparisons, making this specific rule unnecessary. This change streamlines the pattern matching logic for comparisons.

In Details

The match.pd file contains pattern matching rules for GENERIC intermediate representation. This commit removes a specific rule that combined ORDERED and NE (Not Equal) comparisons into LTGT (Less Than, Greater Than) conditions. The existing combine_comparisons mechanism already handles such folds, making the explicit rule redundant. The fold was also problematic with trapping math and NaNs, which is now addressed by removing it.

For Context
match.pd
A file in GCC containing pattern matching rules used to optimize the GENERIC intermediate representation.
ORDERED
A comparison predicate that is true if neither operand is NaN (Not a Number).
NE
Not Equal comparison operator.
LTGT
A combined Less Than and Greater Than condition, often used as a shorthand for certain comparison outcomes.
GENERIC
The first compiler intermediate representation (IR) in GCC, representing code in a tree-like structure before further optimizations and target-specific lowering.
NaN
Not a Number. A special floating-point value used to represent undefined or unrepresentable results, such as from dividing by zero or taking the square root of a negative number.
Filed Under: optimizationpattern matching