23 Jan 2010 02:15:04 +0100

Related articles |
---|

[5 earlier articles] |

Re: Detailed algorithms on inline optimization miles@gnu.org (Miles Bader) (2010-01-20) |

Re: Detailed algorithms on inline optimization rangsynth@gmail.com (Robin Holmes) (2010-01-20) |

Re: Detailed algorithms on inline optimization jeremy.wright@microfocus.com (Jeremy Wright) (2010-01-20) |

Re: Detailed algorithms on inline optimization dot@dotat.at (Tony Finch) (2010-01-21) |

Re: Detailed algorithms on inline optimization bear@sonic.net (Ray) (2010-01-21) |

Re: Detailed algorithms on inline optimization bobduff@shell01.TheWorld.com (Robert A Duff) (2010-01-21) |

Re: Detailed algorithms on inline optimization cdodd@acm.org (Chris Dodd) (2010-01-23) |

Re: Detailed algorithms on inline optimization mcrodgers@gmail.com (Martin Rodgers) (2010-01-24) |

Re: Detailed algorithms on inline optimization anton@mips.complang.tuwien.ac.at (2010-01-25) |

Re: Detailed algorithms on inline optimization monnier@iro.umontreal.ca (Stefan Monnier) (2010-01-25) |

Re: Detailed algorithms on inline optimization kkylheku@gmail.com (Kaz Kylheku) (2010-01-28) |

Re: Detailed algorithms on inline optimization martin@gkc.org.uk (Martin Ward) (2010-01-28) |

Re: Detailed algorithms on inline optimization anton@mips.complang.tuwien.ac.at (2010-01-31) |

[2 later articles] |

From: | Chris Dodd <cdodd@acm.org> |

Newsgroups: | comp.compilers |

Date: | 23 Jan 2010 02:15:04 +0100 |

Organization: | Compilers Central |

References: | 10-01-058 10-01-061 |

Keywords: | optimize |

Robert A Duff <bobduff@shell01.TheWorld.com> wrote in

*> You can inline recursive calls if you limit the depth.*

*>*

*> [True. Does anyone do that, inline the first few times though and then*

*> punt to the normal routine? -John]*

Recent versions of gcc do pretty well. Its instructive to look at what it

does for a naive fibonacci function:

unsigned fib(unsigned n) { return n < 2 ? n : fib(n-2) + fib(n-1); }

Gcc 4.3 with -O3 will turn this into a loop via tail-recursion elimination of

one of the recursive calls, and then inline the other call several times,

ending up with 8 nested loops...

-chris

Post a followup to this message

Return to the
comp.compilers page.

Search the
comp.compilers archives again.