diff options
author | klebinger.andreas@gmx.at <klebinger.andreas@gmx.at> | 2018-08-21 12:10:38 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-08-21 18:52:42 -0400 |
commit | 09c1d5afba655a2427a448a9933bebe7d13b696b (patch) | |
tree | d23083a9e99afe785f632e89f0186af8b191aee2 /compiler/simplCore/Simplify.hs | |
parent | 02518f9d99c2d038384263f9e039efcb09bc96ff (diff) | |
download | haskell-09c1d5afba655a2427a448a9933bebe7d13b696b.tar.gz |
Replace most occurences of foldl with foldl'.
This patch adds foldl' to GhcPrelude and changes must occurences
of foldl to foldl'. This leads to better performance especially
for quick builds where GHC does not perform strictness analysis.
It does change strictness behaviour when we use foldl' to turn
a argument list into function applications. But this is only a
drawback if code looks ONLY at the last argument but not at the first.
And as the benchmarks show leads to fewer allocations in practice
at O2.
Compiler performance for Nofib:
O2 Allocations:
-1 s.d. ----- -0.0%
+1 s.d. ----- -0.0%
Average ----- -0.0%
O2 Compile Time:
-1 s.d. ----- -2.8%
+1 s.d. ----- +1.3%
Average ----- -0.8%
O0 Allocations:
-1 s.d. ----- -0.2%
+1 s.d. ----- -0.1%
Average ----- -0.2%
Test Plan: ci
Reviewers: goldfire, bgamari, simonmar, tdammers, monoidal
Reviewed By: bgamari, monoidal
Subscribers: tdammers, rwbarton, thomie, carter
Differential Revision: https://phabricator.haskell.org/D4929
Diffstat (limited to 'compiler/simplCore/Simplify.hs')
-rw-r--r-- | compiler/simplCore/Simplify.hs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/simplCore/Simplify.hs b/compiler/simplCore/Simplify.hs index c60d850cd0..c8870c98a1 100644 --- a/compiler/simplCore/Simplify.hs +++ b/compiler/simplCore/Simplify.hs @@ -295,7 +295,7 @@ simplLazyBind env top_lvl is_rec bndr bndr1 rhs rhs_se do { tick LetFloatFromLet ; (poly_binds, body3) <- abstractFloats (seDynFlags env) top_lvl tvs' body_floats2 body2 - ; let floats = foldl extendFloats (emptyFloats env) poly_binds + ; let floats = foldl' extendFloats (emptyFloats env) poly_binds ; rhs' <- mkLam env tvs' body3 rhs_cont ; return (floats, rhs') } @@ -2978,7 +2978,7 @@ mkDupableCont env (StrictArg { sc_fun = info, sc_cci = cci, sc_cont = cont }) = do { (floats1, cont') <- mkDupableCont env cont ; (floats_s, args') <- mapAndUnzipM (makeTrivialArg (getMode env)) (ai_args info) - ; return ( foldl addLetFloats floats1 floats_s + ; return ( foldl' addLetFloats floats1 floats_s , StrictArg { sc_fun = info { ai_args = args' } , sc_cci = cci , sc_cont = cont' |