[commit: ghc] master: Narrow the args of the popCnt# primitives (new codegen) (e641139)

Simon Marlow <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.ghc
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/e6411395563c3d425bc78a78b189b33eb3d3cc07

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

commit e6411395563c3d425bc78a78b189b33eb3d3cc07
Author: Simon Marlow <[email protected]>
Date:   Mon Sep 3 12:28:35 2012 +0100

    Narrow the args of the popCnt# primitives (new codegen)
    
    (this change was previously done in the old codegen only)

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

 compiler/codeGen/StgCmmPrim.hs |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/compiler/codeGen/StgCmmPrim.hs b/compiler/codeGen/StgCmmPrim.hs
index 3a7a456..6c6005e 100644
--- a/compiler/codeGen/StgCmmPrim.hs
+++ b/compiler/codeGen/StgCmmPrim.hs
@@ -498,11 +498,16 @@ emitPrimOp [] SetByteArrayOp [ba,off,len,c] =
     doSetByteArrayOp ba off len c
 
 -- Population count
-emitPrimOp [res] PopCnt8Op [w] = emitPopCntCall res w W8
-emitPrimOp [res] PopCnt16Op [w] = emitPopCntCall res w W16
-emitPrimOp [res] PopCnt32Op [w] = emitPopCntCall res w W32
-emitPrimOp [res] PopCnt64Op [w] = emitPopCntCall res w W64
-emitPrimOp [res] PopCntOp [w] = emitPopCntCall res w wordWidth
+emitPrimOp [res] PopCnt8Op [w] =
+  emitPopCntCall res (CmmMachOp mo_WordTo8 [w]) W8
+emitPrimOp [res] PopCnt16Op [w] =
+  emitPopCntCall res (CmmMachOp mo_WordTo16 [w]) W16
+emitPrimOp [res] PopCnt32Op [w] =
+  emitPopCntCall res (CmmMachOp mo_WordTo32 [w]) W32
+emitPrimOp [res] PopCnt64Op [w] =
+  emitPopCntCall res w W64 -- arg always has type W64, no need to narrow
+emitPrimOp [res] PopCntOp [w] =
+  emitPopCntCall res w wordWidth
 
 -- The rest just translate straightforwardly
 emitPrimOp [res] op [arg]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.