[project @ 2001-03-19 16:20:44 by simonpj]
[ghc-hetmet.git] / ghc / compiler / coreSyn / CoreUtils.lhs
index 1fa614a..00d5723 100644 (file)
@@ -315,6 +315,7 @@ exprIsAtom :: CoreExpr -> Bool
 exprIsAtom (Var v)    = True   -- primOpIsDupable?
 exprIsAtom (Lit lit)  = True
 exprIsAtom (Type ty)  = True
+exprIsAtom (Note (SCC _) e) = False
 exprIsAtom (Note _ e) = exprIsAtom e
 exprIsAtom other      = False
 \end{code}
@@ -332,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
@@ -382,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 && 
@@ -517,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