diff options
author | Michal Terepeta <michal.terepeta@gmail.com> | 2018-03-26 15:18:44 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-03-27 09:53:10 -0400 |
commit | d5c4d46a62ce6a0cfa6440344f707136eff18119 (patch) | |
tree | 539f6eaf8fa90d791ab8315b6f40c8687f56e92b /compiler/cmm/CmmCommonBlockElim.hs | |
parent | 8cfd2e4e5832bd188816e64daaa95c9003437723 (diff) | |
download | haskell-d5c4d46a62ce6a0cfa6440344f707136eff18119.tar.gz |
CmmPipeline: add a second pass of CmmCommonBlockElim
The sinking pass often gets rid of unnecessary registers
registers/assignements exposing more opportunities for CBE, so this
commit adds a second round of CBE after the sinking pass and should
fix #12915 (and some examples in #14226).
Nofib results:
* Binary size: 0.9% reduction on average
* Compile allocations: 0.7% increase on average
* Runtime: noisy, two separate runs of nofib showed a tiny
reduction on average, (~0.2-0.3%), but I think
this is mostly noise
* Compile time: very noisy, but generally within +/- 0.5% (one
run faster, one slower)
One interesting part of this change is that running CBE invalidates
results of proc-point analysis. But instead of re-doing the whole
analysis, we can use the map that CBE creates for replacing/comparing
block labels (maps a redundant label to a useful one) to update the
results of proc-point analysis. This lowers the overhead compared to the
previous experiment in #12915.
Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
Test Plan: ./validate
Reviewers: bgamari, simonmar
Reviewed By: simonmar
Subscribers: rwbarton, thomie, carter
GHC Trac Issues: #12915, #14226
Differential Revision: https://phabricator.haskell.org/D4417
Diffstat (limited to 'compiler/cmm/CmmCommonBlockElim.hs')
-rw-r--r-- | compiler/cmm/CmmCommonBlockElim.hs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/cmm/CmmCommonBlockElim.hs b/compiler/cmm/CmmCommonBlockElim.hs index c91d553c47..ad10511c1d 100644 --- a/compiler/cmm/CmmCommonBlockElim.hs +++ b/compiler/cmm/CmmCommonBlockElim.hs @@ -59,9 +59,10 @@ import Data.List (foldl') -- hashes, and at most once otherwise. Previously, we were slower, and people -- rightfully complained: #10397 --- TODO: Use optimization fuel -elimCommonBlocks :: CmmGraph -> CmmGraph -elimCommonBlocks g = replaceLabels env $ copyTicks env g +type Subst = LabelMap BlockId + +elimCommonBlocks :: CmmGraph -> (CmmGraph, Subst) +elimCommonBlocks g = (replaceLabels env $ copyTicks env g, env) where env = iterate mapEmpty blocks_with_key -- The order of blocks doesn't matter here, but revPostorder also drops any @@ -73,7 +74,6 @@ elimCommonBlocks g = replaceLabels env $ copyTicks env g -- (so avoid comparing them again) type DistinctBlocks = [CmmBlock] type Key = [Label] -type Subst = LabelMap BlockId -- The outer list groups by hash. We retain this grouping throughout. iterate :: Subst -> [[(Key, DistinctBlocks)]] -> Subst |