Re: Inlining functions with loops

tore@lis.pitt.edu (Tore Joergensen)
9 Dec 1995 19:12:07 -0500

          From comp.compilers

Related articles
[3 earlier articles]
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)
Re: Inlining functions with loops jsa@organon.com (1995-12-09)
Re: Inlining functions with loops cdg@nullstone.com (1995-12-17)
| List of all articles for this month |

From: tore@lis.pitt.edu (Tore Joergensen)
Newsgroups: comp.compilers
Date: 9 Dec 1995 19:12:07 -0500
Organization: University of Pittsburgh
References: 95-11-241 95-12-012
Keywords: optimize, comment

Christopher Glaeser (cdg@nullstone.com) wrote:
: Yes, some C compilers will inline functions with FOR loops. In addition,
: recursion is a type of loop, and some C compilers will inline recursive
: functions.
I think many recursive functions/procedures require a stack (ok.. most
of them can be changed into non-recursive versions, but it will often
require much work and become much more code).


E.g. (print strings in a binary tree):


                          procedure put_tree (tree : pointer) is
                          begin
                                if tree /= null then
                                      put_tree(tree.left);
                                      put_line(tree.line);
                                      put_tree(tree.right);
                                end if;
                          end put_tree;


Will inlining that require maintaining its own stack be more efficient
than a recursive version? Will that depend much on the processor?
--
+-------------------------+-------------------------------------------+
| Tore B. Joergensen | e-mail : tore@lis.pitt.edu |
| Centre Court Villa | web : http://www.pitt.edu/~tojst1 |
| 5535 Centre Avenue # 6 | |
| Pgh, PA 15232, USA | Norwegian MSIS-student at Univ. of Pgh. |
[It's pretty common to optimize out tail recursion, but I'd be quite surprised
if anyone tried to optimize a bushy recursion like this one. -John]
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.