SUNDAY, AUGUST 2, 2026
match
match: Combine four fors into one for.
Simplifies `genmatch` output by merging four `for` loops into one, reducing generated C++ code.
This commit merges four for loops within the genmatch pattern definitions into a single for loop. This simplification reduces the amount of C++ code generated by genmatch, addressing PRs related to tree optimization and code size.
In Details
In match.pd, this change consolidates four distinct for constructs into a single for loop. This reduces the complexity and size of the C++ code generated by genmatch, impacting the tree-optimization passes that rely on this generated code. It addresses issues reported in PRs 117760 and 125442.
For Context
- genmatch
- A utility within GCC that generates C++ code for pattern matching. It takes pattern definitions and produces efficient code to check for those patterns, often used in compiler passes.
- C++ code generation
- The process by which the compiler translates internal representations of code into C++ source code, which is then further processed. In this case,
genmatchgenerates C++ code for its own pattern-matching logic. - Tree optimization
- A phase in the GCC compiler where intermediate representations of the code (in the form of abstract syntax trees or similar structures) are analyzed and transformed to improve performance, reduce code size, or enable other optimizations.