From 81de68e651377e8f31c83b1919a64a17a6567233 Mon Sep 17 00:00:00 2001 From: Roman Leshchinskiy Date: Fri, 14 Dec 2007 00:27:19 +0000 Subject: [PATCH] Separate and optional size thresholds for SpecConstr and LiberateCase This patch replaces -fspec-threshold by -fspec-constr-threshold and -fliberate-case-threshold. The thresholds can be disabled by -fno-spec-constr-threshold and -fno-liberate-case-threshold. --- compiler/main/DynFlags.hs | 17 ++++++++++++----- compiler/simplCore/LiberateCase.lhs | 7 ++++--- compiler/specialise/SpecConstr.lhs | 9 +++++---- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index c8e999a..44e2aea 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -301,7 +301,8 @@ data DynFlags = DynFlags { maxSimplIterations :: Int, -- max simplifier iterations ruleCheck :: Maybe String, - specThreshold :: Int, -- Threshold for function specialisation + specConstrThreshold :: Maybe Int, -- Threshold for SpecConstr + liberateCaseThreshold :: Maybe Int, -- Threshold for LiberateCase stolen_x86_regs :: Int, cmdlineHcIncludes :: [String], -- -#includes @@ -478,7 +479,8 @@ defaultDynFlags = optLevel = 0, maxSimplIterations = 4, ruleCheck = Nothing, - specThreshold = 200, + specConstrThreshold = Just 200, + liberateCaseThreshold = Just 200, stolen_x86_regs = 4, cmdlineHcIncludes = [], importPaths = ["."], @@ -1140,9 +1142,14 @@ dynamic_flags = [ , ( "fmax-simplifier-iterations", IntSuffix (\n -> upd (\dfs -> dfs{ maxSimplIterations = n })) ) - -- liberate-case-threshold is an old flag for '-fspec-threshold' - , ( "fspec-threshold", IntSuffix (\n -> upd (\dfs -> dfs{ specThreshold = n }))) - , ( "fliberate-case-threshold", IntSuffix (\n -> upd (\dfs -> dfs{ specThreshold = n }))) + , ( "fspec-constr-threshold", IntSuffix (\n -> + upd (\dfs -> dfs{ specConstrThreshold = Just n }))) + , ( "fno-spec-constr-threshold", NoArg ( + upd (\dfs -> dfs{ specConstrThreshold = Nothing }))) + , ( "fliberate-case-threshold", IntSuffix (\n -> + upd (\dfs -> dfs{ liberateCaseThreshold = Just n }))) + , ( "fno-liberate-case-threshold", NoArg ( + upd (\dfs -> dfs{ liberateCaseThreshold = Nothing }))) , ( "frule-check", SepArg (\s -> upd (\dfs -> dfs{ ruleCheck = Just s }))) , ( "fcontext-stack" , IntSuffix $ \n -> upd $ \dfs -> dfs{ ctxtStkDepth = n }) diff --git a/compiler/simplCore/LiberateCase.lhs b/compiler/simplCore/LiberateCase.lhs index c29d217..9c51103 100644 --- a/compiler/simplCore/LiberateCase.lhs +++ b/compiler/simplCore/LiberateCase.lhs @@ -195,7 +195,8 @@ libCaseBind env (Rec pairs) rhs_small_enough (id,rhs) = idArity id > 0 -- Note [Only functions!] - && couldBeSmallEnoughToInline (bombOutSize env) rhs + && maybe True (\size -> couldBeSmallEnoughToInline size rhs) + (bombOutSize env) \end{code} @@ -349,7 +350,7 @@ topLevel = 0 \begin{code} data LibCaseEnv = LibCaseEnv { - lc_size :: Int, -- Bomb-out size for deciding if + lc_size :: Maybe Int, -- Bomb-out size for deciding if -- potential liberatees are too big. -- (passed in from cmd-line args) @@ -377,7 +378,7 @@ data LibCaseEnv initEnv :: DynFlags -> LibCaseEnv initEnv dflags - = LibCaseEnv { lc_size = specThreshold dflags, + = LibCaseEnv { lc_size = liberateCaseThreshold dflags, lc_lvl = 0, lc_lvl_env = emptyVarEnv, lc_rec_env = emptyVarEnv, diff --git a/compiler/specialise/SpecConstr.lhs b/compiler/specialise/SpecConstr.lhs index 0478d2e..d1c7499 100644 --- a/compiler/specialise/SpecConstr.lhs +++ b/compiler/specialise/SpecConstr.lhs @@ -456,9 +456,9 @@ specConstrProgram dflags us binds %************************************************************************ \begin{code} -data ScEnv = SCE { sc_size :: Int, -- Size threshold +data ScEnv = SCE { sc_size :: Maybe Int, -- Size threshold - sc_subst :: Subst, -- Current substitution + sc_subst :: Subst, -- Current substitution sc_how_bound :: HowBoundEnv, -- Binds interesting non-top-level variables @@ -491,7 +491,7 @@ instance Outputable Value where --------------------- initScEnv dflags - = SCE { sc_size = specThreshold dflags, + = SCE { sc_size = specConstrThreshold dflags, sc_subst = emptySubst, sc_how_bound = emptyVarEnv, sc_vals = emptyVarEnv } @@ -824,7 +824,8 @@ scExpr' env e@(App _ _) ---------------------- scBind :: ScEnv -> CoreBind -> UniqSM (ScEnv, ScUsage, CoreBind) scBind env (Rec prs) - | not (all (couldBeSmallEnoughToInline (sc_size env)) rhss) + | Just threshold <- sc_size env + , not (all (couldBeSmallEnoughToInline threshold) rhss) -- No specialisation = do { let (rhs_env,bndrs') = extendRecBndrs env bndrs ; (rhs_usgs, rhss') <- mapAndUnzipUs (scExpr rhs_env) rhss -- 1.7.10.4