Skip to content

Call-site inliner: admit saturated n-ary worker calls #245

Description

@Unisay

Problem

inlineSaturatedCall (the #180 budgeted call-site inliner) matches a call by peeling the curried unary spine with unwindApp and requiring a Ref head. A genuinely n-ary call produced by the uncurrying pass, AppN (Ref f$w) [a, b], never matches: the n-ary node is not a spine link, so the head comes back as the whole AppN with no peeled arguments and the rule declines. Saturated calls of uncurried workers are therefore invisible to call-site inlining, even when the worker is a literal lambda within inlineSizeBudget. The shape is everywhere after the worker/wrapper split (#24), and today it only collapses when a domino cascade happens to make the worker used-once for the whole-binding inliner, as observed while landing #231.

Approach

Extend the match to accept an AppN (Ref f) args head whose argument count equals the manifest parameter count of the env RHS (an AbsN of the same arity), reusing the existing budget and self-reference checks. The n-ary betaReduce already reduces the resulting redex at exact arity, so no new reduction machinery is needed.

Prerequisites / Relations

Builds on #180 (the call-site inliner) and #24 (uncurrying introduces the shape). Overlaps in effect with #211 (inline small pure bindings regardless of use count): either can collapse a small worker, but this rule fires per site under the existing budget and needs no new policy decision.

Verification / Measurement

A focused optimizer test: an n-ary worker under budget referenced from two saturated AppN call sites inlines at both under InlineCallSites, and a partial or over-applied site is left alone. Structural goldens shrink where worker calls collapse; eval goldens unchanged. Corpus size delta through #172.

Metadata

Metadata

Assignees

Labels

OptimisationA Compiler Optimisationarea: irIR / optimizer / DCE / inlinerenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions