Sat Sep 20 10:52:38 PDT 2008 [EMAIL PROTECTED]
* Tidy up the treatment of dead binders
This patch does a lot of tidying up of the way that dead variables are
handled in Core. Just the sort of thing to do on an aeroplane.
* The tricky "binder-swap" optimisation is moved from the Simplifier
to the Occurrence Analyser. See Note [Binder swap] in OccurAnal.
This is really a nice change. It should reduce the number of
simplifier iteratoins (slightly perhaps). And it means that
we can be much less pessimistic about zapping occurrence info
on binders in a case expression.
* For example:
case x of y { (a,b) -> e }
Previously, each time around, even if y,a,b were all dead, the
Simplifier would pessimistically zap their OccInfo, so that we
can't see they are dead any more. As a result virtually no
case expression ended up with dead binders. This wasn't Bad
in itself, but it always felt wrong.
* I added a check to CoreLint to check that a dead binder really
isn't used. That showed up a couple of bugs in CSE. (Only in
this sense -- they didn't really matter.)
* I've changed the PprCore printer to print "_" for a dead variable.
(Use -dppr-debug to see it again.) This reduces clutter quite a
bit, and of course it's much more useful with the above change.
* Another benefit of the binder-swap change is that I could get rid of
the Simplifier hack (working, but hacky) in which the InScopeSet was
used to map a variable to a *different* variable. That allowed me
to remove VarEnv.modifyInScopeSet, and to simplify lookupInScopeSet
so that it doesn't look for a fixpoint. This fixes no bugs, but
is a useful cleanup.
* Roman pointed out that Id.mkWildId is jolly dangerous, because
of its fixed unique. So I've
- localied it to MkCore, where it is private (not exported)
- renamed it to 'mkWildBinder' to stress that you should only
use it at binding sites, unless you really know what you are
doing
- provided a function MkCore.mkWildCase that emodies the most
common use of mkWildId, and use that elsewhere
So things are much better
* A knock-on change is that I found a common pattern of localising
a potentially global Id, and made a function for it: Id.localiseId
M ./compiler/basicTypes/Id.lhs -8 +21
M ./compiler/basicTypes/VarEnv.lhs -26 +15
M ./compiler/coreSyn/CoreLint.lhs +19
M ./compiler/coreSyn/CoreUtils.lhs -9 +1
M ./compiler/coreSyn/MkCore.lhs -7 +35
M ./compiler/coreSyn/PprCore.lhs -12 +21
M ./compiler/deSugar/DsBinds.lhs -6 +3
M ./compiler/deSugar/DsCCall.lhs -8 +9
M ./compiler/deSugar/DsUtils.lhs -5 +3
M ./compiler/prelude/PrelRules.lhs -2 +3
M ./compiler/simplCore/CSE.lhs -12 +18
M ./compiler/simplCore/LiberateCase.lhs -4 +2
M ./compiler/simplCore/OccurAnal.lhs -40 +119
M ./compiler/simplCore/SimplEnv.lhs -13 +23
M ./compiler/simplCore/Simplify.lhs -192 +167
M ./compiler/vectorise/VectCore.hs -3 +3
M ./compiler/vectorise/VectType.hs -12 +12
M ./compiler/vectorise/VectUtils.hs -3 +2
View patch online:
http://darcs.haskell.org/ghc/_darcs/patches/20080920175238-1287e-cd2c2f29254452bdce71d120d25bfe88e64bd9a6.gz
_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc