[Haskell-cafe] GHC vs GCC

Jan-Willem Maessen jmaessen at alum.mit.edu
Sun Mar 28 09:33:48 EDT 2010


On Sat, Mar 27, 2010 at 8:16 PM, Roman Leshchinskiy <rl at cse.unsw.edu.au>wrote:

> On 28/03/2010, at 01:36, Jan-Willem Maessen wrote:
>
> > It's worth pointing out that there's a bit of bang-pattern mysticism
> going on in this conversation (which has not been uncommon of late!).  A
> non-buggy strictness analyzer should expose the strictness of these
> functions without difficulty.
>
> Actually, rangeJ is lazy in i and rangeK is lazy in i and j. GHC does unbox
> everything important here but that needs more optimisations than just
> strictness analysis. You are right, though, that GHC doesn't need bang
> patterns here.
>

Quite right, the condition in rangeK that mentions all variables is under
another condition:

       rangeK :: Int -> Int -> Int -> Int -> Int
       rangeK i j k acc
           | k < 1000 =
               if i * i + j * j + k * k `mod` 7 == 0
               ...

So we need to apply some constructor specialization as well to notice that i
and j are always of the form (Int# i#).

-Jan

Roman
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100328/9efc9990/attachment.html


More information about the Haskell-Cafe mailing list