[commit: ghc] master: NCG: New code layout algorithm. (912fd2b)

git at git.haskell.org git at git.haskell.org
Sat Nov 17 10:28:26 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/912fd2b6ca0bc51076835b6e3d1f469b715e2760/ghc

>---------------------------------------------------------------

commit 912fd2b6ca0bc51076835b6e3d1f469b715e2760
Author: Andreas Klebinger <klebinger.andreas at gmx.at>
Date:   Sat Nov 17 11:20:36 2018 +0100

    NCG: New code layout algorithm.
    
    Summary:
    This patch implements a new code layout algorithm.
    It has been tested for x86 and is disabled on other platforms.
    
    Performance varies slightly be CPU/Machine but in general seems to be better
    by around 2%.
    Nofib shows only small differences of about +/- ~0.5% overall depending on
    flags/machine performance in other benchmarks improved significantly.
    
    Other benchmarks includes at least the benchmarks of: aeson, vector, megaparsec, attoparsec,
    containers, text and xeno.
    
    While the magnitude of gains differed three different CPUs where tested with
    all getting faster although to differing degrees. I tested: Sandy Bridge(Xeon), Haswell,
    Skylake
    
    * Library benchmark results summarized:
      * containers: ~1.5% faster
      * aeson: ~2% faster
      * megaparsec: ~2-5% faster
      * xml library benchmarks: 0.2%-1.1% faster
      * vector-benchmarks: 1-4% faster
      * text: 5.5% faster
    
    On average GHC compile times go down, as GHC compiled with the new layout
    is faster than the overhead introduced by using the new layout algorithm,
    
    Things this patch does:
    
    * Move code responsilbe for block layout in it's own module.
    * Move the NcgImpl Class into the NCGMonad module.
    * Extract a control flow graph from the input cmm.
    * Update this cfg to keep it in sync with changes during
      asm codegen. This has been tested on x64 but should work on x86.
      Other platforms still use the old codelayout.
    * Assign weights to the edges in the CFG based on type and limited static
      analysis which are then used for block layout.
    * Once we have the final code layout eliminate some redundant jumps.
    
      In particular turn a sequences of:
          jne .foo
          jmp .bar
        foo:
      into
          je bar
        foo:
          ..
    
    Test Plan: ci
    
    Reviewers: bgamari, jmct, jrtc27, simonmar, simonpj, RyanGlScott
    
    Reviewed By: RyanGlScott
    
    Subscribers: RyanGlScott, trommler, jmct, carter, thomie, rwbarton
    
    GHC Trac Issues: #15124
    
    Differential Revision: https://phabricator.haskell.org/D4726


>---------------------------------------------------------------

912fd2b6ca0bc51076835b6e3d1f469b715e2760
 compiler/cmm/CmmMachOp.hs                          |  13 +-
 compiler/cmm/CmmNode.hs                            |  23 +-
 compiler/cmm/CmmPipeline.hs                        |   1 -
 compiler/cmm/Hoopl/Collections.hs                  |  11 +-
 compiler/cmm/Hoopl/Label.hs                        |   7 +-
 compiler/ghc.cabal.in                              |   2 +
 compiler/main/DynFlags.hs                          | 105 ++-
 compiler/nativeGen/AsmCodeGen.hs                   | 334 ++++-----
 compiler/nativeGen/BlockLayout.hs                  | 819 +++++++++++++++++++++
 compiler/nativeGen/CFG.hs                          | 635 ++++++++++++++++
 compiler/nativeGen/NCGMonad.hs                     |  89 ++-
 compiler/nativeGen/PPC/CodeGen.hs                  |   4 +-
 compiler/nativeGen/PPC/Instr.hs                    |  10 +-
 compiler/nativeGen/PPC/RegInfo.hs                  |   5 +
 compiler/nativeGen/RegAlloc/Linear/Base.hs         |  11 +-
 .../nativeGen/RegAlloc/Linear/JoinToTargets.hs     |  47 +-
 compiler/nativeGen/RegAlloc/Linear/Main.hs         |   8 +-
 compiler/nativeGen/RegAlloc/Linear/State.hs        |  14 +-
 compiler/nativeGen/RegAlloc/Liveness.hs            |  44 +-
 compiler/nativeGen/SPARC/CodeGen.hs                |   2 +-
 compiler/nativeGen/SPARC/ShortcutJump.hs           |   7 +-
 compiler/nativeGen/X86/CodeGen.hs                  | 251 ++++---
 compiler/nativeGen/X86/Cond.hs                     |  41 +-
 compiler/nativeGen/X86/Instr.hs                    |  18 +-
 compiler/nativeGen/X86/Regs.hs                     |   1 -
 compiler/utils/Digraph.hs                          |  94 +++
 compiler/utils/OrdList.hs                          |  10 +-
 compiler/utils/Util.hs                             |  22 +-
 docs/users_guide/8.8.1-notes.rst                   |   4 +
 docs/users_guide/debugging.rst                     |   6 +
 docs/users_guide/using-optimisation.rst            |  52 ++
 .../{annotations => cmm}/should_compile/Makefile   |   0
 testsuite/tests/cmm/should_compile/all.T           |   2 +
 testsuite/tests/cmm/should_compile/selfloop.cmm    |  11 +
 34 files changed, 2370 insertions(+), 333 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 912fd2b6ca0bc51076835b6e3d1f469b715e2760


More information about the ghc-commits mailing list