public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Improve genmatch code-gen
@ 2015-08-03 10:11 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2015-08-03 10:11 UTC (permalink / raw)
  To: gcc-patches


Since we allow arbitrary IDs in captures the capture array is dense
and thus we don't need to clear it before initializing.  We can
also emit more compact source by simply using an initializer.

-           tree captures[3] ATTRIBUTE_UNUSED = {};
-           captures[0] = o20;
-           captures[1] = op1;
-           captures[2] = op2;
+           tree captures[3] ATTRIBUTE_UNUSED = { o20, op1, op2 };

this has a surprinsingly big effect on code-size at -O0 as well
(on the positive side).

Boostrap & regtest running on x86_64-unknown-linux-gnu.

Richard.

2015-08-03  Richard Biener  <rguenther@suse.de>

	* genmatch.c (dt_simplify::gen): Create captures array
	with an initializer.

Index: gcc/genmatch.c
===================================================================
--- gcc/genmatch.c	(revision 226490)
+++ gcc/genmatch.c	(working copy)
@@ -3023,16 +3195,15 @@ dt_simplify::gen (FILE *f, int indent, b
   output_line_directive (f,
 			 s->result ? s->result->location : s->match->location);
   if (s->capture_max >= 0)
-    fprintf_indent (f, indent, "tree captures[%u] ATTRIBUTE_UNUSED = {};\n",
-		    s->capture_max + 1);
-
-  for (int i = 0; i <= s->capture_max; ++i)
-    if (indexes[i])
-      {
-	char opname[20];
-	fprintf_indent (f, indent, "captures[%u] = %s;\n",
-			i, indexes[i]->get_name (opname));
-      }
+    {
+      char opname[20];
+      fprintf_indent (f, indent, "tree captures[%u] ATTRIBUTE_UNUSED = { %s",
+		      s->capture_max + 1, indexes[0]->get_name (opname));
+
+      for (int i = 1; i <= s->capture_max; ++i)
+	fprintf (f, ", %s", indexes[i]->get_name (opname));
+      fprintf (f, " };\n");
+    }
 
   /* If we have a split-out function for the actual transform, call it.  */
   if (info && info->fname)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-08-03 10:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-03 10:11 [PATCH] Improve genmatch code-gen Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).