From: simonpj Date: Mon, 19 Mar 2001 16:20:44 +0000 (+0000) Subject: [project @ 2001-03-19 16:20:44 by simonpj] X-Git-Tag: Approximately_9120_patches~2376 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=4fb9c8aa14742cf98c1c0f2be1f98841fad145b8;p=ghc-hetmet.git [project @ 2001-03-19 16:20:44 by simonpj] ------------------------------------ Be more gung-ho about INLINE pragmas ------------------------------------ When we see {-# INLINE f #-} f = g $ h should we inline f inside a lambda? Previously we said 'no' because f looks like a redex, but that's a great mistake sometimes. So this commit is more gung-ho: if you say INLINE that's what you get. The changes are to exprIsDupable and exprIsCheap. --- diff --git a/ghc/compiler/coreSyn/CoreUtils.lhs b/ghc/compiler/coreSyn/CoreUtils.lhs index 6905cb7..00d5723 100644 --- a/ghc/compiler/coreSyn/CoreUtils.lhs +++ b/ghc/compiler/coreSyn/CoreUtils.lhs @@ -333,10 +333,11 @@ exprIsAtom other = False \begin{code} -exprIsDupable (Type _) = True -exprIsDupable (Var v) = True -exprIsDupable (Lit lit) = litIsDupable lit -exprIsDupable (Note _ e) = exprIsDupable e +exprIsDupable (Type _) = True +exprIsDupable (Var v) = True +exprIsDupable (Lit lit) = litIsDupable lit +exprIsDupable (Note InlineMe e) = True +exprIsDupable (Note _ e) = exprIsDupable e exprIsDupable expr = go expr 0 where @@ -383,6 +384,7 @@ exprIsCheap :: CoreExpr -> Bool exprIsCheap (Lit lit) = True exprIsCheap (Type _) = True exprIsCheap (Var _) = True +exprIsCheap (Note InlineMe e) = True exprIsCheap (Note _ e) = exprIsCheap e exprIsCheap (Lam x e) = if isId x then True else exprIsCheap e exprIsCheap (Case e _ alts) = exprIsCheap e && @@ -518,9 +520,11 @@ as values, even if their arguments are non-trivial; map (...redex...) is a value Because `seq` on such things completes immediately -A worry: constructors with unboxed args: +A possible worry: constructors with unboxed args: C (f x :: Int#) -Suppose (f x) diverges; then C (f x) is not a value. +Suppose (f x) diverges; then C (f x) is not a value. True, but +this form is illegal (see the invariants in CoreSyn). Args of unboxed +type must be ok-for-speculation (or trivial). \begin{code} exprIsValue :: CoreExpr -> Bool -- True => Value-lambda, constructor, PAP