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

Combine several patterns into fors in genmatch.

Reduces genmatch's C++ output size by combining patterns.

This commit refactors the genmatch tool by combining several patterns into for loops. This change aims to reduce the amount of C++ code generated by genmatch, leading to smaller output files. The modification was tested and verified through bootstrapping and regression testing on an x86_64 Linux system.

In Details

The match.pd file, which defines patterns for genmatch, has been modified to consolidate multiple distinct patterns into for constructs. This optimization reduces the verbosity and size of the generated C++ code, making the output of genmatch more compact. This change affects the pattern matching infrastructure used for various compiler passes.

For Context
genmatch
A tool within GCC that generates C++ code for pattern matching based on pattern definitions. This generated code is often used in various compiler passes for tasks like optimization and analysis.
pattern matching
A technique used in programming and compilers to check if a given data structure or sequence conforms to a specific structure or pattern. It's often used in optimization passes to identify code constructs that can be transformed.
bootstrapping
The process of compiling a compiler using an earlier version of itself. This is a common method for testing compiler changes and ensuring the compiler can build itself correctly.
Filed Under: buildcompiler