Improve SpecConstr for local bindings: seed specialisation from the calls
authorsimonpj@microsoft.com <unknown>
Thu, 6 Mar 2008 12:00:04 +0000 (12:00 +0000)
committersimonpj@microsoft.com <unknown>
Thu, 6 Mar 2008 12:00:04 +0000 (12:00 +0000)
commite5adcaf845207c73da65cb44cff4ef83b76dd4a9
treed2d69b9169c1aa7db4356ff424da5d48836ff136
parent6dc702e8e8b744196b5841729d16d03f83218834
Improve SpecConstr for local bindings: seed specialisation from the calls

This patch makes a significant improvement to SpecConstr, based on
Roman's experience with using it for stream fusion.  The main change is
this:

  * For local (not-top-level) declarations, seed the specialisation
    loop from the calls in the body of the 'let'.

See Note [Local recursive groups] for discussion and example.  Top-level
declarations are treated just as before.

Other changes in this patch:

  * New flag -fspec-constr-count=N sets the maximum number of specialisations
    for any single function to N.  -fno-spec-constr-count removes the limit.

  * Refactoring in specLoop and friends; new algebraic data types
    OneSpec and SpecInfo instead of the tuples that were there before

  * Be less keen to specialise on variables that are simply in scope.
    Example
      f p q = letrec g a y = ...g....  in g q p
    We probably do not want to specialise 'g' for calls with exactly
    the arguments 'q' and 'p', since we know nothing about them.
compiler/main/DynFlags.hs
compiler/specialise/SpecConstr.lhs
docs/users_guide/flags.xml