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]

Re: [PATCH] New tests for sibling call optimisation


On 04-Nov-2002, Andreas Bauer <baueran@in.tum.de> wrote:
> --- /dev/null   Sun Jul 14 11:06:13 2002
> +++ sibcall-6.c Mon Nov  4 14:48:12 2002
> @@ -0,0 +1,23 @@
> +/* A simple check to see whether indirect calls are
> +   being sibcall optimized on targets that do support
> +   this notion, i.e. have the according call patterns
> +   in place.
> +
> +   Copyright (C) 2002 Free Software Foundation Inc.
> +   Contributed by Andreas Bauer <baueran@in.tum.de>  */
> +
> +/* { dg-do compile { target i?86-*-* } } */
> +/* { dg-options "-O2 -foptimize-sibling-calls" } */
> +
> +int (*ptr) (int);
> +extern int bar (int);
> +
> +int
> +foo (f)
> +     int f;
> +{
> +  ptr = bar;
> +  return (*ptr)(f);
> +}
> +
> +/* { dg-final { scan-assembler "jmp" } } */

This is not a very good test, since it is likely that a future version
of gcc will optimize this to just a direct (tail)call to bar(); at that
point, the test will continue to succeed, but will no longer be testing
what it is supposed to be testing.

It would be better to delete the assignment "ptr = bar;"
(and the declaration of "bar").

> +++ sibcall-7.c Mon Nov  4 14:48:39 2002
> @@ -0,0 +1,22 @@
> +/* A simple check to make sure that indirect calls to
> +   functions which do not return are not being sibcall
> +   optimized.

It would be helpful if the comments in this test case
explained why such calls should not be optimized.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.


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