-
Notifications
You must be signed in to change notification settings - Fork 21
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.