summaryrefslogtreecommitdiff
path: root/compiler/simplCore
diff options
context:
space:
mode:
authorIan Lynagh <ian@well-typed.com>2012-10-09 00:27:28 +0100
committerIan Lynagh <ian@well-typed.com>2012-10-09 12:32:04 +0100
commit0a768bcbe6f7238d0bcdddd85fe24c99189453a0 (patch)
treea1e75804cc73c1f88fb3deae9fa7aaf0aaa75753 /compiler/simplCore
parent9c6223dd780b5a41be98702a583a1b7229841305 (diff)
downloadhaskell-0a768bcbe6f7238d0bcdddd85fe24c99189453a0.tar.gz
Make the opt_UF_* static flags dynamic
I also removed the default values from the "Discounts and thresholds" note: most of them were no longer up-to-date. Along the way I added FloatSuffix to the argument parser, analogous to IntSuffix.
Diffstat (limited to 'compiler/simplCore')
-rw-r--r--compiler/simplCore/LiberateCase.lhs13
-rw-r--r--compiler/simplCore/SimplUtils.lhs6
-rw-r--r--compiler/simplCore/Simplify.lhs22
3 files changed, 24 insertions, 17 deletions
diff --git a/compiler/simplCore/LiberateCase.lhs b/compiler/simplCore/LiberateCase.lhs
index 35bfb5fcc1..9f83043740 100644
--- a/compiler/simplCore/LiberateCase.lhs
+++ b/compiler/simplCore/LiberateCase.lhs
@@ -168,7 +168,7 @@ libCaseBind env (Rec pairs)
rhs_small_enough id rhs -- Note [Small enough]
= idArity id > 0 -- Note [Only functions!]
- && maybe True (\size -> couldBeSmallEnoughToInline size rhs)
+ && maybe True (\size -> couldBeSmallEnoughToInline (lc_dflags env) size rhs)
(bombOutSize env)
\end{code}
@@ -366,9 +366,7 @@ topLevel = 0
\begin{code}
data LibCaseEnv
= LibCaseEnv {
- lc_size :: Maybe Int, -- Bomb-out size for deciding if
- -- potential liberatees are too big.
- -- (passed in from cmd-line args)
+ lc_dflags :: DynFlags,
lc_lvl :: LibCaseLevel, -- Current level
-- The level is incremented when (and only when) going
@@ -405,13 +403,16 @@ data LibCaseEnv
initEnv :: DynFlags -> LibCaseEnv
initEnv dflags
- = LibCaseEnv { lc_size = liberateCaseThreshold dflags,
+ = LibCaseEnv { lc_dflags = dflags,
lc_lvl = 0,
lc_lvl_env = emptyVarEnv,
lc_rec_env = emptyVarEnv,
lc_scruts = [] }
+-- Bomb-out size for deciding if
+-- potential liberatees are too big.
+-- (passed in from cmd-line args)
bombOutSize :: LibCaseEnv -> Maybe Int
-bombOutSize = lc_size
+bombOutSize = liberateCaseThreshold . lc_dflags
\end{code}
diff --git a/compiler/simplCore/SimplUtils.lhs b/compiler/simplCore/SimplUtils.lhs
index 87aefbab89..a5ed3976bd 100644
--- a/compiler/simplCore/SimplUtils.lhs
+++ b/compiler/simplCore/SimplUtils.lhs
@@ -922,14 +922,14 @@ story for now.
\begin{code}
postInlineUnconditionally
- :: SimplEnv -> TopLevelFlag
+ :: DynFlags -> SimplEnv -> TopLevelFlag
-> OutId -- The binder (an InId would be fine too)
-- (*not* a CoVar)
-> OccInfo -- From the InId
-> OutExpr
-> Unfolding
-> Bool
-postInlineUnconditionally env top_lvl bndr occ_info rhs unfolding
+postInlineUnconditionally dflags env top_lvl bndr occ_info rhs unfolding
| not active = False
| isWeakLoopBreaker occ_info = False -- If it's a loop-breaker of any kind, don't inline
-- because it might be referred to "earlier"
@@ -952,7 +952,7 @@ postInlineUnconditionally env top_lvl bndr occ_info rhs unfolding
-- This is very important in practice; e.g. wheel-seive1 doubles
-- in allocation if you miss this out
OneOcc in_lam _one_br int_cxt -- OneOcc => no code-duplication issue
- -> smallEnoughToInline unfolding -- Small enough to dup
+ -> smallEnoughToInline dflags unfolding -- Small enough to dup
-- ToDo: consider discount on smallEnoughToInline if int_cxt is true
--
-- NB: Do NOT inline arbitrarily big things, even if one_br is True
diff --git a/compiler/simplCore/Simplify.lhs b/compiler/simplCore/Simplify.lhs
index f76fec1033..df301421c0 100644
--- a/compiler/simplCore/Simplify.lhs
+++ b/compiler/simplCore/Simplify.lhs
@@ -654,7 +654,8 @@ completeBind env top_lvl old_bndr new_bndr new_rhs
-- Simplify the unfolding
; new_unfolding <- simplUnfolding env top_lvl old_bndr final_rhs old_unf
- ; if postInlineUnconditionally env top_lvl new_bndr occ_info
+ ; dflags <- getDynFlags
+ ; if postInlineUnconditionally dflags env top_lvl new_bndr occ_info
final_rhs new_unfolding
-- Inline and discard the binding
@@ -749,7 +750,8 @@ simplUnfolding env top_lvl id _
_other -- Happens for INLINABLE things
-> let bottoming = isBottomingId id
in bottoming `seq` -- See Note [Force bottoming field]
- return (mkUnfolding src' is_top_lvl bottoming expr')
+ do dflags <- getDynFlags
+ return (mkUnfolding dflags src' is_top_lvl bottoming expr')
-- If the guidance is UnfIfGoodArgs, this is an INLINABLE
-- unfolding, and we need to make sure the guidance is kept up
-- to date with respect to any changes in the unfolding.
@@ -762,7 +764,8 @@ simplUnfolding env top_lvl id _
simplUnfolding _ top_lvl id new_rhs _
= let bottoming = isBottomingId id
in bottoming `seq` -- See Note [Force bottoming field]
- return (mkUnfolding InlineRhs (isTopLevel top_lvl) bottoming new_rhs)
+ do dflags <- getDynFlags
+ return (mkUnfolding dflags InlineRhs (isTopLevel top_lvl) bottoming new_rhs)
-- We make an unfolding *even for loop-breakers*.
-- Reason: (a) It might be useful to know that they are WHNF
-- (b) In TidyPgm we currently assume that, if we want to
@@ -2008,23 +2011,26 @@ simplAlt env scrut imposs_deflt_cons case_bndr' cont' (DEFAULT, bndrs, rhs)
simplAlt env scrut _ case_bndr' cont' (LitAlt lit, bndrs, rhs)
= ASSERT( null bndrs )
- do { let env' = addBinderUnfolding env scrut case_bndr'
- (mkSimpleUnfolding (Lit lit))
+ do { dflags <- getDynFlags
+ ; let env' = addBinderUnfolding env scrut case_bndr'
+ (mkSimpleUnfolding dflags (Lit lit))
; rhs' <- simplExprC env' rhs cont'
; return (LitAlt lit, [], rhs') }
simplAlt env scrut _ case_bndr' cont' (DataAlt con, vs, rhs)
- = do { -- Deal with the pattern-bound variables
+ = do { dflags <- getDynFlags
+
+ -- Deal with the pattern-bound variables
-- Mark the ones that are in ! positions in the
-- data constructor as certainly-evaluated.
-- NB: simplLamBinders preserves this eval info
- let vs_with_evals = add_evals (dataConRepStrictness con)
+ ; let vs_with_evals = add_evals (dataConRepStrictness con)
; (env', vs') <- simplLamBndrs env vs_with_evals
-- Bind the case-binder to (con args)
; let inst_tys' = tyConAppArgs (idType case_bndr')
con_args = map Type inst_tys' ++ varsToCoreExprs vs'
- unf = mkSimpleUnfolding (mkConApp con con_args)
+ unf = mkSimpleUnfolding dflags (mkConApp con con_args)
env'' = addBinderUnfolding env' scrut case_bndr' unf
; rhs' <- simplExprC env'' rhs cont'