Make SpecConstr specialise for constant arguments again
authorsimonpj@microsoft.com <unknown>
Sun, 5 Aug 2007 22:03:35 +0000 (22:03 +0000)
committersimonpj@microsoft.com <unknown>
Sun, 5 Aug 2007 22:03:35 +0000 (22:03 +0000)
commit57a4597d5a487af65d0a6c9a6701e2efcbbefac2
tree483f3eb96e2082db89ac1b0687ed69487c0c86c9
parent0b34654125ca8551a1ce82919236d67a862b59bd
Make SpecConstr specialise for constant arguments again

Consider
  lvl = Just True

  foo :: Maybe Bool -> Int -> Int
  foo (Just True) i = i
  foo _           i = foo lvl i

SpecConstr should specialise foo, but it wasn't doing so (spotted
by Roman).

Reason: lvl's unfolding wasn't in the cloned version of lvl.
Solution: extend the value environment to record top-level bindings too

At the same time I made it work if 'lvl' is a lambda, in which case it
is again worth specialisg.  This meant renaming ConEnv to ValueEnv,
and adding a case for 'LambdaVal'.

(To make specialisation on lambdas work properly, we have to do lambda
lifting as well, but this gets part of the way, and fixes a bug too.)
compiler/specialise/SpecConstr.lhs