X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FcoreSyn%2FCoreUnfold.lhs;h=2d83a0fc717e53258ef2294f2542675ec482f173;hb=e66a5311c7bfa0690875f2e87bbe74d053e24147;hp=f32d5b1482c386aaf21d6979c22b8b7ad99e0962;hpb=72462499b891d5779c19f3bda03f96e24f9554ae;p=ghc-hetmet.git diff --git a/compiler/coreSyn/CoreUnfold.lhs b/compiler/coreSyn/CoreUnfold.lhs index f32d5b1..2d83a0f 100644 --- a/compiler/coreSyn/CoreUnfold.lhs +++ b/compiler/coreSyn/CoreUnfold.lhs @@ -42,6 +42,7 @@ import CoreSyn import PprCore () -- Instances import OccurAnal import CoreSubst hiding( substTy ) +import CoreFVs ( exprFreeVars ) import CoreUtils import Id import DataCon @@ -54,6 +55,7 @@ import TcType ( tcSplitDFunTy ) import Type import Coercion import PrelNames +import VarEnv ( mkInScopeSet ) import Bag import Util import FastTypes @@ -118,8 +120,9 @@ mkCoreUnfolding top_lvl expr arity guidance = CoreUnfolding { uf_tmpl = occurAnalyseExpr expr, uf_arity = arity, uf_is_top = top_lvl, - uf_is_value = exprIsHNF expr, - uf_is_cheap = exprIsCheap expr, + uf_is_value = exprIsHNF expr, + uf_is_conlike = exprIsConLike expr, + uf_is_cheap = exprIsCheap expr, uf_expandable = exprIsExpandable expr, uf_guidance = guidance } @@ -934,7 +937,7 @@ Note [Conlike is interesting] Consider f d = ...((*) d x y)... ... f (df d')... -where df is con-like. Then we'd really like to inline so that the +where df is con-like. Then we'd really like to inline 'f' so that the rule for (*) (df d) can fire. To do this a) we give a discount for being an argument of a class-op (eg (*) d) b) we say that a con-like argument (eg (df d)) is interesting @@ -956,10 +959,11 @@ interestingArg e = go e 0 -- data constructors here | idArity v > n = ValueArg -- Catches (eg) primops with arity but no unfolding | n > 0 = NonTrivArg -- Saturated or unknown call - | evald_unfolding = ValueArg -- n==0; look for a value + | conlike_unfolding = ValueArg -- n==0; look for an interesting unfolding + -- See Note [Conlike is interesting] | otherwise = TrivArg -- n==0, no useful unfolding where - evald_unfolding = isEvaldUnfolding (idUnfolding v) + conlike_unfolding = isConLikeUnfolding (idUnfolding v) go (Type _) _ = TrivArg go (App fn (Type _)) n = go fn n @@ -1070,7 +1074,8 @@ exprIsConApp_maybe (Cast expr co) let dump_doc = vcat [ppr dc, ppr dc_univ_tyvars, ppr dc_ex_tyvars, ppr arg_tys, ppr dc_args, ppr _dc_univ_args, ppr ex_args, ppr val_args] - ASSERT2( coreEqType from_ty (mkTyConApp dc_tc _dc_univ_args), dump_doc ) + in + ASSERT2( coreEqType _from_ty (mkTyConApp dc_tc _dc_univ_args), dump_doc ) ASSERT2( all isTypeArg (ex_args ++ co_args), dump_doc ) ASSERT2( equalLength val_args arg_tys, dump_doc ) #endif @@ -1110,6 +1115,9 @@ exprIsConApp_maybe expr analyse _ _ = Nothing ----------- + in_scope = mkInScopeSet (exprFreeVars expr) + + ----------- beta (Lam v body) pairs (arg : args) | isTypeArg arg = beta body ((v,arg):pairs) args @@ -1118,12 +1126,13 @@ exprIsConApp_maybe expr = Nothing beta fun pairs args - = case analyse (substExpr (mkOpenSubst pairs) fun) args of + = case analyse (substExpr subst fun) args of Nothing -> -- pprTrace "Bale out! exprIsConApp_maybe" doc $ Nothing Just ans -> -- pprTrace "Woo-hoo! exprIsConApp_maybe" doc $ Just ans where + subst = mkOpenSubst in_scope pairs -- doc = vcat [ppr fun, ppr expr, ppr pairs, ppr args]