On Thu, Jul 19, 2012 at 8:24 PM, Richard Henderson <r...@redhat.com> wrote: > While adding multiple new optabs over the past week or three, it > occurred to me that (1) there are lots of places to update all in > sync and (2) the representation size of optabs is huge. > > The first issue is somewhat trivially accomplished by moving all > optabs knowledge into an optabs.def file. This could have been > staged differently to prove no errors in the transcription, but > I'm simply going to ask for help reviewing and testing for that. > > The second issue is addressed by recognizing that the contents of > the md file, and thus the set of named patterns, does not change > between sub-targets. The only thing that changes is the value of > HAVE_foo for any pattern foo. > > We currently have a very sparse pattern[max_mode] arrays for the > optabs. Changing that to a dense mapping of known patterns to a > unified pattern array can reduce the dynamic memory requirements > by a factor of 10. Splitting away the truely unchanging portions > to rodata can reduce the non-sharable data by another factor of 10. > > I initially thought of using a minimal perfect hash for the dense > mapping, but gperf turns out to be irritatingly string oriented > and re-implementing a perfect hash algorithm was more than I wanted > to do while I didn't know how much memory I could save. So at the > moment my "hash function" is a binary search over a table. > > Some statistics: > > old sizeof(struct target_optabs): > alpha: 225472 > ppc64: 396088 > i386: 721240 > > new sizeof(struct target_optabs) + new .rodata > alpha: 210 + 3232 > ppc64: 502 + 5568 > i386: 1009 + 9624 > > i386 cc1 old: new: > .text 9381620 9373204 > .rodata 3017472 3031040 > .bss 1499552 778144 > > I've not yet speed tested this, only completed bootstrap + test > runs for both x86_64 and ppc64. I've done sanity cross compiles > to alpha and mips (the only SWITCHABLE_TARGET).
It would be interesting to see startup-time effects of this patch (thus, compile-time of an empty CU). Richard. > I'll be offline til Tuesday, so I won't commit this until then at > least. Hopefully there will be some good feedback on my return. > > FYI, the patchset is available at > > git://repo.or.cz/gcc/rth.git rth/opinit > > > r~ > > > Richard Henderson (4): > Introduce and use unknown_optab > Tidy some include usage + dependencies > Introduce and use code_to_optab and optab_to_code functions > Reduce the size of optabs representation > > gcc/Makefile.in | 35 +- > gcc/builtins.c | 2 +- > gcc/dojump.c | 13 +- > gcc/dwarf2out.c | 1 - > gcc/genopinit.c | 932 +++++++++++++++++++++----------------------- > gcc/ifcvt.c | 4 +- > gcc/libfuncs.h | 3 +- > gcc/lto-streamer-in.c | 1 - > gcc/optabs.c | 709 +++++++--------------------------- > gcc/optabs.def | 289 ++++++++++++++ > gcc/optabs.h | 958 > +++++----------------------------------------- > gcc/rtl.h | 7 +- > gcc/tree-vect-generic.c | 30 +- > gcc/tree-vect-patterns.c | 2 +- > gcc/tree-vect-stmts.c | 2 +- > 15 files changed, 1020 insertions(+), 1968 deletions(-) > create mode 100644 gcc/optabs.def > > -- > 1.7.7.6 >