From debf9165d1760f18f4e0339757a8a743333514fc Mon Sep 17 00:00:00 2001 From: simonpj Date: Thu, 14 Feb 2002 15:08:08 +0000 Subject: [PATCH] [project @ 2002-02-14 15:08:08 by simonpj] ------------------------------------------------- Undo an earlier hack in postInlineUnconditionally ------------------------------------------------- In an earlier era I made postInlineUnconditionally rather less aggressive; it didn't inline even trivial things unless they occurred just once. THis was a hack designed to avoid rules unexpectedly not firing. But now we have much more control over rules, through the phase numbering stuff, so I can undo the hack. Well, so I believe. Manuel, yell if your rules stop working! --- ghc/compiler/simplCore/SimplMonad.lhs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/ghc/compiler/simplCore/SimplMonad.lhs b/ghc/compiler/simplCore/SimplMonad.lhs index d3f10a0..266d9ec 100644 --- a/ghc/compiler/simplCore/SimplMonad.lhs +++ b/ghc/compiler/simplCore/SimplMonad.lhs @@ -71,7 +71,7 @@ import UniqSupply ( uniqsFromSupply, uniqFromSupply, splitUniqSupply, UniqSupply ) import FiniteMap -import BasicTypes ( TopLevelFlag, isTopLevel, +import BasicTypes ( TopLevelFlag, isTopLevel, isLoopBreaker, Activation, isActive, isAlwaysActive, OccInfo(..), isOneOcc ) @@ -862,16 +862,27 @@ story for now. \begin{code} postInlineUnconditionally :: SimplEnv -> OutId -> OccInfo -> OutExpr -> Bool postInlineUnconditionally env bndr occ_info rhs - = exprIsTrivial rhs && active && isOneOcc occ_info - -- We used to have (not loop_breaker && not (isExportedId bndr)) - -- instead of (isOneOcc occ_info). Indeed, you might suppose that + = exprIsTrivial rhs + && active + && not (isLoopBreaker occ_info) + && not (isExportedId bndr) + -- We used to have (isOneOcc occ_info) instead of + -- not (isLoopBreaker occ_info) && not (isExportedId bndr) + -- That was because a rather fragile use of rules got confused + -- if you inlined even a binding f=g e.g. We used to have + -- map = mapList + -- But now a more precise use of phases has eliminated this problem, + -- so the is_active test will do the job. I think. + -- + -- OLD COMMENT: (delete soon) + -- Indeed, you might suppose that -- there is nothing wrong with substituting for a trivial RHS, even -- if it occurs many times. But consider -- x = y -- h = _inline_me_ (...x...) -- Here we do *not* want to have x inlined, even though the RHS is -- trivial, becuase the contract for an INLINE pragma is "no inlining". - -- This is important in the rules for the Prelude (e.g. PrelEnum.eftInt). + -- This is important in the rules for the Prelude where active = case getMode env of SimplGently -> isAlwaysActive prag -- 1.7.10.4