summaryrefslogtreecommitdiff
path: root/compiler/simplCore
diff options
context:
space:
mode:
authorsimonpj@microsoft.com <unknown>2009-04-03 08:46:34 +0000
committersimonpj@microsoft.com <unknown>2009-04-03 08:46:34 +0000
commitb71760aac3a1b2e7d772a4c0457ff3f19eac8631 (patch)
tree7c6f1c8297f9be18cb68cf18ff36872868308e90 /compiler/simplCore
parent9060e51e4773bdff1829d17e3f7c42edb910d805 (diff)
downloadhaskell-b71760aac3a1b2e7d772a4c0457ff3f19eac8631.tar.gz
Adjust inlining heursitics
This patch is the result of a long series of nofib-based experiments to improve GHC's inlining heuristics. In the end, I'm not sure how worthwhile it all was: I only got a 1% decrease in code size 1% decrease in allocation and I don't trust the runtime statistics enough to quote. Still, in doing all this I tidied up the code quite a bit, and I understand it much better now, so I'm going to commit it. The main changes are in CoreUnfold, which has lots of new comments. Other changes: - litSize moves from Literal to CoreUnfold - interestingArg moves from SimplUtils to CoreUnfold - the default unfolding threshold (in StaticFlags) reduces from 8 to 6 (since the size calculation has changed a bit)
Diffstat (limited to 'compiler/simplCore')
-rw-r--r--compiler/simplCore/SimplUtils.lhs41
1 files changed, 4 insertions, 37 deletions
diff --git a/compiler/simplCore/SimplUtils.lhs b/compiler/simplCore/SimplUtils.lhs
index 4ddd8ca411..48787dceb0 100644
--- a/compiler/simplCore/SimplUtils.lhs
+++ b/compiler/simplCore/SimplUtils.lhs
@@ -246,42 +246,8 @@ splitInlineCont _ = Nothing
\end{code}
-\begin{code}
-interestingArg :: OutExpr -> Bool
- -- An argument is interesting if it has *some* structure
- -- We are here trying to avoid unfolding a function that
- -- is applied only to variables that have no unfolding
- -- (i.e. they are probably lambda bound): f x y z
- -- There is little point in inlining f here.
-interestingArg (Var v) = hasSomeUnfolding (idUnfolding v)
- -- Was: isValueUnfolding (idUnfolding v')
- -- But that seems over-pessimistic
- || isDataConWorkId v
- -- This accounts for an argument like
- -- () or [], which is definitely interesting
-interestingArg (Type _) = False
-interestingArg (App fn (Type _)) = interestingArg fn
-interestingArg (Note _ a) = interestingArg a
-
--- Idea (from Sam B); I'm not sure if it's a good idea, so commented out for now
--- interestingArg expr | isUnLiftedType (exprType expr)
--- -- Unlifted args are only ever interesting if we know what they are
--- = case expr of
--- Lit lit -> True
--- _ -> False
-
-interestingArg _ = True
- -- Consider let x = 3 in f x
- -- The substitution will contain (x -> ContEx 3), and we want to
- -- to say that x is an interesting argument.
- -- But consider also (\x. f x y) y
- -- The substitution will contain (x -> ContEx y), and we want to say
- -- that x is not interesting (assuming y has no unfolding)
-\end{code}
-
-
-Comment about interestingCallContext
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Note [Interesting call context]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We want to avoid inlining an expression where there can't possibly be
any gain, such as in an argument position. Hence, if the continuation
is interesting (eg. a case scrutinee, application etc.) then we
@@ -316,6 +282,7 @@ default case.
\begin{code}
interestingCallContext :: SimplCont -> CallCtxt
+-- See Note [Interesting call context]
interestingCallContext cont
= interesting cont
where
@@ -354,7 +321,7 @@ interestingCallContext cont
-------------------
mkArgInfo :: Id
-> Int -- Number of value args
- -> SimplCont -- Context of the cal
+ -> SimplCont -- Context of the call
-> ArgInfo
mkArgInfo fun n_val_args call_cont