From: simonpj Date: Tue, 19 Nov 2002 15:51:17 +0000 (+0000) Subject: [project @ 2002-11-19 15:51:16 by simonpj] X-Git-Tag: Approx_11550_changesets_converted~1429 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=821d799485702aa76b393cecf3e2eb32381eb5df;p=ghc-hetmet.git [project @ 2002-11-19 15:51:16 by simonpj] Comments --- diff --git a/ghc/compiler/stranal/DmdAnal.lhs b/ghc/compiler/stranal/DmdAnal.lhs index 063a288..e02bf5e 100644 --- a/ghc/compiler/stranal/DmdAnal.lhs +++ b/ghc/compiler/stranal/DmdAnal.lhs @@ -487,11 +487,10 @@ We can't start with 'not-demanded' because then consider In the first iteration we'd have no demand info for x, so assume not-demanded; then we'd get TopRes for f's CPR info. Next iteration -we'd see that t was demanded, and so give it the CPR property, but -by now f has TopRes, so it will stay TopRes. -ever_in -Instead, with the Nothing setting the first time round, we say -'yes t is demanded' the first time. +we'd see that t was demanded, and so give it the CPR property, but by +now f has TopRes, so it will stay TopRes. Instead, with the Nothing +setting the first time round, we say 'yes t is demanded' the first +time. However, this does mean that for non-recursive bindings we must iterate twice to be sure of not getting over-optimistic CPR info, @@ -729,10 +728,15 @@ extendSigEnvList = extendVarEnvList extendSigsWithLam :: SigEnv -> Id -> SigEnv -- Extend the SigEnv when we meet a lambda binder --- If the binder is marked demanded with a product demand, then give it a CPR +-- If the binder is marked demanded with a product demand, then give it a CPR -- signature, because in the likely event that this is a lambda on a fn defn -- [we only use this when the lambda is being consumed with a call demand], --- it'll be w/w'd and so it will be CPR-ish. +-- it'll be w/w'd and so it will be CPR-ish. E.g. +-- f = \x::(Int,Int). if ...strict in x... then +-- x +-- else +-- (a,b) +-- We want f to have the CPR property because x does, by the time f has been w/w'd -- -- NOTE: see notes [CPR-AND-STRICTNESS] -- diff --git a/ghc/compiler/stranal/WwLib.lhs b/ghc/compiler/stranal/WwLib.lhs index 58060b0..49571f3 100644 --- a/ghc/compiler/stranal/WwLib.lhs +++ b/ghc/compiler/stranal/WwLib.lhs @@ -420,6 +420,9 @@ mkWWcpr body_ty RetCPR | n_con_args == 1 && isUnLiftedType con_arg_ty1 -- Special case when there is a single result of unlifted type + -- + -- Wrapper: case (..call worker..) of x -> C x + -- Worker: case ( ..body.. ) of C x -> x = getUniquesUs `thenUs` \ (work_uniq : arg_uniq : _) -> let work_wild = mk_ww_local work_uniq body_ty @@ -431,6 +434,8 @@ mkWWcpr body_ty RetCPR con_arg_ty1) | otherwise -- The general case + -- Wrapper: case (..call worker..) of (# a, b #) -> C a b + -- Worker: case ( ...body... ) of C a b -> (# a, b #) = getUniquesUs `thenUs` \ uniqs -> let (wrap_wild : work_wild : args) = zipWith mk_ww_local uniqs (ubx_tup_ty : body_ty : con_arg_tys) @@ -440,7 +445,7 @@ mkWWcpr body_ty RetCPR ubx_tup_app = mkConApp ubx_tup_con (map Type con_arg_tys ++ arg_vars) con_app = mkConApp data_con (map Type tycon_arg_tys ++ arg_vars) in - returnUs (\ wkr_call -> Case wkr_call wrap_wild [(DataAlt ubx_tup_con, args, con_app)], + returnUs (\ wkr_call -> Case wkr_call wrap_wild [(DataAlt ubx_tup_con, args, con_app)], \ body -> workerCase body work_wild [(DataAlt data_con, args, ubx_tup_app)], ubx_tup_ty) where