Skip to content

improve loop detection - #1069

Open
mflatt wants to merge 1 commit into
cisco:mainfrom
mflatt:loop-detect3
Open

mflatt wants to merge 1 commit into
cisco:mainfrom
mflatt:loop-detect3

Conversation

@mflatt

@mflatt mflatt commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Generalize the recognized pattern from

 (letrec ([f (lambda ....)])
   (f arg ...))

to allow a loop entry into f to be anywhere in the letrec body as long as there's a single call to f as an entry point (and f is otherwise only tail-called within the lambda body). Also, avoid merging letrecs in the cpletrec pass, which can otherwise obscure loops.

Loops conversion by itself doesn't help all that much, since function calls are already fast. But loop conversion can enable floating-point unboxing, which can offer substantial performance benefits.

Generalize the recognized pattern from

```
 (letrec ([f (lambda ....)])
   (f arg ...))
```

to allow a loop entry into `f` to be anywhere in the `letrec` body as
long as there's a single call to `f` as an entry point (and `f` is
otherwise only tail-called within the `lambda` body). Also, avoid
merging `letrec`s in the cpletrec pass, which can otherwise obscure
loops.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant