
On Wednesday 30 April 2014, 13:42:36, Joachim Breitner wrote:
Hi,
Am Dienstag, den 29.04.2014, 18:16 -0700 schrieb John Lato:
So this is interesting. The forLoop code gets compiled into a nice loop in core over unboxed Ints. The foldl' function OTOH still goes via a list. I expect it's not foldl' itself that's slow, rather that it doesn't fuse with the list producers in current GHCs. This may be improved in the future. Especially as the vectorized foldl' does fuse.
This should have improved in GHC 7.9, where I have fixed https://ghc.haskell.org/trac/ghc/ticket/7994 (making foldl a good consumer).
Confirmed, foldl' (+) 0 [1 .. 5000000 :: Int] gets the very nice core
Rec {
Main.$wgo [Occ=LoopBreaker]
:: GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int#
[GblId, Arity=2, Caf=NoCafRefs, Str=DmdType