#4978: Continuation passing style loop doesn't compile into a loop ---------------------------------+------------------------------------------ Reporter: tibbe | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.4.1 Component: Compiler | Version: 7.0.1 Keywords: | Testcase: Blockedby: | Difficulty: Os: Unknown/Multiple | Blocking: Architecture: Unknown/Multiple | Failure: None/Unknown ---------------------------------+------------------------------------------
Comment(by tibbe): The above change to `go_pap` does improve the performance in the binary package's benchmark suite by a bit, but the core still doesn't look great. Here's an example from `Repro3.hs`: {{{ $wa = \ (w_s11t :: [Word8]) (w1_s11u :: Buffer -> [ByteString]) (ww_s11x :: Addr#) (ww1_s11y :: ForeignPtrContents) (ww2_s11z :: Int#) (ww3_s11A :: Int#) (ww4_s11B :: Int#) -> case w_s11t of _ { [] -> w1_s11u (Buffer ww_s11x ww1_s11y ww2_s11z ww3_s11A ww4_s11B); : x1_ax1 xs1_ax2 -> let { $weta_s11K = \ (ww5_s11j :: Addr#) (ww6_s11k :: ForeignPtrContents) (ww7_s11l :: Int#) (ww8_s11m :: Int#) (ww9_s11n :: Int#) -> case x1_ax1 of _ { W8# x2_aYW -> case writeWord8OffAddr# (plusAddr# ww5_s11j (+# ww7_s11l ww8_s11m)) 0 x2_aYW realWorld# of s2_aYY { __DEFAULT -> case touch# ww6_s11k s2_aYY of _ { __DEFAULT -> $wa xs1_ax2 w1_s11u ww5_s11j ww6_s11k ww7_s11l (+# ww8_s11m 1) (-# ww9_s11n 1) } } } } in case <=# 1 ww4_s11B of _ { False -> case ww3_s11A of wild2_X18 { __DEFAULT -> : (PS ww_s11x ww1_s11y ww2_s11z wild2_X18) (case newPinnedByteArray# 32752 realWorld# of _ { (# _, mbarr#_a10h #) -> $weta_s11K (byteArrayContents# (mbarr#_a10h `cast` ...)) (PlainPtr mbarr#_a10h) 0 0 32752 }); 0 -> case newPinnedByteArray# 32752 realWorld# of _ { (# _, mbarr#_a10h #) -> $weta_s11K (byteArrayContents# (mbarr#_a10h `cast` ...)) (PlainPtr mbarr#_a10h) 0 0 32752 } }; True -> $weta_s11K ww_s11x ww1_s11y ww2_s11z ww3_s11A ww4_s11B } } }}} It would be better to duplicate `$weta_s11K` in both branches instead of allocating a closure. -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4978#comment:14> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler _______________________________________________ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs