From: Kyrylo Tkachov <[email protected]>
The sources the machine description generators write are among the slowest
objects to compile in a bootstrap. GCC already works around this by cutting
insn-emit and insn-recog into numbered partitions, which spreads the cost over
more processes.
Before improving and extending the splitting machinery, I think we should first
try to optimise the generated code from the generators as much as possible.
In these patches I try to teach the generators to write repeated text once,
or to replace regular code with a table that a small interpreter walks.
Nothing about the interfaces changes, so the rest of the compiler is
untouched.
Measured over one configuration per backend, 46 backends, counting every
insn-*.cc and insn-*.h a generator writes and summing over all partitions:
generator bytes base bytes new % lines % stmts base stmts new
%
extract 6954308 1018570 -85.4 -87.9 35744 2116
-94.1
output 91193978 53162187 -41.7 -87.4 67516 32910
-51.3
recog 74649869 54765387 -26.6 -15.7 712451 727994
+2.2
opinit 4398223 3377021 -23.2 -20.2 44034 9332
-78.8
attrtab 64906810 63096558 -2.8 -2.0 106488 102829
-3.4
emit 107926701 106158175 -1.6 -1.0 814206 814206
+0.0
TOTAL 350029889 281577898 -19.6 -44.2 1780439 1689387
-5.1
Every backend shrinks. The reduction runs from 25.0% on vax to 2.7% on moxie,
with a median of 12.4%. The larger backends gain most in absolute terms:
riscv 140.0MB to 107.7MB, i386 57.0MB to 49.9MB, aarch64 40.4MB to 31.4MB.
Patches 1 to 9 do the compaction, grouped by generator. Patches 10 to 12 are a
respin of https://gcc.gnu.org/pipermail/gcc-patches/2026-August/726474.html.
Give the generators one output mechanism, apply it to genattrtab, and let a
target
choose its own partition counts. With the sources this much smaller the counts
no longer need to be large, so AArch64 drops from ten emit and ten recog
partitions to six, and stops splitting insn-attrtab at all.
On bootstrap time the effect is currently small. On an idle x86_64 machine at
-j48, three rounds alternating baseline and series, the series uses 1.18% less
CPU and 0.50% less wall time. A bootstrap is dominated by libstdc++, libgcc
and three stages of the compiler, so the generated sources are a small share
of the whole even after these reductions.
The other big seriliser is the gimple genmatch stuff that produces a very large
COND_EXPR match function. I have ideas on how to split that, but that will be a
separate patch. Once that happens I expect this series to matter much more.
In the meantime I think it would help with things like Jeff's userspace
emulation-assisted bootstraps.
Bootstrapped on aarch64 and on x86_64.
All 191 config-list.mk configurations were built, of which 187 succeed.
The four that do not are pre-existing.
Every prefix of the series builds, so the series is
bisectable.
Ok for trunk?
Thanks,
Kyrill
Kyrylo Tkachov (12):
contrib: match the split insn-emit sources in filter-clang-warnings.py
genoutput: emit insn_data and operand_data compactly
genoutput: write each output template out once
genopinit: group optab patterns by their availability condition
genextract: drive insn_extract from the operand path table
genrecog: write each .md condition out once
genemit: emit the split dump message through a helper
genemit: spread the overloaded-name definitions over the output files
genattrtab: table-drive attributes that are functions of one other
attribute
gensupport: Centralize machine-generator output management
genattrtab: Distribute generated code across multiple files
configure: Add target defaults for MD generator partitions
contrib/filter-clang-warnings.py | 4 +-
gcc/Makefile.in | 63 +++--
gcc/config.gcc | 8 +
gcc/config/arc/arc-protos.h | 3 +-
gcc/config/ia64/ia64.cc | 4 +-
gcc/config/ia64/t-ia64 | 3 +-
gcc/config/sh/sh.h | 5 +-
gcc/configure | 93 ++++++-
gcc/configure.ac | 82 ++++++-
gcc/doc/install.texi | 11 +
gcc/emit-rtl.cc | 12 +
gcc/final.cc | 2 +-
gcc/genattrtab.cc | 406 +++++++++++++++++++++++++++----
gcc/genemit.cc | 32 ++-
gcc/genextract.cc | 316 +++++++++++++++---------
gcc/genopinit.cc | 112 ++++++---
gcc/genoutput.cc | 138 ++++++-----
gcc/genrecog.cc | 119 ++++++---
gcc/gensupport.cc | 80 ++++--
gcc/gensupport.h | 16 +-
gcc/recog.h | 20 +-
gcc/rtl.h | 1 +
gcc/system.h | 9 -
23 files changed, 1128 insertions(+), 411 deletions(-)
--
2.50.1 (Apple Git-155)