tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] return stmt optimalization


From: Zdenek Pavlas
Subject: [Tinycc-devel] return stmt optimalization
Date: Mon, 03 Oct 2005 16:55:17 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050831 Debian/1.7.8-1sarge2

Very cheap and quite effective since tail return is common.
Please test.

Should apply to all archs, but then arch-depenendent size
of jump instruction needs #defining.

Index: tcc.c
===================================================================
RCS file: /cvsroot/tinycc/tinycc/tcc.c,v
retrieving revision 1.179
diff -u -b -B -w -p -r1.179 tcc.c
--- tcc.c       3 Sep 2005 22:51:34 -0000       1.179
+++ tcc.c       3 Oct 2005 14:23:58 -0000
@@ -8926,6 +8926,13 @@ static void gen_function(Sym *sym)
     gfunc_prolog(&sym->type);
     rsym = 0;
     block(NULL, NULL, NULL, NULL, 0, 0);
+#ifdef TCC_TARGET_I386
+    if (rsym == ind - 4) {
+        /* kill the final jump to the epilog */
+        rsym = *(int*)(cur_text_section->data + rsym);
+        ind -= 5;
+    }
+#endif
     gsym(rsym);
     gfunc_epilog();
     cur_text_section->data_offset = ind;

--
Zdenek Pavlas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]