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]

[rfc] Expose more tailcall opportunities (PR


Hi,

Rth had this nice example some time ago:

struct S { int w, x, y, z; };
struct T { int r; struct S s; };
void bar (struct S, int);
void foo (int a, struct T b)
{
  struct S *c = 0;
  if (a)
    c = &b.s;
  bar (*c, a);
}

GCC currently doesn't produce a tail call for this, but it could.
With the attached patch, tree-tailcall can see that even though
b is addressable, b is not call clobbered.  That means, iiuc, that
its address doesn't escape either.  Does this patch make sense?
It passed bootstrap and testing on x86_64 (unix{,-m32}) and on ppc.

Gr.
Steven

Index: tree-tailcall.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-tailcall.c,v
retrieving revision 2.45
diff -u -3 -p -r2.45 tree-tailcall.c
--- tree-tailcall.c	13 Jul 2005 22:35:28 -0000	2.45
+++ tree-tailcall.c	18 Jul 2005 09:21:02 -0000
@@ -185,7 +185,7 @@ suitable_for_tail_call_opt_p (void)
   for (param = DECL_ARGUMENTS (current_function_decl);
        param;
        param = TREE_CHAIN (param))
-    if (TREE_ADDRESSABLE (param))
+    if (TREE_ADDRESSABLE (param) && is_call_clobbered (param))
       return false;
 
   return true;


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