[GHC] #5000: Eliminate absent arguments in non-strict positions
GHC
cvs-ghc at haskell.org
Mon Mar 7 11:48:51 CET 2011
#5000: Eliminate absent arguments in non-strict positions
---------------------------------+------------------------------------------
Reporter: batterseapower | Owner:
Type: feature request | Status: new
Priority: normal | Component: Compiler
Version: 7.0.2 | Keywords:
Testcase: | Blockedby:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: Runtime performance bug
---------------------------------+------------------------------------------
Description changed by batterseapower:
Old description:
> One of my programs has this is the output of GHC -O2:
>
> {{{
> Rec {
> h28_s14N
> :: forall t_aMK t_aML.
> Main.Nat -> t_aMK -> t_aML -> Main.Nat -> Main.Nat
> [LclId,
> Arity=4,
> Unf=Unf{Src=<vanilla>, TopLvl=True, Arity=4, Value=True,
> ConLike=True, Cheap=True, Expandable=True,
> Guidance=IF_ARGS [0 0 0 0] 6 2}]
> h28_s14N =
> \ (@ t_aMK)
> (@ t_aML)
> (az94z94z941_u439_amh :: Main.Nat)
> (awS1_u462_ami :: t_aMK)
> (awS1_u466_amj :: t_aML)
> (x_u590_amk :: Main.Nat) ->
> Main.S
> (h29_s14O
> @ t_aMK
> @ t_aML
> az94z94z941_u439_amh
> awS1_u462_ami
> awS1_u466_amj
> x_u590_amk)
>
> h29_s14O [Occ=LoopBreaker]
> :: forall t_aMK t_aML.
> Main.Nat -> t_aMK -> t_aML -> Main.Nat -> Main.Nat
> [LclId,
> Arity=4,
> Unf=Unf{Src=<vanilla>, TopLvl=True, Arity=4, Value=True,
> ConLike=True, Cheap=True, Expandable=True,
> Guidance=IF_ARGS [0 0 0 5] 9 0}]
> h29_s14O =
> \ (@ t_aMK)
> (@ t_aML)
> (az94z94z941_u439_amm :: Main.Nat)
> (awS1_u462_amn :: t_aMK)
> (awS1_u466_amo :: t_aML)
> (x_u590_amp :: Main.Nat) ->
> case x_u590_amp of _ {
> Main.Z -> h21'_al8 @ Main.Nat az94z94z941_u439_amm;
> Main.S x_u595_amq ->
> h28_s14N
> @ t_aMK
> @ t_aML
> az94z94z941_u439_amm
> awS1_u462_amn
> awS1_u466_amo
> x_u595_amq
> }
> end Rec }
> }}}
>
> This is ridiculous because the two awS1 arguments are totally dead. This
> greatly increases allocations made by the program.
>
> I speculate that this occurs because the recursive call to h29 is guarded
> by a use of the S constructor, making it non-strict.
New description:
One of my programs has this is the output of the post-worker/wrapper
simplification:
{{{
Rec {
h28_s14N
:: forall t_aMK t_aML.
Main.Nat -> t_aMK -> t_aML -> Main.Nat -> Main.Nat
[LclId,
Arity=4,
Str=DmdType LLLL,
Unf=Unf{Src=<vanilla>, TopLvl=True, Arity=4, Value=True,
ConLike=True, Cheap=True, Expandable=True,
Guidance=IF_ARGS [0 0 0 0] 6 2}]
h28_s14N =
\ (@ t_aMK)
(@ t_aML)
(az94z94z941_u439_amh :: Main.Nat)
(awS1_u462_ami :: t_aMK)
(awS1_u466_amj :: t_aML)
(x_u590_amk :: Main.Nat) ->
Main.S
(h29_s14O
@ t_aMK
@ t_aML
az94z94z941_u439_amh
awS1_u462_ami
awS1_u466_amj
x_u590_amk)
h29_s14O [Occ=LoopBreaker]
:: forall t_aMK t_aML.
Main.Nat -> t_aMK -> t_aML -> Main.Nat -> Main.Nat
[LclId,
Arity=4,
Str=DmdType LLLS,
Unf=Unf{Src=<vanilla>, TopLvl=True, Arity=4, Value=True,
ConLike=True, Cheap=True, Expandable=True,
Guidance=IF_ARGS [0 0 0 3] 7 0}]
h29_s14O =
\ (@ t_aMK)
(@ t_aML)
(az94z94z941_u439_amm :: Main.Nat)
(awS1_u462_amn :: t_aMK)
(awS1_u466_amo :: t_aML)
(x_u590_amp :: Main.Nat) ->
case x_u590_amp of _ {
Main.Z -> az94z94z941_u439_amm;
Main.S x_u595_amq [Dmd=Just L] ->
h28_s14N
@ t_aMK
@ t_aML
az94z94z941_u439_amm
awS1_u462_amn
awS1_u466_amo
x_u595_amq
}
end Rec }
}}}
This is ridiculous because the two awS1 arguments are totally dead. This
greatly increases allocations made by the program.
These absent arguments should be removed by the strictness analyser,
However I speculate that this occurs because the recursive call to h29 is
guarded by a use of the S constructor, making it non-strict.
--
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5000#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list