#4978: Continuation passing style loop doesn't compile into a loop
---------------------------------+------------------------------------------
Reporter: tibbe | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.0.1
Keywords: | Testcase:
Blockedby: | Difficulty:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
Comment(by simonpj):
So HEAD (and 7.0.2) does a much better job here. It has a simple arity
analyser that (somewhat to my surprise) is clever enough to spot that
`test2` really has arity 3. Your earlier example was in fact nastier,
because `test4`'s arity depended on its parameter `k`, which isn't the
case with your new example.
Anyway try HEAD of 7.0.2.
{{{
T4978a.test2 [Occ=LoopBreaker]
:: [GHC.Word.Word8]
-> (T4978a.Buffer -> [Data.ByteString.Internal.ByteString])
-> T4978a.Buffer
-> [Data.ByteString.Internal.ByteString]
[GblId, Arity=3, Str=DmdType SC(S)L]
T4978a.test2 =
\ (ds_dQG :: [GHC.Word.Word8])
(eta_B1 :: T4978a.Buffer -> [Data.ByteString.Internal.ByteString])
(eta1_X2 :: T4978a.Buffer) ->
case ds_dQG of _ {
[] -> eta_B1 eta1_X2;
: x1_ax6 xs1_ax7 ->
case eta1_X2
of _ { T4978a.Buffer rb_dQL rb1_dQM rb2_dQN rb3_dQO rb4_dQP ->
case GHC.Prim.<=# 1 rb4_dQP of _ {
GHC.Bool.False ->
lvl1_rYs
`cast` (CoUnsafe
T4978a.Builder [Data.ByteString.Internal.ByteString]
:: T4978a.Builder ~
[Data.ByteString.Internal.ByteString]);
GHC.Bool.True ->
case x1_ax6 of _ { GHC.Word.W8# x2_aWt ->
case GHC.Prim.writeWord8OffAddr#
@ GHC.Prim.RealWorld
(GHC.Prim.plusAddr# rb_dQL (GHC.Prim.+# rb2_dQN
rb3_dQO))
0
x2_aWt
GHC.Prim.realWorld#
of s2_aWv { __DEFAULT ->
case GHC.Prim.touch#
@ GHC.ForeignPtr.ForeignPtrContents rb1_dQM s2_aWv
of _ { __DEFAULT ->
T4978a.test2
xs1_ax7
eta_B1
(T4978a.Buffer
rb_dQL
rb1_dQM
rb2_dQN
(GHC.Prim.+# rb3_dQO 1)
(GHC.Prim.-# rb4_dQP 1))
}
}
}
}
}
}
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4978#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs