aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2015-07-24 12:39:08 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2015-07-24 12:39:08 +0000
commit803835ded7f4ed4bbfcf0bbb427c7cf1f23203ac (patch)
treeff65bc2fd54f85c55f0e4f564fb9e6a7f1c9d59c /gcc
parent21aacde45801e932d3de8f7547fda44226ae9764 (diff)
downloadgcc-803835ded7f4ed4bbfcf0bbb427c7cf1f23203ac.zip
gcc-803835ded7f4ed4bbfcf0bbb427c7cf1f23203ac.tar.gz
gcc-803835ded7f4ed4bbfcf0bbb427c7cf1f23203ac.tar.bz2
genmatch.c (struct dt_node): Add statistic fields.
2015-07-24 Richard Biener <rguenther@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. From-SVN: r226154
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/genmatch.c43
2 files changed, 51 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d7f6ca5..0e18f35 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,13 @@
2015-07-24 Richard Biener <rguenther@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.
+
+2015-07-24 Richard Biener <rguenther@suse.de>
+
* fold-const.c (fold_binary_loc): Move simplifying of comparisons
against the highest or lowest possible integer ...
* match.pd: ... as patterns here.
diff --git a/gcc/genmatch.c b/gcc/genmatch.c
index 83e66c6..ce90a74 100644
--- a/gcc/genmatch.c
+++ b/gcc/genmatch.c
@@ -1212,6 +1212,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 +1231,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 +1435,30 @@ dt_node::append_simplify (simplify *s, unsigned pattern_no,
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. */
@@ -2912,6 +2943,12 @@ dt_simplify::gen (FILE *f, int indent, bool gimple)
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"
@@ -2958,6 +2995,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"