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

genrecog: Write each .md condition out once

Reduces the size of insn-recog-*.cc files by emitting conditions as inline functions.

The genrecog tool in GCC previously emitted each pattern condition inline, leading to duplicated code and large generated files. This commit refactors genrecog to define a helper inline function for each unique condition and call that function from the generated code. This significantly reduces the size of insn-recog-*.cc files, speeds up compilation, and lowers memory usage, as demonstrated on AArch64.

In Details

The genrecog tool translates .md pattern descriptions into C code for the GCC instruction recognizer. Previously, common conditions (like TARGET_SVE) were duplicated verbatim for each pattern instance. This change introduces a pattern of defining static inline functions for each unique condition and calling these functions from the generated recognition code. This improves code size and compilation time by reducing redundancy. The functions are inlined by the host compiler, preserving runtime performance.

For Context
genrecog
A GCC internal tool that generates C code for instruction recognition from machine description files (.md).
.md files
Machine description files used by GCC to define target-specific instruction patterns and properties.
insn-recog-*.cc
The C source files generated by genrecog that contain the logic for matching instructions to patterns.
TARGET_SVE
A GCC target-specific macro indicating whether Scalable Vector Extension (SVE) is enabled for the target architecture.
inline function
A function whose code is substituted directly into the calling code by the compiler, avoiding function call overhead.
Filed Under: gccoptimizationcode generationaarch64