diff options
| author | klebinger.andreas@gmx.at <klebinger.andreas@gmx.at> | 2019-02-18 00:28:39 +0100 |
|---|---|---|
| committer | Ben Gamari <ben@smart-cactus.org> | 2019-10-13 15:07:06 -0400 |
| commit | 9a90f27f080123c636a3401b103ea68aa843e34d (patch) | |
| tree | 581dabf4a1720457bce175902d8e9b5f6f1a0d93 /compiler/nativeGen/AsmCodeGen.hs | |
| parent | d584e3f08cfee6e28b70bf53c573d86e44f326f8 (diff) | |
| download | haskell-wip/gc/base.tar.gz | |
Add loop level analysis to the NCG backend.wip/gc/base
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.
(cherry picked from commit 056aa12d60f34ee90db2527586c82fc6f16eba39)
Diffstat (limited to 'compiler/nativeGen/AsmCodeGen.hs')
| -rw-r--r-- | compiler/nativeGen/AsmCodeGen.hs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/compiler/nativeGen/AsmCodeGen.hs b/compiler/nativeGen/AsmCodeGen.hs index e033a4c218..68a094a9b9 100644 --- a/compiler/nativeGen/AsmCodeGen.hs +++ b/compiler/nativeGen/AsmCodeGen.hs @@ -563,7 +563,7 @@ cmmNativeGen dflags this_mod modLoc ncgImpl us fileIds dbgMap cmm count Opt_D_dump_asm_native "Native code" (vcat $ map (pprNatCmmDecl ncgImpl) native) - dumpIfSet_dyn dflags + when (not $ null nativeCfgWeights) $ dumpIfSet_dyn dflags Opt_D_dump_cfg_weights "CFG Weights" (pprEdgeWeights nativeCfgWeights) @@ -691,7 +691,7 @@ cmmNativeGen dflags this_mod modLoc ncgImpl us fileIds dbgMap cmm count {-# SCC "generateJumpTables" #-} generateJumpTables ncgImpl alloced - dumpIfSet_dyn dflags + when (not $ null nativeCfgWeights) $ dumpIfSet_dyn dflags Opt_D_dump_cfg_weights "CFG Update information" ( text "stack:" <+> ppr stack_updt_blks $$ text "linearAlloc:" <+> ppr cfgRegAllocUpdates ) @@ -704,7 +704,7 @@ cmmNativeGen dflags this_mod modLoc ncgImpl us fileIds dbgMap cmm count let optimizedCFG = optimizeCFG (cfgWeightInfo dflags) cmm postShortCFG - dumpIfSet_dyn dflags + when (not $ null nativeCfgWeights) $ dumpIfSet_dyn dflags Opt_D_dump_cfg_weights "CFG Final Weights" ( pprEdgeWeights optimizedCFG ) |
