Understanding core2core optimisation pipeline
Simon Peyton Jones
simonpj at microsoft.com
Fri Oct 31 10:42:34 UTC 2014
Jan
As people respond on this thread, would you be willing to capture what you learn in a wiki page in the Commentary? That way, your successor would have at least those questions answered right away. Somewhere under here https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler would be good.
| 1. I'm still a bit confused about terminology. Demand analysis,
| strictness analysis, cardinality analysis - do these three terms mean
| exactly the same thing? If no, then what are the differences?
Strictness and demand analysis are the same.
Cardinality analysis, strictness/demand analysis, and CPR analysis, are all different analyses, but they are all carried out by the same piece of code, namely DmdAnal.
| 2. First pass of full laziness is followed by floating in. At that
| stage we have not yet run the demand analysis and yet the code that
| does the floating-in checks whether a binder is one-shot
| (FloatIn.okToFloatInside called by FloatIn.fiExpr AnnLam case). This
| suggests that cardinality analysis is done earlier (but when?) and
| that demand analysis is not the same thing as cardinality analysis.
Imported functions (eg foldr or build) have strictness and cardinality analysis info in their interface file signatures. That can in turn drive the attachment of one-shot info to binders. See
one_shots = argsOneShots (idStrictness fun) n_val_args
-- See Note [Use one-shot info]
line 1345 of OccurAnal.
| 3. Does demand analyser perform any transformations? Or does it only
| annotate Core with demand information that can be used by subsequent
| passes?
The demand analyser simply annotates Core
It is immediately followed by the worker/wrapper transformation, which uses the strictness annotations to transform Core using the w/w idea.
| 4. BasicTypes module defines:
|
| data OneShotInfo = NoOneShotInfo -- ^ No information
| | ProbOneShot -- ^ The lambda is probably applied
| at most once
| | OneShotLam -- ^ The lambda is applied at most
| once.
|
| Do I understand correctly that `NoOneShotInfo` really means no
| information, ie. a binding annotated with this might in fact be one
| shot?
Correct
| If so, then do we have means of saying that a binding is
| certainly not a one-shot binding?
We do not.
| 5. What is the purpose of SetLevels.lvlMFE function?
It decides what level to float an expression out to.
Simon
|
More information about the ghc-devs
mailing list