
#11731: Demand analysis: Thunk wrongly determined single-entry
-------------------------------------+-------------------------------------
Reporter: nomeata | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by nomeata):
It seems that on its own, the demand analysis is correct. Here is the
relevant bit from `transPort`, as the demand analysis sees it:
{{{
transPort =
\ (p_ayV
[Dmd=]
:: Particle)
(prob_ayW [Dmd=]
:: Probability) ->
let {
seed_s33f [Dmd=},
Unf=Unf{Src=<vanilla>, TopLvl=False, Value=False, ConLike=False,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 0}]
seed_s33f =
case p_ayV
of _ [Occ=Dead, Dmd=] ->
seed_X22n
} } in
case Utils.$wgenRand seed_s33f
...
}}}
Note that the demand on `seed` is *not* one-shot (because there are two
calls to `wgenRand seed_s33f` in the body below, but the demand on the
corresponding member of `Particle` is. As long as `seed_s33f` is shared,
this is fine.
But after the next simplifier run, which includes worker-wrappering the
`Particle` argument, CSE’ing the various calls to `$wgenRand` as well as
subsequent simplifications, we get:
{{{
[LclId,
Arity=14,
Str=DmdType
,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=NEVER}]
$wtransPort_s3nF =
\ (ww_s3nb :: Coord)
(ww_s3nc :: Coord)
(ww_s3nd :: Coord)
(ww_s3ni :: Coord)
(ww_s3nj :: Coord)
(ww_s3nk :: Coord)
(ww_s3nm :: Weight)
(ww_s3nn :: Energy)
(ww_s3no :: Indx)
(ww_s3np :: Int)
(ww_s3nq :: Random)
(ww_s3nu :: Prob)
(ww_s3nw :: Prob)
(ww_s3nA :: GHC.Prim.Double#) ->
case Utils.$wgenRand ww_s3nq
of _ [Occ=Dead, Dmd=], ww2_a2WS [Dmd=] :: GHC.Prim.Double#) ->
...
let {
w_s3n4
[Dmd=]
:: Particle
[LclId, Str=DmdType]
w_s3n4 =
GamtebType.Part
ww_s3n8 ww_s3nf ww_s3nm ww_s3nn ww_s3no ww_s3np ww_s3nq } in
...
case (\ (p_ayV
[Dmd=]
:: Particle)
(prob_ayW [Dmd=]
:: Probability) ->
let {
seed_s33f [Dmd=] ->
seed_X22n
} } in
case Utils.$wgenRand seed_s33f
...
w_s3n4 w_s3n5
}}}
and then (beta-reduction)
{{{
let {
seed_s33f [Dmd=] ->
seed_X22n
} } in
case Utils.$wgenRand seed_s33f
}}}
and then (inlining of constructor application into interesting context,
and case of known constructor)
{{{
let {
seed_s33f [Dmd=