[project @ 2001-03-05 15:37:25 by simonpj]
authorsimonpj <unknown>
Mon, 5 Mar 2001 15:37:25 +0000 (15:37 +0000)
committersimonpj <unknown>
Mon, 5 Mar 2001 15:37:25 +0000 (15:37 +0000)
commitc8276ef7cf2a315fcb8f609cf548a6e90625e578
tree1325a17990f60f49e2ddd52a20230959c841dea1
parent757f1ebd95bfd38f0124b36386be6ad0f990dce1
[project @ 2001-03-05 15:37:25 by simonpj]
Exploit the 1-shot lambda HACK in etaExpandArity

We often find code like

f :: Int -> IO ()
f = \ x -> case ... of
p1 -> \s -> ...rhs1...
p2 -> \s -> ...rhs2...

where the \s is a state transformer lambda.  Almost invariably
these \s things are one-shot; that is, we virtually never say

let
   h = f 3
in
h >> h >> h

In this case we'd be much better off eta-expanding f, to

f :: Int -> IO ()
f = \ x \ s -> case ... of
   p1 -> ...rhs1...
   p2 -> ...rhs2...

GHC already has a MAJOR HACK in

Id.isOneShotLambda

which declares that any \s::State# T is a one-shot lambda.  It's
almost always true, and it makes a big difference.

This commit simply makes use of isOneShotLambda to improve the
results of CoreUtils.etaExpandArity.  Which has the desired effect.

There isn't a flag to control the MAJOR HACK yet.  Maybe there should be.

Anyway, some of Manuel's array code should improve a lot.
ghc/compiler/coreSyn/CoreUtils.lhs