Re: Understanding core2core optimisation pipeline

On Thu, Oct 30, 2014 Jan Stolarek wrote:
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.
If you're looking at super-recent code, that could be Joachim Breitner's work. He's exposed the one-shot stuff at the Haskell level with the experimental magic oneShot function, intended primarily for use in the libraries to make foldl-as-foldr and related things be analyzed more reliably. The old GHC arity analysis combined with his Call Arity get almost everything right, but there are occasional corner cases where things go wrong, and when they do the results tend to be extremely bad.

On Thu, Oct 30, 2014 at 9:55 AM, David Feuer
On Thu, Oct 30, 2014 Jan Stolarek wrote:
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.
If you're looking at super-recent code, that could be Joachim Breitner's work. He's exposed the one-shot stuff at the Haskell level with the experimental magic oneShot function, intended primarily for use in the libraries to make foldl-as-foldr and related things be analyzed more reliably. The old GHC arity analysis combined with his Call Arity get almost everything right, but there are occasional corner cases where things go wrong, and when they do the results tend to be extremely bad.
Joachim's work looks like neat stuff. I've only been scanning those emails, but I recall mention of interface files. Jan, would your question #2 be addressed by that information being imported from interface files? With separate compilation, phase ordering because more nuanced.
_______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://www.haskell.org/mailman/listinfo/ghc-devs

Thanks guys. I've read the wiki page about demand analysis and things start to make a bit more sense now.
If you're looking at super-recent code, that could be Joachim Breitner's work. He's exposed the one-shot stuff at the Haskell level with the experimental magic oneShot function I'm looking at recent HEAD. But I'm not sure if we're thinking about the same thing. If you mean Joachim's work on call arity then I believe this is only realted to callArityInfo field of IdInfo. I'm interested in the oneShotInfo field of IdInfo.
I recall mention of interface files. Jan, would your question #2 be addressed by that information being imported from interface files? No, I don't think that's the answer. I mean I imagine that when we import things from interface files we get this information. But I'm interested in how this information is generated when we compile things in the current module.
One more question about reading the demand analysis results:
Str=DmdType
Here the argument is demanded once. But what if I have:
Str=DmdType
Does the lack of `1*` imply that the argument is used many times?
Janek

Hi, Am Freitag, den 31.10.2014, 10:48 +0200 schrieb Jan Stolarek:
One more question about reading the demand analysis results:
Str=DmdType
Here the argument is demanded once. But what if I have:
Str=DmdType
Does the lack of `1*` imply that the argument is used many times?
no; these things tend to be always an approximation in one direction. So you either know that it is used at most once, or both is possible. Nothing goes wrong when treating something that is used once as if it is used multiple times. What would be the value of knowing that it is definitely used multiple times? Greetings, Joachim -- Joachim “nomeata” Breitner mail@joachim-breitner.de • http://www.joachim-breitner.de/ Jabber: nomeata@joachim-breitner.de • GPG-Key: 0xF0FBF51F Debian Developer: nomeata@debian.org

What would be the value of knowing that it is definitely used multiple times? I'm working on core-to-core optimisation that improves code when something is used multiple times. I fear that in practice it might not be beneficial to transform thing that are used just once.
Janek

| One more question about reading the demand analysis results:
|
| Str=DmdType
|
| Here the argument is demanded once. But what if I have:
|
| Str=DmdType
|
| Does the lack of `1*` imply that the argument is used many times?
Well, *may* be used many times.
S
participants (5)
-
David Feuer
-
Jan Stolarek
-
Joachim Breitner
-
Nicolas Frisby
-
Simon Peyton Jones