diff options
| author | Sebastian Graf <sebastian.graf@kit.edu> | 2022-02-18 10:57:14 +0100 |
|---|---|---|
| committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-04-12 11:11:42 -0400 |
| commit | 0090ad7b8b436961fe1e225aae214d0ea1381c07 (patch) | |
| tree | d56a67bbaa3c9cbd54de2f0d1f21f6d2b01d0e3b /compiler/GHC/Core/SimpleOpt.hs | |
| parent | 5440f63ec4a584b8805a8ff49ba1bd26bc2c032d (diff) | |
| download | haskell-0090ad7b8b436961fe1e225aae214d0ea1381c07.tar.gz | |
Eta reduction based on evaluation context (#21261)
I completely rewrote our Notes surrounding eta-reduction. The new entry point is
`Note [Eta reduction makes sense]`.
Then I went on to extend the Simplifier to maintain an evaluation context in the
form of a `SubDemand` inside a `SimplCont`. That `SubDemand` is useful for doing
eta reduction according to `Note [Eta reduction based on evaluation context]`,
which describes how Demand analysis, Simplifier and `tryEtaReduce` interact to
facilitate eta reduction in more scenarios.
Thus we fix #21261.
ghc/alloc perf marginally improves (-0.0%). A medium-sized win is when compiling
T3064 (-3%). It seems that haddock improves by 0.6% to 1.0%, too.
Metric Decrease:
T3064
Diffstat (limited to 'compiler/GHC/Core/SimpleOpt.hs')
| -rw-r--r-- | compiler/GHC/Core/SimpleOpt.hs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/compiler/GHC/Core/SimpleOpt.hs b/compiler/GHC/Core/SimpleOpt.hs index fa6fcda351..925eaf5841 100644 --- a/compiler/GHC/Core/SimpleOpt.hs +++ b/compiler/GHC/Core/SimpleOpt.hs @@ -36,7 +36,7 @@ import GHC.Types.Var ( isNonCoVarId ) import GHC.Types.Var.Set import GHC.Types.Var.Env import GHC.Core.DataCon -import GHC.Types.Demand( etaConvertDmdSig ) +import GHC.Types.Demand( etaConvertDmdSig, topSubDmd ) import GHC.Types.Tickish import GHC.Core.Coercion.Opt ( optCoercion, OptCoercionOpts (..) ) import GHC.Core.Type hiding ( substTy, extendTvSubst, extendCvSubst, extendTvSubstList @@ -295,8 +295,8 @@ simple_opt_expr env expr where (env', b') = subst_opt_bndr env b go_lam env bs' e - | Just etad_e <- tryEtaReduce bs e' = etad_e - | otherwise = mkLams bs e' + | Just etad_e <- tryEtaReduce bs e' topSubDmd = etad_e + | otherwise = mkLams bs e' where bs = reverse bs' e' = simple_opt_expr env e |
