diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2015-07-03 14:03:25 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2015-07-06 15:07:38 +0100 |
commit | eb6657550f163fd1b5ae11a0a38980560308b7e3 (patch) | |
tree | 913ddab036a2b09e08de82f23a48a04880ca161d /compiler/simplCore/Simplify.hs | |
parent | df6665e0cfdd23567bd32d222154ab25dbc39079 (diff) | |
download | haskell-wip/T10527.tar.gz |
Use lazy substitution in simplCastwip/T10527
It turned out that the terrible compiler performance in
Trac #10527 arose because we were simplifying a function
argument that subseuqently was discarded, so the work was
wasted. Moreover, the work turned out to be substantial;
indeed it made an asymptotic difference to compile time.
Ths solution in this 7.10 branch is a bit brutal; just
duplicate CoreSubst.substExpr to be SimplEnv.substExprS.
It works fine I'm working on a better solution for HEAD.
Diffstat (limited to 'compiler/simplCore/Simplify.hs')
-rw-r--r-- | compiler/simplCore/Simplify.hs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler/simplCore/Simplify.hs b/compiler/simplCore/Simplify.hs index efefa23758..2e1dcefbdb 100644 --- a/compiler/simplCore/Simplify.hs +++ b/compiler/simplCore/Simplify.hs @@ -1179,11 +1179,15 @@ simplCast env body co0 cont0 -- But it isn't a common case. -- -- Example of use: Trac #995 - = do { (dup', arg_se', arg') <- simplArg env dup arg_se arg - ; cont' <- addCoerce co2 cont + = do { let arg' = substExprS arg_se arg + -- It's important that this is lazy, because this argument + -- may be disarded if turns out to be the argument of + -- (\_ -> e) This can make a huge difference; + -- see Trac #10527 + ; cont' <- addCoerce co2 cont ; return (ApplyToVal { sc_arg = mkCast arg' (mkSymCo co1) - , sc_env = arg_se' - , sc_dup = dup' + , sc_env = zapSubstEnv arg_se + , sc_dup = dup , sc_cont = cont' }) } where -- we split coercion t1->t2 ~ s1->s2 into t1 ~ s1 and |