Related articles |
---|
Inlining functions with loops mpr@absoft.com (Michael Rice) (1995-11-29) |
Re: Inlining functions with loops jplevyak@violet-femmes.cs.uiuc.edu (1995-11-30) |
Re: Inlining functions with loops meissner@cygnus.com (Michael Meissner) (1995-11-30) |
Re: Inlining functions with loops preston@tera.com (1995-11-30) |
Re: Inlining functions with loops ayers@apollo.hp.com (1995-11-30) |
Re: Inlining functions with loops cdg@nullstone.com (1995-12-01) |
Re: Inlining functions with loops jeremy@suede.sw.oz.au (1995-12-01) |
Inlining functions with loops dave@occl-cam.demon.co.uk (Dave Lloyd) (1995-12-01) |
Re: Inlining functions with loops serrano@ardeche.IRO.UMontreal.CA (1995-12-01) |
Re: Inlining functions with loops tore@lis.pitt.edu (1995-12-09) |
Re: Inlining functions with loops preston@tera.com (1995-12-09) |
Re: Inlining functions with loops ball@Eng.Sun.COM (1995-12-09) |
Re: Inlining functions with loops ok@cs.rmit.edu.au (1995-12-09) |
[2 later articles] |
Newsgroups: | comp.compilers |
From: | jeremy@suede.sw.oz.au (Jeremy Fitzhardinge) |
Keywords: | optimize, C++ |
Organization: | Softway Pty Limited |
References: | 95-11-241 |
Date: | Fri, 1 Dec 1995 08:44:05 GMT |
"Michael Rice" <mpr@absoft.com> writes:
>All C++ compilers that I am aware of will not inline a function if it
>contains any type of loop. Is anyone aware of ANY C++ compiler that
>will do this? Is anyone aware of a compiler for any language which is
>able to do this?
Gcc certainly does - it will even inline obviously tail-recursive
functions.
>I believe the basic problem is the inability to convert such a function
>to a suitable expression tree. That is, loops are syntactically statements
>with no equivalent expression-like construct.
Yes, its probably a representation problem. If you have a strictly
tree-based IR then it may be quite hard to manage. However, a general
SSA graph style IR can cope with function inlining quite easily.
Inlining is simply a matter of connecting up the values passed in with
the arguments used within the function and then running the normal
optimisations over the complete graph. This gives you all the real
wins of inlining (constant propagation, etc).
>I also have to wonder if this is worth the work. Any comments?
Well, it depends, but probably. If you have a loop with bounds
specified by function arguments, and the caller passes constants, you
can get pretty good improvments, particularly if you do loop
unrolling. If you do alias analysis you get "interprocedural"
alias analysis for free.
J
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.