[project @ 2001-07-19 15:32:05 by apt]
authorapt <unknown>
Thu, 19 Jul 2001 15:32:05 +0000 (15:32 +0000)
committerapt <unknown>
Thu, 19 Jul 2001 15:32:05 +0000 (15:32 +0000)
reinstate inlinings that are completely within an INLINE

ghc/compiler/simplCore/SimplMonad.lhs
ghc/compiler/simplCore/Simplify.lhs

index 19faf99..70112ed 100644 (file)
@@ -49,7 +49,8 @@ module SimplMonad (
 
 #include "HsVersions.h"
 
-import Id              ( Id, mkSysLocal, idType, idUnfolding, isDataConWrapId )
+import Id              ( Id, mkSysLocal, idType, idUnfolding, isDataConWrapId,
+                         isGlobalId )
 import CoreSyn
 import CoreUnfold      ( isCompulsoryUnfolding )
 import CoreUtils       ( exprOkForSpeculation )
@@ -61,7 +62,8 @@ import VarSet
 import OrdList
 import qualified Subst
 import Subst           ( Subst, mkSubst, substEnv, 
-                         InScopeSet, mkInScopeSet, substInScope
+                         InScopeSet, mkInScopeSet, substInScope,
+                         isInScope 
                        )
 import Type             ( Type, isUnLiftedType )
 import UniqSupply      ( uniqsFromSupply, uniqFromSupply, splitUniqSupply,
@@ -629,18 +631,21 @@ setBlackList black_list m dflags env us sc
 getBlackList :: SimplM BlackList
 getBlackList dflags env us sc = (seBlackList env, us, sc)
 
-noInlineBlackList :: BlackList
+noInlineBlackList :: SimplM BlackList
        -- Inside inlinings, black list anything that is in scope or imported.
        -- except for things that must be unfolded (Compulsory)
        -- and data con wrappers.  The latter is a hack, like the one in
        -- SimplCore.simplRules, to make wrappers inline in rule LHSs.
        -- We may as well do the same here.
-noInlineBlackList v = not (isCompulsoryUnfolding (idUnfolding v)) &&
-                     not (isDataConWrapId v)
-       -- NB: this implementation means that even inlinings *completely within*
-       -- an INLINE won't happen, which is perhaps overkill. 
-       -- An earlier verion had: (v `isInScope` subst) || not (isLocallyDefined v)
-       -- but it's more expensive, and it probably doesn't matter.
+noInlineBlackList dflags env us sc = (blacklisted,us,sc)
+       where blacklisted v =
+                 not (isCompulsoryUnfolding (idUnfolding v)) &&
+                 not (isDataConWrapId v) &&
+                 (v `isInScope` (seSubst env) || isGlobalId v)
+       -- NB: An earlier version omitted the last clause; this meant 
+       -- that even inlinings *completely within* an INLINE didn't happen. 
+       -- This was cheaper, and probably adequate, but produced awful code
+        -- for some dictionary constructions.
 \end{code}
 
 
index 1dc5ab0..638efec 100644 (file)
@@ -429,7 +429,8 @@ simplNote InlineCall e cont
 simplNote InlineMe e cont
   | keep_inline cont           -- Totally boring continuation
   =                            -- Don't inline inside an INLINE expression
-    setBlackList noInlineBlackList (simplExpr e)       `thenSmpl` \ e' ->
+    noInlineBlackList                  `thenSmpl` \ bl ->
+    setBlackList bl (simplExpr e)      `thenSmpl` \ e' ->
     rebuild (mkInlineMe e') cont
 
   | otherwise          -- Dissolve the InlineMe note if there's
@@ -947,7 +948,8 @@ simplifyArgs is_data_con args cont_ty thing_inside
                -- Even though x get's an occurrence of 'many', its RHS looks cheap,
                -- and there's a good chance it'll get inlined back into C's RHS. Urgh!
   = getBlackList                               `thenSmpl` \ old_bl ->
-    setBlackList noInlineBlackList             $
+    noInlineBlackList                          `thenSmpl` \ ni_bl ->
+    setBlackList ni_bl                         $
     go args                                    $ \ args' ->
     setBlackList old_bl                                $
     thing_inside args'