Repository : ssh://darcs.haskell.org//srv/darcs/ghc On branch : master
http://hackage.haskell.org/trac/ghc/changeset/78e2beb5cda2d8b0f7bf22e32fcbf20ae35e63ea >--------------------------------------------------------------- commit 78e2beb5cda2d8b0f7bf22e32fcbf20ae35e63ea Author: Simon Peyton Jones <[email protected]> Date: Thu Feb 16 13:42:01 2012 +0000 Comments only >--------------------------------------------------------------- compiler/simplCore/SetLevels.lhs | 5 ++++- compiler/simplCore/Simplify.lhs | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletions(-) diff --git a/compiler/simplCore/SetLevels.lhs b/compiler/simplCore/SetLevels.lhs index beb64cb..6e0afb4 100644 --- a/compiler/simplCore/SetLevels.lhs +++ b/compiler/simplCore/SetLevels.lhs @@ -419,7 +419,10 @@ the inner loop. Things to note * We can't float a case to top level * It's worth doing this float even if we don't float - the case outside a value lambda + the case outside a value lambda. Example + case x of { + MkT y -> (case y of I# w2 -> ..., case y of I# w2 -> ...) + If we floated the cases out we could eliminate one of them. * We only do this with a single-alternative case Note [Check the output scrutinee for okForSpec] diff --git a/compiler/simplCore/Simplify.lhs b/compiler/simplCore/Simplify.lhs index 900d70c..ee20a52 100644 --- a/compiler/simplCore/Simplify.lhs +++ b/compiler/simplCore/Simplify.lhs @@ -1668,6 +1668,22 @@ not want to transform to in blah because that builds an unnecessary thunk. +Note [Case elimination: unlifted case] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + case a +# b of r -> ...r... +Then we do case-elimination (to make a let) followed by inlining, +to get + .....(a +# b).... +If we have + case indexArray# a i of r -> ...r... +we might like to do the same, and inline the (indexArray# a i). +But indexArray# is not okForSpeculation, so we don't build a let +in rebuildCase (lest it get floated *out*), so the inlining doesn't +happen either. + +This really isn't a big deal I think. The let can be + Further notes about case elimination ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1788,6 +1804,7 @@ rebuildCase env scrut case_bndr [(_, bndrs, rhs)] cont | otherwise = exprOkForSpeculation scrut -- The case-binder is alive, but we may be able -- turn the case into a let, if the expression is ok-for-spec + -- See Note [Case elimination: unlifted case] ok_for_spec = exprOkForSpeculation scrut is_plain_seq = isDeadBinder case_bndr -- Evaluation *only* for effect _______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
