#2598: Avoid excessive specialisation in SpecConstr
-----------------------------+----------------------------------------------
Reporter: simonpj | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.8.3
Severity: normal | Resolution:
Keywords: | Difficulty: Unknown
Testcase: | Architecture: Unknown
Os: Unknown |
-----------------------------+----------------------------------------------
Comment (by simonpj):
Hmm. I just compiled `dropComment` all by itself, and sure enough you get
two `dropComment` itself, one similar-sized specialisation --- together
with another FIVE smaller specialisations that look like
{{{
Foo.$sdropComment3 :: [GHC.Types.Char] -> GHC.Prim.Char# ->
[GHC.Types.Char]
Foo.$sdropComment3 xs c = '-' : Foo.$sdropComment2 xs c
}}}
and similar ones. I'd expected lots of big specialisations, so this was a
surprise to me.
The full output follows. Still there a big bloat in the middle.
Discarding the recursive components is just a slightly-random heuristic,
and I expect you're right that there might be cases where it matters.
Simon
{{{
==================== Tidy Core ====================
Foo.a :: GHC.Types.Char
[GlobalId]
[NoCafRefs]
Foo.a = GHC.Types.C# '-'
Foo.a1 :: GHC.Types.Char
[GlobalId]
[NoCafRefs]
Foo.a1 = GHC.Types.C# '-'
Foo.$sdropComment :: [GHC.Types.Char]
[GlobalId]
[NoCafRefs]
Foo.$sdropComment =
GHC.Types.: @ GHC.Types.Char Foo.a (GHC.Types.[] @ GHC.Types.Char)
Foo.$sdropComment1 :: [GHC.Types.Char]
[GlobalId]
[NoCafRefs]
Foo.$sdropComment1 =
GHC.Types.: @ GHC.Types.Char Foo.a1 Foo.$sdropComment
Rec {
Foo.$sdropComment2 :: [GHC.Types.Char]
-> GHC.Prim.Char#
-> [GHC.Types.Char]
[GlobalId]
[Arity 2
NoCafRefs]
Foo.$sdropComment2 =
\ (sc_sgz :: [GHC.Types.Char]) (sc1_sgA :: GHC.Prim.Char#) ->
GHC.Types.:
@ GHC.Types.Char
(GHC.Types.C# '-')
(Foo.$sdropComment4 sc_sgz sc1_sgA)
Foo.$sdropComment3 :: [GHC.Types.Char]
-> GHC.Prim.Char#
-> [GHC.Types.Char]
[GlobalId]
[Arity 2
NoCafRefs]
Foo.$sdropComment3 =
\ (sc_sgD :: [GHC.Types.Char]) (sc1_sgE :: GHC.Prim.Char#) ->
GHC.Types.:
@ GHC.Types.Char
(GHC.Types.C# '-')
(Foo.$sdropComment2 sc_sgD sc1_sgE)
Foo.$sdropComment4 :: [GHC.Types.Char]
-> GHC.Prim.Char#
-> [GHC.Types.Char]
[GlobalId]
[Arity 2
NoCafRefs]
Foo.$sdropComment4 =
\ (sc_sgv :: [GHC.Types.Char]) (sc1_sgw :: GHC.Prim.Char#) ->
case sc1_sgw of ds_Xfu {
__DEFAULT ->
GHC.Types.:
@ GHC.Types.Char (GHC.Types.C# ds_Xfu) (Foo.dropComment sc_sgv);
' ' ->
case sc_sgv of wild_Xo {
[] ->
GHC.Types.:
@ GHC.Types.Char
(GHC.Types.C# ' ')
(GHC.Types.[] @ GHC.Types.Char);
: ds1_dfc ds2_dfd ->
case ds1_dfc of wild1_Xu { GHC.Types.C# ds3_dfe ->
case ds3_dfe of ds4_XfM {
__DEFAULT ->
GHC.Types.:
@ GHC.Types.Char
(GHC.Types.C# ' ')
(Foo.$sdropComment4 ds2_dfd ds4_XfM);
'-' ->
case ds2_dfd of wild2_XD {
[] ->
GHC.Types.: @ GHC.Types.Char (GHC.Types.C# ' ')
Foo.$sdropComment;
: ds5_dff ds6_dfg ->
case ds5_dff of wild3_XJ { GHC.Types.C# ds7_dfh ->
case ds7_dfh of ds8_Xg4 {
__DEFAULT ->
GHC.Types.:
@ GHC.Types.Char
(GHC.Types.C# ' ')
(GHC.Types.:
@ GHC.Types.Char
(GHC.Types.C# '-')
(Foo.$sdropComment4 ds6_dfg ds8_Xg4));
'-' ->
case ds6_dfg of wild4_XS {
[] ->
GHC.Types.: @ GHC.Types.Char (GHC.Types.C# '
') Foo.$sdropComment1;
: ds9_dfi ds10_dfj ->
case ds9_dfi of wild5_XY { GHC.Types.C#
ds11_dfk ->
case ds11_dfk of ds12_Xgm {
__DEFAULT ->
GHC.Types.:
@ GHC.Types.Char
(GHC.Types.C# ' ')
(GHC.Types.:
@ GHC.Types.Char
(GHC.Types.C# '-')
(GHC.Types.:
@ GHC.Types.Char
(GHC.Types.C# '-')
(Foo.$sdropComment4 ds10_dfj
ds12_Xgm)));
' ' -> GHC.Types.[] @ GHC.Types.Char
}}}}}}}}}
Foo.dropComment :: [GHC.Types.Char] -> [GHC.Types.Char]
[GlobalId]
[Arity 1
NoCafRefs
Str: DmdType S]
Foo.dropComment =
\ (ds_df8 :: [GHC.Types.Char]) ->
case ds_df8 of wild_B1 {
[] -> GHC.Types.[] @ GHC.Types.Char;
: ds1_df9 ds2_dfa ->
case ds1_df9 of wild1_Xf { GHC.Types.C# ds3_dfb ->
case ds3_dfb of ds4_Xfu {
__DEFAULT ->
GHC.Types.: @ GHC.Types.Char wild1_Xf (Foo.dropComment
ds2_dfa);
' ' ->
case ds2_dfa of wild2_Xo {
[] ->
GHC.Types.:
@ GHC.Types.Char wild1_Xf (GHC.Types.[] @
GHC.Types.Char);
: ds5_dfc ds6_dfd ->
case ds5_dfc of wild3_Xu { GHC.Types.C# ds7_dfe ->
case ds7_dfe of ds8_XfM {
__DEFAULT ->
GHC.Types.:
@ GHC.Types.Char wild1_Xf (Foo.$sdropComment4
ds6_dfd ds8_XfM);
'-' ->
case ds6_dfd of wild4_XD {
[] -> GHC.Types.: @ GHC.Types.Char wild1_Xf
Foo.$sdropComment;
: ds9_dff ds10_dfg ->
case ds9_dff of wild5_XJ { GHC.Types.C# ds11_dfh
->
case ds11_dfh of ds12_Xg4 {
__DEFAULT ->
GHC.Types.:
@ GHC.Types.Char
wild1_Xf
(GHC.Types.:
@ GHC.Types.Char
(GHC.Types.C# '-')
(Foo.$sdropComment4 ds10_dfg ds12_Xg4));
'-' ->
case ds10_dfg of wild6_XS {
[] -> GHC.Types.: @ GHC.Types.Char wild1_Xf
Foo.$sdropComment1;
: ds13_dfi ds14_dfj ->
case ds13_dfi of wild7_XY { GHC.Types.C#
ds15_dfk ->
case ds15_dfk of ds16_Xgm {
__DEFAULT ->
GHC.Types.:
@ GHC.Types.Char
wild1_Xf
(GHC.Types.:
@ GHC.Types.Char
(GHC.Types.C# '-')
(GHC.Types.:
@ GHC.Types.Char
(GHC.Types.C# '-')
(Foo.$sdropComment4 ds14_dfj
ds16_Xgm)));
' ' -> GHC.Types.[] @ GHC.Types.Char
}}}}}}}}}}}
end Rec }
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2598#comment:4>
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