GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
genmatch

genmatch: Try later patterns when a transform needs a sequence

Improves error handling in genmatch by falling back to subsequent patterns instead of aborting the entire match.

This commit enhances the error handling in GCC’s genmatch pass. Previously, if a GIMPLE transform required a sequence for a COND_EXPR substitution and none was available, the entire matching process would fail. The change modifies the code to jump to the failure label of the current pattern instead, allowing matching to continue with subsequent patterns. This prevents a local failure from causing a global skip of all remaining patterns.

In Details

In genmatch.cc, when a GIMPLE transform substitutes a capture that matched a COND_EXPR condition, and the captured value is not a COND_EXPR itself, gen_transform attempts to build the comparison. If no seq (sequence) is available to build it, the original code returned false, aborting the entire pattern matching for that transform. This commit changes this behavior to goto next_after_fail, allowing the matching to continue with the next pattern, similar to how other transform failures are handled.

For Context
genmatch
A GCC pass that generates C code for pattern matching, used for optimizing specific code structures.
GIMPLE transform
A transformation applied to the GIMPLE intermediate representation of code.
COND_EXPR
A GCC internal representation for conditional expressions (like C's ternary operator).
pattern matching
The process of finding and applying specific code structures or patterns within the intermediate representation.
Filed Under: genmatchbugfix