diff options
author | klebinger.andreas@gmx.at <klebinger.andreas@gmx.at> | 2019-02-18 00:28:39 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-10-16 07:04:21 -0400 |
commit | 535a88e1f348112c44e27e0083a68f054b055619 (patch) | |
tree | 52738736723400052f440163d469148e223ed771 /compiler/cmm | |
parent | 9c11f8171a9aebec4b4d19e5eac4140f40c28542 (diff) | |
download | haskell-535a88e1f348112c44e27e0083a68f054b055619.tar.gz |
Add loop level analysis to the NCG backend.
For backends maintaining the CFG during codegen
we can now find loops and their nesting level.
This is based on the Cmm CFG and dominator analysis.
As a result we can estimate edge frequencies a lot better
for methods, resulting in far better code layout.
Speedup on nofib: ~1.5%
Increase in compile times: ~1.9%
To make this feasible this commit adds:
* Dominator analysis based on the Lengauer-Tarjan Algorithm.
* An algorithm estimating global edge frequences from branch
probabilities - In CFG.hs
A few static branch prediction heuristics:
* Expect to take the backedge in loops.
* Expect to take the branch NOT exiting a loop.
* Expect integer vs constant comparisons to be false.
We also treat heap/stack checks special for branch prediction
to avoid them being treated as loops.
Diffstat (limited to 'compiler/cmm')
-rw-r--r-- | compiler/cmm/Hoopl/Dataflow.hs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/compiler/cmm/Hoopl/Dataflow.hs b/compiler/cmm/Hoopl/Dataflow.hs index 2a2bb72dcc..9762a84e20 100644 --- a/compiler/cmm/Hoopl/Dataflow.hs +++ b/compiler/cmm/Hoopl/Dataflow.hs @@ -6,8 +6,6 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} -{-# OPTIONS_GHC -fprof-auto-top #-} - -- -- Copyright (c) 2010, João Dias, Simon Marlow, Simon Peyton Jones, -- and Norman Ramsey @@ -108,6 +106,7 @@ analyzeCmm -> FactBase f -> FactBase f analyzeCmm dir lattice transfer cmmGraph initFact = + {-# SCC analyzeCmm #-} let entry = g_entry cmmGraph hooplGraph = g_graph cmmGraph blockMap = @@ -169,7 +168,7 @@ rewriteCmm -> CmmGraph -> FactBase f -> UniqSM (CmmGraph, FactBase f) -rewriteCmm dir lattice rwFun cmmGraph initFact = do +rewriteCmm dir lattice rwFun cmmGraph initFact = {-# SCC rewriteCmm #-} do let entry = g_entry cmmGraph hooplGraph = g_graph cmmGraph blockMap1 = |