[commit: ghc] wip/common-context: Move Common Context after CSE (e009b4f)

git at git.haskell.org git at git.haskell.org
Tue Dec 17 23:42:35 UTC 2013


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/common-context
Link       : http://ghc.haskell.org/trac/ghc/changeset/e009b4f1676c3ae080b59cb1e0914409e0c4660c/ghc

>---------------------------------------------------------------

commit e009b4f1676c3ae080b59cb1e0914409e0c4660c
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Wed Dec 18 00:11:25 2013 +0100

    Move Common Context after CSE
    
    We had something like
    	 let $j = ...
    	 in case foo of ... -> case $j a b c of ... -> case foo of
    and moving the inner "case foo" into $j prevented CSE from happening
    here.
    (Although presumably the "let $j" could be moved inside the outer case
    before CSE, to give CSE a greater scope here.)


>---------------------------------------------------------------

e009b4f1676c3ae080b59cb1e0914409e0c4660c
 compiler/simplCore/CommonContext.lhs |    2 ++
 compiler/simplCore/SimplCore.lhs     |    5 +++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/compiler/simplCore/CommonContext.lhs b/compiler/simplCore/CommonContext.lhs
index 9199e70..1cfcbe9 100644
--- a/compiler/simplCore/CommonContext.lhs
+++ b/compiler/simplCore/CommonContext.lhs
@@ -52,6 +52,8 @@ findInterestingLet (Let (Rec pairs) body) =
 process :: Var -> CoreExpr -> CoreExpr -> (Var, CoreExpr, CoreExpr)
 process v e body
   | idArity v <= 0 = (v, e, body)
+  -- TODO: check for non value args here. For now, ignore this let then
+  -- Possibly later: Check if all uses have the same type argument
   | otherwise
   = case contextOf v body of
         OneUse cts | not (null cts) ->
diff --git a/compiler/simplCore/SimplCore.lhs b/compiler/simplCore/SimplCore.lhs
index 92784d3..110c461 100644
--- a/compiler/simplCore/SimplCore.lhs
+++ b/compiler/simplCore/SimplCore.lhs
@@ -190,8 +190,6 @@ getCoreToDo dflags
     demand_analyser = (CoreDoPasses ([
                            CoreDoStrictness,
                            CoreDoWorkerWrapper,
-                           simpl_phase 0 ["post-worker-wrapper"] max_iter,
-                           CoreCommonContext,
                            simpl_phase 0 ["post-worker-wrapper"] max_iter
                            ]))
 
@@ -293,6 +291,9 @@ getCoreToDo dflags
                         -- reduce the possiblility of shadowing
                         -- Reason: see Note [Shadowing] in SpecConstr.lhs
 
+        CoreCommonContext,
+        simpl_phase 0 ["post-common-context"] max_iter,
+
         runWhen spec_constr CoreDoSpecConstr,
 
         maybe_rule_check (Phase 0),



More information about the ghc-commits mailing list