[commit: ghc] master: Implement new CLZ and CTZ primops (re #9340) (e0c1767)

git at git.haskell.org git at git.haskell.org
Thu Aug 14 10:29:44 UTC 2014


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

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

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

commit e0c1767d0ea8d12e0a4badf43682a08784e379c6
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Mon Aug 11 18:56:57 2014 +0200

    Implement new CLZ and CTZ primops (re #9340)
    
    This implements the new primops
    
      clz#, clz32#, clz64#,
      ctz#, ctz32#, ctz64#
    
    which provide efficient implementations of the popular
    count-leading-zero and count-trailing-zero respectively
    (see testcase for a pure Haskell reference implementation).
    
    On x86, NCG as well as LLVM generates code based on the BSF/BSR
    instructions (which need extra logic to make the 0-case well-defined).
    
    Test Plan: validate and succesful tests on i686 and amd64
    
    Reviewers: rwbarton, simonmar, ezyang, austin
    
    Subscribers: simonmar, relrod, ezyang, carter
    
    Differential Revision: https://phabricator.haskell.org/D144
    
    GHC Trac Issues: #9340


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

e0c1767d0ea8d12e0a4badf43682a08784e379c6
 compiler/cmm/CmmMachOp.hs                       |  3 +
 compiler/cmm/PprC.hs                            |  2 +
 compiler/codeGen/StgCmmPrim.hs                  | 28 ++++++++
 compiler/llvmGen/LlvmCodeGen/CodeGen.hs         |  9 ++-
 compiler/nativeGen/CPrim.hs                     | 20 ++++++
 compiler/nativeGen/PPC/CodeGen.hs               |  2 +
 compiler/nativeGen/SPARC/CodeGen.hs             |  2 +
 compiler/nativeGen/X86/CodeGen.hs               | 65 +++++++++++++++++
 compiler/prelude/primops.txt.pp                 | 22 ++++++
 includes/stg/Prim.h                             | 12 ++++
 libraries/ghc-prim/cbits/clz.c                  | 41 +++++++++++
 libraries/ghc-prim/cbits/ctz.c                  | 41 +++++++++++
 libraries/ghc-prim/ghc-prim.cabal               |  2 +
 testsuite/.gitignore                            |  1 +
 testsuite/tests/codeGen/should_run/T9340.hs     | 96 +++++++++++++++++++++++++
 testsuite/tests/codeGen/should_run/T9340.stdout |  1 +
 testsuite/tests/codeGen/should_run/all.T        |  1 +
 17 files changed, 347 insertions(+), 1 deletion(-)

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 e0c1767d0ea8d12e0a4badf43682a08784e379c6


More information about the ghc-commits mailing list