[project @ 2005-10-14 11:22:41 by simonpj]
[ghc-hetmet.git] / ghc / compiler / coreSyn / CoreUnfold.lhs
index a0050d5..d57f188 100644 (file)
@@ -23,7 +23,7 @@ module CoreUnfold (
        hasUnfolding, hasSomeUnfolding, neverUnfold,
 
        couldBeSmallEnoughToInline, 
-       certainlyWillInline, 
+       certainlyWillInline, smallEnoughToInline,
 
        callSiteInline
     ) where
@@ -38,7 +38,7 @@ import DynFlags               ( DynFlags, DynFlag(..), dopt )
 import CoreSyn
 import PprCore         ( pprCoreExpr )
 import OccurAnal       ( occurAnalyseExpr )
-import CoreUtils       ( exprIsValue, exprIsCheap, exprIsTrivial )
+import CoreUtils       ( exprIsHNF, exprIsCheap, exprIsTrivial )
 import Id              ( Id, idType, isId,
                          idUnfolding, globalIdDetails
                        )
@@ -51,7 +51,6 @@ import PrelNames      ( hasKey, buildIdKey, augmentIdKey )
 import Bag
 import FastTypes
 import Outputable
-import Util
 
 #if __GLASGOW_HASKELL__ >= 404
 import GLAEXTS         ( Int# )
@@ -72,7 +71,7 @@ mkUnfolding top_lvl expr
   = CoreUnfolding (occurAnalyseExpr expr)
                  top_lvl
 
-                 (exprIsValue expr)
+                 (exprIsHNF expr)
                        -- Already evaluated
 
                  (exprIsCheap expr)
@@ -460,6 +459,12 @@ certainlyWillInline (CoreUnfolding _ _ _ is_cheap (UnfoldIfGoodArgs n_vals _ siz
   = is_cheap && size - (n_vals +1) <= opt_UF_UseThreshold
 certainlyWillInline other
   = False
+
+smallEnoughToInline :: Unfolding -> Bool
+smallEnoughToInline (CoreUnfolding _ _ _ _ (UnfoldIfGoodArgs _ _ size _))
+  = size <= opt_UF_UseThreshold
+smallEnoughToInline other
+  = False
 \end{code}
 
 %************************************************************************
@@ -520,7 +525,7 @@ callSiteInline dflags active_inline inline_call occ id arg_infos interesting_con
          | otherwise = case occ of
                                IAmDead              -> pprTrace "callSiteInline: dead" (ppr id) False
                                IAmALoopBreaker      -> False
-                               OneOcc in_lam _ _    -> (not in_lam || is_cheap) && consider_safe True
+                               --OneOcc in_lam _ _    -> (not in_lam || is_cheap) && consider_safe True
                                other                -> is_cheap && consider_safe False
                -- we consider even the once-in-one-branch
                -- occurrences, because they won't all have been
@@ -551,7 +556,7 @@ callSiteInline dflags active_inline inline_call occ id arg_infos interesting_con
 
                  where
                    some_benefit = or arg_infos || really_interesting_cont || 
-                                  (not is_top && (once || (n_vals_wanted > 0 && enough_args)))
+                                  (not is_top && ({- once || -} (n_vals_wanted > 0 && enough_args)))
                                -- [was (once && not in_lam)]
                -- If it occurs more than once, there must be
                -- something interesting about some argument, or the