diff options
author | Sebastian Graf <sebastian.graf@kit.edu> | 2022-02-18 10:57:14 +0100 |
---|---|---|
committer | Sebastian Graf <sebastian.graf@kit.edu> | 2022-04-11 12:32:27 +0200 |
commit | 068e3b84dba0bfec51e52a3a6997decfb888fe6d (patch) | |
tree | ec60c5529808eaef31cd68f340108eee9692e55b /compiler/GHC/Core/Opt/Simplify.hs | |
parent | 20eca489df8c3dae80a584dede8fea40728bde3b (diff) | |
download | haskell-wip/T21261.tar.gz |
Eta reduction based on evaluation context (#21261)wip/T21261
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/Opt/Simplify.hs')
-rw-r--r-- | compiler/GHC/Core/Opt/Simplify.hs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/compiler/GHC/Core/Opt/Simplify.hs b/compiler/GHC/Core/Opt/Simplify.hs index cc7529179b..c5fd3dfef1 100644 --- a/compiler/GHC/Core/Opt/Simplify.hs +++ b/compiler/GHC/Core/Opt/Simplify.hs @@ -352,7 +352,7 @@ simplLazyBind env top_lvl is_rec bndr bndr1 rhs rhs_se -- See Note [Floating and type abstraction] in GHC.Core.Opt.Simplify.Utils -- Simplify the RHS - ; let rhs_cont = mkRhsStop (substTy body_env (exprType body)) + ; let rhs_cont = mkRhsStop (substTy body_env (exprType body)) (idDemandInfo bndr) ; (body_floats0, body0) <- {-#SCC "simplExprF" #-} simplExprF body_env body rhs_cont -- ANF-ise a constructor or PAP rhs @@ -2205,7 +2205,7 @@ rebuildCall env fun_info -- have to be very careful about bogus strictness through -- floating a demanded let. = do { arg' <- simplExprC (arg_se `setInScopeFromE` env) arg - (mkLazyArgStop arg_ty (lazyArgContext fun_info)) + (mkLazyArgStop arg_ty fun_info) ; rebuildCall env (addValArgTo fun_info arg' fun_ty) cont } where arg_ty = funArgTy fun_ty @@ -2671,7 +2671,7 @@ There have been various earlier versions of this patch: case_bndr_evald_next _ = False This patch was part of fixing #7542. See also - Note [Eta reduction of an eval'd function] in GHC.Core.Utils.) + Note [Eta reduction soundness], criterion (E) in GHC.Core.Utils.) Further notes about case elimination @@ -4281,5 +4281,3 @@ for the RHS as well as the LHS, but that seems more conservative than necesary. Allowing some inlining might, for example, eliminate a binding. -} - - |