[project @ 2001-10-24 08:33:25 by simonpj]
authorsimonpj <unknown>
Wed, 24 Oct 2001 08:33:25 +0000 (08:33 +0000)
committersimonpj <unknown>
Wed, 24 Oct 2001 08:33:25 +0000 (08:33 +0000)
commit566075c3369dbaefd7fec9b0fde2eb11f521185a
tree9ba692173d14adb485221fbf2f8046cbda941cbc
parentb692d4c0cbcc2cc95d4c0e20d0631ee479fd8d59
[project @ 2001-10-24 08:33:25 by simonpj]
-------------------------
Implement thunk splitting
-------------------------

This is a rather nice transformation that I found when
optimising some nofib programs.

Suppose x is used strictly (never mind whether it has the CPR
property).

      let
x* = x-rhs
      in body

splitThunk transforms like this:

      let
x* = case x-rhs of { I# a -> I# a }
      in body

Now simplifier will transform to

      case x-rhs of
I# a -> let x* = I# b
        in body

which is what we want. Now suppose x-rhs is itself a case:

x-rhs = case e of { T -> I# a; F -> I# b }

The join point will abstract over a, rather than over (which is
what would have happened before) which is fine.

Notice that x certainly has the CPR property now!

In fact, splitThunk uses the function argument w/w splitting
function, so that if x's demand is deeper (say U(U(L,L),L))
then the splitting will go deeper too.

** On the way, I tidied up some of the code in WwLib.
ghc/compiler/stranal/WorkWrap.lhs
ghc/compiler/stranal/WwLib.lhs