diff options
author | Joachim Breitner <mail@joachim-breitner.de> | 2015-02-22 10:36:15 +0100 |
---|---|---|
committer | Joachim Breitner <mail@joachim-breitner.de> | 2015-02-22 12:42:29 +0100 |
commit | c76f59b6d6cdea0b1ae8449e13777f9b9bfae80e (patch) | |
tree | 0ae409d229817843027c869aa036f9ea1820e8ae /compiler/stranal | |
parent | e7420c731d0c307fcaf61c1a2ffd4daa64a8e7b1 (diff) | |
download | haskell-wip/T9388.tar.gz |
Introduce the new state hack in the demand analyzerwip/T9388
The new state hack, as proposed by SPJ in #9388, applies only to bound
expressions. It is implemented by constructing an artificial incoming demand that claims that it is called at most once.
(Currently, it also applies to non-top-level let-bound expressions. This
needs to be revisited.)
Diffstat (limited to 'compiler/stranal')
-rw-r--r-- | compiler/stranal/DmdAnal.hs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/compiler/stranal/DmdAnal.hs b/compiler/stranal/DmdAnal.hs index 27fa35fba0..d6155622dd 100644 --- a/compiler/stranal/DmdAnal.hs +++ b/compiler/stranal/DmdAnal.hs @@ -619,9 +619,14 @@ dmdAnalRhs top_lvl rec_flag env id rhs -- See Note [NOINLINE and strictness] -- See Note [Product demands for function body] - body_dmd = case deepSplitProductType_maybe (ae_fam_envs env) (exprType body) of - Nothing -> cleanEvalDmd - Just (dc, _, _, _) -> cleanEvalProdDmd (dataConRepArity dc) + body_dmd + | Just (dc, _, _, _) <- deepSplitProductType_maybe (ae_fam_envs env) (exprType body) + = cleanEvalProdDmd (dataConRepArity dc) + | isStateHackFunType $ topNormaliseType (ae_fam_envs env) (exprType body) + = -- pprTrace "new state hack" (ppr (exprType body)) $ + cleanEvalStateHackDmd + | otherwise + = cleanEvalDmd -- See Note [Lazy and unleashable free variables] -- See Note [Aggregated demand for cardinality] |