Skip to content

improve loop detection - #1069

Merged
mflatt merged 1 commit into
cisco:mainfrom
mflatt:loop-detect3
Oct 8, 2026
Merged

mflatt merged 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.
@mflatt
mflatt merged commit e3b1363 into cisco:main Oct 8, 2026
17 checks passed
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