This calculates size estimates for the decision (sub-)trees and dumps info to stderr. My dev tree says:
build/genmatch --gimple /space/rguenther/tramp3d/trunk/gcc/match.pd \ > tmp-gimple-match.c GIMPLE decision tree has 696 leafs, maximum depth 10 and a total number of 2786 nodes build/genmatch --generic /space/rguenther/tramp3d/trunk/gcc/match.pd \ > tmp-generic-match.c GENERIC decision tree has 696 leafs, maximum depth 10 and a total number of 2786 nodes the idea is to play with the simple idea of splitting the simplify functions into equally sized pieces with a toplevel switch (code) { case PLUS_EXPR: case MINUS_EXPR: return do_part1 (); case ... this should be relatively straight-forward and eventually helps compile-time enough while we work on reducing the amount of generated code (that hit some obstackles I have to think about some more). Eventually we can split this into multiple files as well. Bootstrapping on x86_64-unknown-linux-gnu. Richard. 2015-07-24 Richard Biener <rguent...@suse.de> * genmatch.c (struct dt_node): Add statistic fields. (dt_node::analyze): New method. (decision_tree::gen_gimple): Call analyze on the root node and print statistics to stderr. (decision_tree::gen_generic): Likewise. Index: gcc/genmatch.c =================================================================== --- gcc/genmatch.c (revision 226140) +++ gcc/genmatch.c (working copy) @@ -1212,6 +1225,11 @@ struct dt_node unsigned level; vec<dt_node *> kids; + /* Statistics. */ + unsigned num_leafs; + unsigned total_size; + unsigned max_level; + dt_node (enum dt_type type_): type (type_), level (0), kids (vNULL) {} dt_node *append_node (dt_node *); @@ -1226,6 +1244,8 @@ struct dt_node void gen_kids_1 (FILE *, int, bool, vec<dt_operand *>, vec<dt_operand *>, vec<dt_operand *>, vec<dt_operand *>, vec<dt_operand *>, vec<dt_node *>); + + void analyze (); }; /* Generic decision tree node used for DT_OPERAND and DT_MATCH. */ @@ -1428,6 +1448,30 @@ dt_node::append_simplify (simplify *s, u return append_node (n); } +/* Analyze the node and its children. */ + +void +dt_node::analyze () +{ + num_leafs = 0; + total_size = 1; + max_level = level; + + if (type == DT_SIMPLIFY) + { + num_leafs = 1; + return; + } + + for (unsigned i = 0; i < kids.length (); ++i) + { + kids[i]->analyze (); + num_leafs += kids[i]->num_leafs; + total_size += kids[i]->total_size; + max_level = MAX (max_level, kids[i]->max_level); + } +} + /* Insert O into the decision tree and return the decision tree node found or created. */ @@ -2895,6 +2956,12 @@ dt_simplify::gen (FILE *f, int indent, b void decision_tree::gen_gimple (FILE *f) { + root->analyze (); + + fprintf (stderr, "GIMPLE decision tree has %u leafs, maximum depth %u and " + "a total number of %u nodes\n", root->num_leafs, root->max_level, + root->total_size); + for (unsigned n = 1; n <= 3; ++n) { fprintf (f, "\nstatic bool\n" @@ -2941,6 +3008,12 @@ decision_tree::gen_gimple (FILE *f) void decision_tree::gen_generic (FILE *f) { + root->analyze (); + + fprintf (stderr, "GENERIC decision tree has %u leafs, maximum depth %u and " + "a total number of %u nodes\n", root->num_leafs, root->max_level, + root->total_size); + for (unsigned n = 1; n <= 3; ++n) { fprintf (f, "\ntree\n"