Opened 4 years ago

Closed 4 years ago

#5000 closed feature request (worksforme)

Eliminate absent arguments in non-strict positions

Reported by: batterseapower Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.0.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime performance bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description (last modified by batterseapower)

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.

Change History (2)

comment:1 Changed 4 years ago by batterseapower

  • Description modified (diff)

comment:2 Changed 4 years ago by batterseapower

  • Resolution set to worksforme
  • Status changed from new to closed

Urk, never mind: this was fixed sometime between 7.0.1.20101215 and HEAD

Note: See TracTickets for help on using tickets.