This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][RFT] Reduce gimple-match.c compile-time(?)


The following patch implements the simplest approach of splitting
the huge functions in gimple-match.c (not yet generic-match.c).

In my dev tree it does:

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
Splitting off BIT_NOT_EXPR with 27 leafs and 107 nodes
Splitting off BUILT_IN_BSWAP16 with 8 leafs and 35 nodes
Splitting off BUILT_IN_BSWAP32 with 8 leafs and 35 nodes
Splitting off BUILT_IN_BSWAP64 with 8 leafs and 35 nodes
Splitting off BUILT_IN_LOGF with 8 leafs and 24 nodes
Splitting off BUILT_IN_LOG with 8 leafs and 24 nodes
Splitting off BUILT_IN_LOGL with 8 leafs and 24 nodes
Splitting off BUILT_IN_LOG2F with 8 leafs and 24 nodes
Splitting off BUILT_IN_LOG2 with 8 leafs and 24 nodes
Splitting off BUILT_IN_LOG2L with 8 leafs and 24 nodes
Splitting off BUILT_IN_LOG10F with 8 leafs and 24 nodes
Splitting off BUILT_IN_LOG10 with 8 leafs and 24 nodes
Splitting off BUILT_IN_LOG10L with 8 leafs and 24 nodes
Splitting off PLUS_EXPR with 47 leafs and 221 nodes
Splitting off MINUS_EXPR with 47 leafs and 212 nodes
Splitting off BIT_IOR_EXPR with 53 leafs and 224 nodes
Splitting off BIT_XOR_EXPR with 56 leafs and 251 nodes
Splitting off MULT_EXPR with 9 leafs and 31 nodes
Splitting off RDIV_EXPR with 8 leafs and 22 nodes
Splitting off TRUNC_MOD_EXPR with 10 leafs and 35 nodes
Splitting off LT_EXPR with 21 leafs and 79 nodes
Splitting off GE_EXPR with 21 leafs and 79 nodes
Splitting off GT_EXPR with 21 leafs and 78 nodes
Splitting off LE_EXPR with 21 leafs and 78 nodes
Splitting off BIT_AND_EXPR with 62 leafs and 279 nodes
Splitting off NE_EXPR with 39 leafs and 159 nodes
Splitting off RSHIFT_EXPR with 8 leafs and 31 nodes
Splitting off EQ_EXPR with 35 leafs and 138 nodes

where you can see the maximum function size being around 3000 LOC
after the patch.

On x86_64-unknown-linux-gnu this makes not much difference
(just tried building with an installed compiler using -O2 -g),
it's 24s vs. 32s.

Can people who reported huge compile-times test this patch
and report back?

Thanks,
Richard.

2015-07-24  Richard Biener  <rguenther@suse.de>

	* genmatch.c (decision_tree::gen_gimple): Split out large
	subtrees into separate functions.

Index: gcc/genmatch.c
===================================================================
--- gcc/genmatch.c	(revision 226154)
+++ gcc/genmatch.c	(working copy)
@@ -2949,8 +2962,38 @@ decision_tree::gen_gimple (FILE *f)
 	   "a total number of %u nodes\n", root->num_leafs, root->max_level,
 	   root->total_size);
 
+  const unsigned split_off_point = 8;
+
   for (unsigned n = 1; n <= 3; ++n)
     {
+      /* First generate split-out functions.  */
+      for (unsigned i = 0; i < root->kids.length (); i++)
+	{
+	  dt_operand *dop = static_cast<dt_operand *>(root->kids[i]);
+	  expr *e = static_cast<expr *>(dop->op);
+	  if (e->ops.length () != n)
+	    continue;
+
+	  if (dop->num_leafs < split_off_point)
+	    continue;
+
+	  fprintf (stderr, "Splitting off %s with %u leafs and %u nodes\n",
+		   e->operation->id, dop->num_leafs, dop->total_size);
+
+	  fprintf (f, "\nstatic bool\n"
+		   "gimple_simplify_%s (code_helper *res_code, tree *res_ops,\n"
+		   "                 gimple_seq *seq, tree (*valueize)(tree),\n"
+		   "                 code_helper ARG_UNUSED (code), tree type",
+		   e->operation->id);
+	  for (unsigned i = 0; i < n; ++i)
+	    fprintf (f, ", tree op%d", i);
+	  fprintf (f, ")\n");
+	  fprintf (f, "{\n");
+	  dop->gen_kids (f, 2, true);
+	  fprintf (f, "  return false;\n");
+	  fprintf (f, "}\n");
+	}
+
       fprintf (f, "\nstatic bool\n"
 	       "gimple_simplify (code_helper *res_code, tree *res_ops,\n"
 	       "                 gimple_seq *seq, tree (*valueize)(tree),\n"
@@ -2976,10 +3019,21 @@ decision_tree::gen_gimple (FILE *f)
 	    fprintf (f, "    case %s%s:\n",
 		     is_a <fn_id *> (e->operation) ? "-" : "",
 		     e->operation->id);
-	  fprintf (f,   "      {\n");
-	  dop->gen_kids (f, 8, true);
-	  fprintf (f,   "        break;\n");
-	  fprintf (f,   "      }\n");
+	  if (dop->num_leafs < split_off_point)
+	    {
+	      fprintf (f,   "      {\n");
+	      dop->gen_kids (f, 8, true);
+	      fprintf (f,   "        break;\n");
+	      fprintf (f,   "      }\n");
+	    }
+	  else
+	    {
+	      fprintf (f, "      return gimple_simplify_%s (res_code, res_ops, "
+		       "seq, valueize, code, type", e->operation->id);
+	      for (unsigned i = 0; i < n; ++i)
+		fprintf (f, ", op%d", i);
+	      fprintf (f, ");\n");
+	    }
 	}
       fprintf (f,       "    default:;\n"
 	                "    }\n");


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]