LetFloating
scalus.sir.lowering.simple.LetFloating
object LetFloating
Let-floating transformation that moves lazy let bindings closer to their usage points.
This transformation implements "floating inward" as described in: Simon Peyton Jones, Will Partain, and André Santos. 1996. Let-floating: moving bindings to give faster programs.
The algorithm works in three phases:
- Enrichment pass (down-traversal): Build enriched SIR with node indices, track variable usage, lambda context, and dependencies
- Analysis pass: Find dominating nodes for each lazy let binding using tracked usage information and transitive dependency propagation
- Output generation pass (down-traversal): Reconstruct SIR, moving lazy lets to their computed dominating nodes
Lambda barrier: Non-effortless bindings (computations) are prevented from crossing lambda boundaries to avoid duplicating work when the lambda is called multiple times. Effortless bindings (constants, variables, lambdas) can cross freely.
TODO: optimization can introduce expressions like App((lambda x, x),y) which can be eliminated. Maybe add a beta-reduction pass after let-floating, or just handle it here.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
LetFloating.type
Members list
In this article