From: simonpj Date: Thu, 14 Feb 2002 14:02:55 +0000 (+0000) Subject: [project @ 2002-02-14 14:02:55 by simonpj] X-Git-Tag: Approximately_9120_patches~53 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=0d8a0e7fa62fab635a9a6ba64379688664b3e85c;hp=1f315e01fbdde2911dddb3b0789418906febc51c;p=ghc-hetmet.git [project @ 2002-02-14 14:02:55 by simonpj] --------------------------------------- Stop CSE messing up workers annotations --------------------------------------- See the comments with CSE.do_one --- diff --git a/ghc/compiler/simplCore/CSE.lhs b/ghc/compiler/simplCore/CSE.lhs index 4eb977d..3354bf8 100644 --- a/ghc/compiler/simplCore/CSE.lhs +++ b/ghc/compiler/simplCore/CSE.lhs @@ -11,7 +11,8 @@ module CSE ( #include "HsVersions.h" import CmdLineOpts ( DynFlag(..), DynFlags ) -import Id ( Id, idType ) +import Id ( Id, idType, idWorkerInfo ) +import IdInfo ( workerExists ) import CoreUtils ( hashExpr, cheapEqExpr, exprIsBig, mkAltExpr ) import DataCon ( isUnboxedTupleCon ) import Type ( tyConAppArgs ) @@ -126,12 +127,23 @@ cseBind env (Rec pairs) = let (env', pairs') = mapAccumL do_one env pairs in (env', Rec pairs') -do_one env (id, rhs) = case lookupCSEnv env rhs' of - Just other_id -> (extendSubst env' id other_id, (id', Var other_id)) - Nothing -> (addCSEnvItem env' id' rhs', (id', rhs')) - where - (env', id') = addBinder env id - rhs' = cseExpr env' rhs +do_one env (id, rhs) + = case lookupCSEnv env rhs' of + Just other_id -> (extendSubst env' id other_id, (id', Var other_id)) + Nothing -> (addCSEnvItem env' id' rhs', (id', rhs')) + where + (env', id') = addBinder env id + rhs' | not (workerExists (idWorkerInfo id)) = cseExpr env' rhs + + -- Hack alert: don't do CSE on wrapper RHSs. + -- Otherwise we find: + -- $wf = h + -- f = \x -> ...$wf... + -- ===> + -- f = \x -> ...h... + -- But the WorkerInfo for f still says $wf, which is now dead! + | otherwise = rhs + tryForCSE :: CSEnv -> CoreExpr -> CoreExpr tryForCSE env (Type t) = Type t