genoutput writes each output template only once
Reduces code size and improves compile times by avoiding redundant output template definitions.
The genoutput pass now ensures that each unique output template is defined only once, significantly reducing the generated code size and improving compilation performance. Previously, identical templates were redefined multiple times, especially when using iterators. By keying on both the template text and its source location, redundant definitions are now avoided, with subsequent identical templates simply referencing the first. This change led to a substantial reduction in output definition counts and decreased compile times and memory usage on aarch64.
In Details
The genoutput pass in GCC generates output definitions for instruction patterns. This change optimizes this process by deduplicating identical output definitions. Previously, patterns using mode iterators could generate redundant definitions if the template text was the same across different modes. The optimization now keys definitions on both template text and source location, and for templates processed by gensupport without a location, it keys on text alone. Redundant definitions are replaced by references to the first emitted definition, with the count of alternatives preserved to maint…
- genoutput
- A GCC pass responsible for generating the output definitions for instruction patterns based on the machine description.
- output template
- A part of the machine description that specifies how to format the output for a particular instruction pattern.
- iterator
- A construct in GCC's machine description that allows a single pattern to be expanded over multiple modes or values, effectively generating multiple instructions.
- define_insn
- A directive in the GCC machine description that defines an instruction pattern.
- mode iterator
- A type of iterator that expands a pattern for each available machine mode (e.g.,
SImode,DImode). - gensupport
- A tool used by GCC to process machine description files, often handling compact syntax for patterns.
- #line
- A special directive in generated code that indicates the original source file and line number, used for debugging and diagnostics.