Donald Bruce Stewart wrote: > john: > > 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
> M.lit = > case GHC.Prim.addIntC# 2147418113 2147483647 If I understand the code correctly this happens in the desugaring pass already. The literal 0xFFFF0000 exceeds the range of Int so it's expressed with smaller numbers (see deSugar/DsUtils.lhs, mkIntegerExpr); in this case it becomes fromInteger (0x70000001 + 0x7FFFFFFF), which matches the above line exactly. Btw, the comment in rename/RnTypes about this ("Big integer literals are built [...]") is wrong, as it refers to mkIntegerLit instead of mkIntegerExpr. This suggests that as a workaround, using -0x00010000 and -0x00FF0100 should help (but the code will depend on the word size then). Bertram _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users