[project @ 2002-11-20 15:39:47 by simonpj]
------------------------------------
Improve occurrence analysis a little
------------------------------------
Consider
x1 = a0 : []
x2 = a1 : x1
x3 = a2 : x2
g = f x3
First time round, it looks as if x1 and x2 occur as an arg of a
let(rec)-bound constructor, and hence should not be inlined. (If the
RHS of a let is just (C a b) where C is a constructor, then we like to
keep it that way, with atomic a,b, so that it can be inlined easily at
a 'case'.)
But in this case, x3 is inlined in g's RHS... and now x2 is not an arg
of a let-bound constructor, so it can be inlined, and then x1. Result:
g = f (a2 : a1 : a0 : [])
Which is fine. What is *not* fine is that it has been costing us a
whole simplifier iteration for each element!
This commit adds another little hack to get around the problem: don't treat
constructor RHSs specially if the bound variable looks as if it occurs just
once so it'll be inlined. This catches the common case very nicely.
It's a pain that we have the atomic-args-for-constructor-RHSs invariant.
But I can't see how to do without it.