[project @ 2001-04-05 11:28:36 by simonpj]
authorsimonpj <unknown>
Thu, 5 Apr 2001 11:28:36 +0000 (11:28 +0000)
committersimonpj <unknown>
Thu, 5 Apr 2001 11:28:36 +0000 (11:28 +0000)
commitf05b6981de4c1f76279e17a59d3c42e83ee8d244
treecb49002db9cbb34052143147a8683075f61558a7
parenta5bfbd936f91d871d15857963b8a68942c12f520
[project @ 2001-04-05 11:28:36 by simonpj]
------------------
Better arity stuff
------------------

* CoreToStg now has a local function, predictArity, to
  predict the code-gen arity of a function. Better not to
  use CoreUtils.exprArity, because predictArity is a very
  local thing

* CoreUtils.exprArity is freed to do a better job.  Comments
  below.

exprArity is a cheap-and-cheerful version of exprEtaExpandArity.
It tells how many things the expression can be applied to before doing
any work.  It doesn't look inside cases, lets, etc.  The idea is that
exprEtaExpandArity will do the hard work, leaving something that's easy
for exprArity to grapple with.  In particular, Simplify uses exprArity to
compute the ArityInfo for the Id.

Originally I thought that it was enough just to look for top-level lambdas, but
it isn't.  I've seen this

foo = PrelBase.timesInt

We want foo to get arity 2 even though the eta-expander will leave it
unchanged, in the expectation that it'll be inlined.  But occasionally it
isn't, because foo is blacklisted (used in a rule).

Similarly, see the ok_note check in exprEtaExpandArity.  So
f = __inline_me (\x -> e)
won't be eta-expanded.

And in any case it seems more robust to have exprArity be a bit more intelligent.
ghc/compiler/coreSyn/CoreUtils.lhs
ghc/compiler/stgSyn/CoreToStg.lhs