Lisp HUG Maillist Archive

tail merging

Hi,

under the Linux version the compiler optimizes the toy example 
correctly;
unfortunately, it fails to optimize the real code that depends on tail 
merging.
I will, of course, unroll tail recursion manually -- this is tedious 
but doable.

But it's a pity to get stumbled on an issue like this: all other lisp 
implementations
available to me (CMUCL, Allegro CL, OpenMCL, CLISP, SBCL) optimize this 
code
into a loop without a problem; and that's what I would expect to happen.

David


Re: tail merging

On Mon, 12 Dec 2005 22:59:05 +0400, David Tolpin <dvd@davidashen.net> wrote:

> under the Linux version the compiler optimizes the toy example
> correctly; unfortunately, it fails to optimize the real code that
> depends on tail merging.  I will, of course, unroll tail recursion
> manually -- this is tedious but doable.
>
> But it's a pity to get stumbled on an issue like this: all other
> lisp implementations available to me (CMUCL, Allegro CL, OpenMCL,
> CLISP, SBCL) optimize this code into a loop without a problem; and
> that's what I would expect to happen.

I suggest that you send a bug report to LispWorks support.  As long as
you don't show the code to anyone (which is understandable for
proprietary stuff) this is hard to comment on.  Maybe it's a bug?
Maybe /you/ made a mistake?  Who knows?


Re: tail merging

On Tue, 13 Dec 2005 00:19:24 +0400, David Tolpin <dvd@davidashen.net> wrote:

> the code is not secret. It just takes time to make it suitable for a
> bug report. I expect the code below to be optimized into a chain of
> tail calls. It meets the expectation with CMUCL, Allegro Common
> Lisp, OpenMCL, and CLISP. However, on both Linux and Mac OS X,
> Lispworks 4.4.6, it causes stack overflow with any compiler
> settings. You can try it. Run (test-runes 10000) to see the effect.

Yes, I can confirm that I also see the stack overflow on LWW 4.4.6 and
I don't see it with other Lisp implementations I have here.

> If you know how to make Lispworks compile it, I would be grateful.

I was just playing around and I noticed that replacing the second
LABELS with FLET did the trick for me - now the stack overflow is
away, even without declarations.

I'd still say you should file this as a bug report.

Cheers,
Edi.


Updated at: 2020-12-10 08:49 UTC