Repository : ssh://darcs.haskell.org//srv/darcs/ghc On branch : master
http://hackage.haskell.org/trac/ghc/changeset/fad7453b64fd1783e688efaa534ffdc2fe6f1324 >--------------------------------------------------------------- commit fad7453b64fd1783e688efaa534ffdc2fe6f1324 Author: Simon Marlow <[email protected]> Date: Wed Aug 29 14:50:14 2012 +0100 Narrow the arg of popCnt# to the correct width Fixes cgrun071 on recent Mac OS X versions. This is the right fix at least until we have proper types for Word8#, Word16# etc. >--------------------------------------------------------------- compiler/cmm/CmmMachOp.hs | 5 +++-- compiler/codeGen/CgPrimOp.hs | 21 +++++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/compiler/cmm/CmmMachOp.hs b/compiler/cmm/CmmMachOp.hs index f42626f..d53f485 100644 --- a/compiler/cmm/CmmMachOp.hs +++ b/compiler/cmm/CmmMachOp.hs @@ -13,7 +13,7 @@ module CmmMachOp , mo_wordAnd, mo_wordOr, mo_wordXor, mo_wordNot, mo_wordShl, mo_wordSShr, mo_wordUShr , mo_u_8To32, mo_s_8To32, mo_u_16To32, mo_s_16To32 , mo_u_8ToWord, mo_s_8ToWord, mo_u_16ToWord, mo_s_16ToWord, mo_u_32ToWord, mo_s_32ToWord - , mo_32To8, mo_32To16, mo_WordTo8, mo_WordTo16, mo_WordTo32 + , mo_32To8, mo_32To16, mo_WordTo8, mo_WordTo16, mo_WordTo32, mo_WordTo64 -- CallishMachOp , CallishMachOp(..) @@ -124,7 +124,7 @@ mo_wordAdd, mo_wordSub, mo_wordEq, mo_wordNe,mo_wordMul, mo_wordSQuot , mo_wordAnd, mo_wordOr, mo_wordXor, mo_wordNot, mo_wordShl, mo_wordSShr, mo_wordUShr , mo_u_8To32, mo_s_8To32, mo_u_16To32, mo_s_16To32 , mo_u_8ToWord, mo_s_8ToWord, mo_u_16ToWord, mo_s_16ToWord, mo_u_32ToWord, mo_s_32ToWord - , mo_32To8, mo_32To16, mo_WordTo8, mo_WordTo16, mo_WordTo32 + , mo_32To8, mo_32To16, mo_WordTo8, mo_WordTo16, mo_WordTo32, mo_WordTo64 :: MachOp mo_wordAdd = MO_Add wordWidth @@ -171,6 +171,7 @@ mo_u_32ToWord = MO_UU_Conv W32 wordWidth mo_WordTo8 = MO_UU_Conv wordWidth W8 mo_WordTo16 = MO_UU_Conv wordWidth W16 mo_WordTo32 = MO_UU_Conv wordWidth W32 +mo_WordTo64 = MO_UU_Conv wordWidth W64 mo_32To8 = MO_UU_Conv W32 W8 mo_32To16 = MO_UU_Conv W32 W16 diff --git a/compiler/codeGen/CgPrimOp.hs b/compiler/codeGen/CgPrimOp.hs index 0c8fb1a..88d60b6 100644 --- a/compiler/codeGen/CgPrimOp.hs +++ b/compiler/codeGen/CgPrimOp.hs @@ -424,12 +424,21 @@ emitPrimOp [] CopyMutableByteArrayOp [src,src_off,dst,dst_off,n] live = emitPrimOp [] SetByteArrayOp [ba,off,len,c] live = doSetByteArrayOp ba off len c live --- Population count -emitPrimOp [res] PopCnt8Op [w] live = emitPopCntCall res w W8 live -emitPrimOp [res] PopCnt16Op [w] live = emitPopCntCall res w W16 live -emitPrimOp [res] PopCnt32Op [w] live = emitPopCntCall res w W32 live -emitPrimOp [res] PopCnt64Op [w] live = emitPopCntCall res w W64 live -emitPrimOp [res] PopCntOp [w] live = emitPopCntCall res w wordWidth live +-- Population count. +-- The type of the primop takes a Word#, so we have to be careful to narrow +-- to the correct width before calling the primop. Otherwise this can result +-- in a crash e.g. when calling the helper hs_popcnt8() which assumes that the +-- argument is <=0xff. +emitPrimOp [res] PopCnt8Op [w] live = + emitPopCntCall res (CmmMachOp mo_WordTo8 [w]) W8 live +emitPrimOp [res] PopCnt16Op [w] live = + emitPopCntCall res (CmmMachOp mo_WordTo16 [w]) W16 live +emitPrimOp [res] PopCnt32Op [w] live = + emitPopCntCall res (CmmMachOp mo_WordTo32 [w]) W32 live +emitPrimOp [res] PopCnt64Op [w] live = + emitPopCntCall res (CmmMachOp mo_WordTo64 [w]) W64 live +emitPrimOp [res] PopCntOp [w] live = + emitPopCntCall res w wordWidth live -- The rest just translate straightforwardly emitPrimOp [res] op [arg] _ _______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
