[GHC] #5075: CPR optimisation for sum types if only one constructor is used
GHC
cvs-ghc at haskell.org
Wed Mar 20 15:14:08 CET 2013
#5075: CPR optimisation for sum types if only one constructor is used
---------------------------------+------------------------------------------
Reporter: batterseapower | Owner: simonpj
Type: feature request | Status: patch
Priority: normal | Milestone: 7.6.2
Component: Compiler | Version: 7.0.3
Keywords: | Os: Unknown/Multiple
Architecture: Unknown/Multiple | Failure: None/Unknown
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: |
---------------------------------+------------------------------------------
Comment(by nfrisby):
Confirmed: the Just gets ww'd-away with this core2core pipeline:
SpecConstr, simpl, stranal, wwsplit, simpl.
{{{
Rec {
$w$s$wloop
$w$s$wloop =
\ w_sqX w1_sqY ->
case w_sqX of ds_Xng {
__DEFAULT ->
$w$s$wloop
(-# ds_Xng 1) (case w1_sqY of _ { I# x_anM -> I# (+# x_anM 1)
});
0 -> (# w1_sqY #)
}
end Rec }
loop_$s$wloop [InlPrag=INLINE[0]]
:: ...
[...
Str=DmdType <S,U><L,U(U)>m2,
Unf=Unf{Src=Worker=$w$s$wloop,...}]
loop_$s$wloop =
\ w_sqX w1_sqY ->
case $w$s$wloop w_sqX w1_sqY of _ { (# ww1_sr4 #) -> Just ww1_sr4 }
Rec {
loop_$s$wloop1
loop_$s$wloop1 =
\ sc_sqe ->
case sc_sqe of ds_Xng {
__DEFAULT -> loop_$s$wloop1 (-# ds_Xng 1);
0 -> Nothing
}
end Rec }
}}}
That's an impressive prefix, "$w$s$w".
In case any reader is wondering, the second argument to the loop gets
unboxed if a strict variant of Maybe is used.
Thanks again for the compact example.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5075#comment:13>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list