On 1/27/07, John Meacham <[EMAIL PROTECTED]> wrote:
so I have this simple bit of code, which should be fast but seems to be
being compiled to something very slow.
> import Data.Word
> import Data.Bits
>
> fhb :: Word -> Word
> fhb w = b1 .|. b2 where
> b2 = if 0xFFFF0000 .&. w /= 0 then 0x2 else 0
> b1 = if 0xFF00FF00 .&. w /= 0 then 0x1 else 0
what it compiles to is something involving Integers, lots of coercions
and other nasty stuff when it should consist of a couple of primitive
operations.
Output from an AMD64 box:
$wfhb =
\ (ww_sIw :: GHC.Prim.Word#) ->
case GHC.Prim.eqWord# (GHC.Prim.and# __word 4278255360 ww_sIw) __word 0
of wild2_aHI {
GHC.Base.False ->
case GHC.Prim.eqWord# (GHC.Prim.and# __word 4294901760 ww_sIw) __word 0
of wild21_XHW {
GHC.Base.False -> __word 3; GHC.Base.True -> __word 1
};
GHC.Base.True ->
case GHC.Prim.eqWord# (GHC.Prim.and# __word 4294901760 ww_sIw) __word 0
of wild21_XHW {
GHC.Base.False -> __word 2; GHC.Base.True -> __word 0
}
}
--
Cheers,
Lemmih
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users