#7520: Implement cardinality analysis ---------------------------------+------------------------------------------ Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.1 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Ilya is well on the way to a cardinality analyser. Today I realised that it'll help a lot with CPS-heavy code. For example, here's what happens with {{{ data DT = DT { field1 :: Int , field2 :: Int , field3 :: Int } deriving( Read ) }}} After strictness analysis and simplification we get this: {{{ $wa_sD5 = \ (ww_sD1 :: GHC.Prim.Int#) (@ b_awu) (w_sD3 :: W2.DT -> Text.ParserCombinators.ReadP.P b_awu) -> case GHC.Prim.<=# ww_sD1 11 of _ { GHC.Types.False -> Text.ParserCombinators.ReadP.Fail @ b_awu; GHC.Types.True -> Text.Read.Lex.expect1 a_su6 @ b_awu (\ _ -> Text.Read.Lex.expect1 a_suf @ b_awu (\ _ -> Text.Read.Lex.expect1 a_sum @ b_awu (\ _ -> Text.Read.Lex.expect1 a_suv @ b_awu (\ _ -> GHC.Read.$fReadInt5 GHC.Read.$fReadInt_$sconvertInt Text.ParserCombinators.ReadPrec.minPrec @ b_awu (\ (a2_XB0 [Dmd=Just L] :: GHC.Types.Int) -> Text.Read.Lex.expect1 lvl_svA @ b_awu (\ _ -> Text.Read.Lex.expect1 lvl_svE @ b_awu (\ _ -> Text.Read.Lex.expect1 lvl_svI @ b_awu (\ _ -> GHC.Read.$fReadInt5 GHC.Read.$fReadInt_$sconvertInt Text.ParserCombinators.ReadPrec.minPrec @ b_awu (\ (a2_XBa [Dmd=Just L] :: GHC.Types.Int) -> ... }}} Look at all those nested continuations! Then the subsequent float-out pass floats out lots of MFEs, but entirely fruitlessly because all these are actually one-shot lambdas.
I'm not certain that the analysis will catch them all, but it might. -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7520> 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