Skip to content
  • Simon Peyton Jones's avatar
    Add a simple arity analyser · 1d7a3cf3
    Simon Peyton Jones authored
    I've wanted to do this for ages, but never gotten around to
    it.  The main notes are in Note [Arity analysis] in SimplUtils.
    
    The motivating example for arity analysis is this:
    
      f = \x. let g = f (x+1)
              in \y. ...g...
    
    What arity does f have?  Really it should have arity 2, but a naive
    look at the RHS won't see that.  You need a fixpoint analysis which
    says it has arity "infinity" the first time round.
    
    This makes things more robust to the way in which you write code.  For
    example, see Trac #4474 which is fixed by this change.
    
    Not a huge difference, but worth while:
    
            Program           Size    Allocs   Runtime   Elapsed
    --------------------------------------------------------------------------------
                Min          -0.4%     -2.2%    -10.0%    -10.0%
                Max          +2.7%     +0.3%     +7.1%     +6.9%
     Geometric Mean          -0.3%     -0.2%     -2.1%     -2.2%
    
    I don't really believe the runtime numbers, because the machine was
    busy, but the bottom line is that not much changes, and what does
    change reliably (allocation and size) is in the right direction.
    1d7a3cf3