diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2018-06-01 12:53:41 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2018-06-04 10:35:34 +0100 |
commit | 0e5d2b7442ff9e55837913a53da451fb97417496 (patch) | |
tree | d3ce69a61c838bff299661e857520af6f57106ac | |
parent | 554bc7fcca30b1b6ffb6a2daca684ea74eb83ad8 (diff) | |
download | haskell-0e5d2b7442ff9e55837913a53da451fb97417496.tar.gz |
Do a late CSE pass
When investigating something else I found that a condition
was being re-evaluated in wheel-seive1. Why, when CSE should
find it? Because the opportunity only showed up after
LiberateCase
This patch adds a late CSE pass. Rather than give it an extra
flag I do it when (cse && (spec_constr || liberate_case)), so
roughly speaking it happense with -O2.
In any case, CSE is very cheap.
Nofib results are minor but in the right direction:
Program Size Allocs Runtime Elapsed TotalMem
--------------------------------------------------------------------------------
anna -0.1% -0.0% 0.163 0.163 0.0%
eliza -0.1% -0.4% 0.001 0.001 0.0%
fft2 -0.1% 0.0% 0.087 0.087 0.0%
mate -0.0% -1.3% -0.8% -0.8% 0.0%
paraffins -0.0% -0.1% +0.9% +0.9% 0.0%
pic -0.0% -0.1% 0.009 0.009 0.0%
wheel-sieve1 -0.2% -0.0% -0.1% -0.1% 0.0%
--------------------------------------------------------------------------------
Min -0.6% -1.3% -2.4% -2.4% 0.0%
Max +0.0% +0.0% +3.8% +3.8% +23.8%
Geometric Mean -0.0% -0.0% +0.2% +0.2% +0.2%
-rw-r--r-- | compiler/simplCore/SimplCore.hs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/simplCore/SimplCore.hs b/compiler/simplCore/SimplCore.hs index 888463622a..d461b99c43 100644 --- a/compiler/simplCore/SimplCore.hs +++ b/compiler/simplCore/SimplCore.hs @@ -321,6 +321,12 @@ getCoreToDo dflags (CoreDoPasses [ CoreDoSpecialising , simpl_phase 0 ["post-late-spec"] max_iter]), + -- LiberateCase can yield new CSE opportunities because it peels + -- off one layer of a recursive function (concretely, I saw this + -- in wheel-sieve1), and I'm guessing that SpecConstr can too + -- And CSE is a very cheap pass. So it seems worth doing here. + runWhen ((liberate_case || spec_constr) && cse) CoreCSE, + -- Final clean-up simplification: simpl_phase 0 ["final"] max_iter, |