Skip to content
  • Simon Peyton Jones's avatar
    Rewrite CorePrep and improve eta expansion · 62eeda5a
    Simon Peyton Jones authored
    This patch does two main things
    
    a) Rewrite most of CorePrep to be much easier to understand (I hope!).
       The invariants established by CorePrep are now written out, and
       the code is more perspicuous.  It is surpringly hard to get right,
       and the old code had become quite incomprehensible.
    
    b) Rewrite the eta-expander so that it does a bit of simplifying
       on-the-fly, and thereby guarantees to maintain the CorePrep
       invariants.  This make it much easier to use from CorePrep, and
       is a generally good thing anyway.
    
    A couple of pieces of re-structuring:
    
    *  I moved the eta-expander and arity analysis stuff into a new
       module coreSyn/CoreArity.
    
       Max will find that the type CoreArity.EtaInfo looks strangely 
       familiar.
    
    *  I moved a bunch of comments from Simplify to OccurAnal; that's
       why it looks as though there's a lot of lines changed in those
       modules.
    
    On the way I fixed various things
    
      - Function arguments are eta expanded
           f (map g)  ===>  let s = \x. map g x in f s
    
      - Trac #2368
    
    The result is a modest performance gain, I think mainly due
    to the first of these changes:
    
    --------------------------------------------------------------------------------
            Program           Size    Allocs   Runtime   Elapsed
    --------------------------------------------------------------------------------
                Min          -1.0%    -17.4%    -19.1%    -46.4%
                Max          +0.3%     +0.5%     +5.4%    +53.8%
     Geometric Mean          -0.1%     -0.3%     -7.0%    -10.2%
    
    
    62eeda5a