aristanetworks / aristanetworks/purescript-backend-optimizer

Add inline annotation for data types

Open
#72 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
PureScript
Stars
216
Forks
24
Avg merge
8m
Merged PRs (30d)
2

Description

One of the more powerful optimizations is case-of-case, which internally translates to the `shouldDistributeBranches` heuristic and the `RewriteDistBranchesLet` rewrite constraint. The problem is that it can result in exponential code explosion, so the heuristic is very conservative, with a hard cap on continuation size. The heuristic is mainly driven by the `ResultTerm` analysis, which can verify that all branches yield a known literal term. If as part of the analysis we noted which data type it resulted in (the constructor's `ProperName` field), we could support inlining annotations that force this optimization to apply whenever possible. Thus we could keep the heuristic conservative, but add annotations for things like Generics, so that the Generics intermediate representation more reliably fuses away.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the ResultTerm analysis, shouldDistributeBranches heuristic, and RewriteDistBranchesLet rewrite constraint. Determine how the constructor's ProperName could be carried through analysis and how annotations for types such as Generics would reach the optimizer. Done means annotations can force applicable inlining while the conservative continuation-size cap still prevents uncontrolled code explosion.

Written by the indexing model from the issue text.

Assessment

Domain
compilers, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.