Re: [commit: ghc] master: Fix popcnt calls (2293238)

Simon Marlow <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.ghc
Message-ID <[email protected]>
On 01/11/12 17:29, Ian Lynagh wrote:
> Repository : ssh://darcs.haskell.org//srv/darcs/ghc
>
> On branch  : master
>
> http://hackage.haskell.org/trac/ghc/changeset/229323898b0809047b19b79c181085430cce9850
>
>> ---------------------------------------------------------------
>
> commit 229323898b0809047b19b79c181085430cce9850
> Author: Ian Lynagh <[email protected]>
> Date:   Thu Nov 1 14:13:05 2012 +0000
>
>      Fix popcnt calls
>
>      We don't want to narrow the argument size before making the foreign
>      call: Word8 still gets passed as a Word-sized argument

I'm not sure this is right (I added the narrowing, FWIW).  The fact that 
Word8 gets promoted to Word is part of the C ABI, and we don't want to 
do that when popcnt is being implemented directly by the native codegen. 
  I know it is currently broken on some platforms, but I think the fix 
is to implement the proper type promotion in the compilation of C calls.

Cheers,
	Simon



>> ---------------------------------------------------------------
>
>   compiler/codeGen/StgCmmPrim.hs |   15 +++++----------
>   1 files changed, 5 insertions(+), 10 deletions(-)
>
> diff --git a/compiler/codeGen/StgCmmPrim.hs b/compiler/codeGen/StgCmmPrim.hs
> index 650a12e..fe2a021 100644
> --- a/compiler/codeGen/StgCmmPrim.hs
> +++ b/compiler/codeGen/StgCmmPrim.hs
> @@ -485,16 +485,11 @@ emitPrimOp _      [] SetByteArrayOp [ba,off,len,c] =
>       doSetByteArrayOp ba off len c
>
>   -- Population count
> -emitPrimOp dflags [res] PopCnt8Op [w] =
> -  emitPopCntCall res (CmmMachOp (mo_WordTo8 dflags) [w]) W8
> -emitPrimOp dflags [res] PopCnt16Op [w] =
> -  emitPopCntCall res (CmmMachOp (mo_WordTo16 dflags) [w]) W16
> -emitPrimOp dflags [res] PopCnt32Op [w] =
> -  emitPopCntCall res (CmmMachOp (mo_WordTo32 dflags) [w]) W32
> -emitPrimOp _      [res] PopCnt64Op [w] =
> -  emitPopCntCall res w W64 -- arg always has type W64, no need to narrow
> -emitPrimOp dflags [res] PopCntOp [w] =
> -  emitPopCntCall res w (wordWidth dflags)
> +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 dflags [res] PopCntOp   [w] = emitPopCntCall res w (wordWidth dflags)
>
>   -- The rest just translate straightforwardly
>   emitPrimOp dflags [res] op [arg]
>
>
>
> _______________________________________________
> Cvs-ghc mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/cvs-ghc
>
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.