hrm...

John Meacham john at repetae.net
Fri Jan 26 19:08:01 EST 2007


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.

        John

-- 
John Meacham - ⑆repetae.net⑆john⑈


More information about the Glasgow-haskell-users mailing list