hrm...
Lemmih
lemmih at gmail.com
Fri Jan 26 19:48:29 EST 2007
On 1/27/07, John Meacham <john at repetae.net> 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
More information about the Glasgow-haskell-users
mailing list