summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorsimonpj@microsoft.com <unknown>2008-12-05 10:50:02 +0000
committersimonpj@microsoft.com <unknown>2008-12-05 10:50:02 +0000
commit6f547477aba779646caa7043d65825c59f10256b (patch)
tree70e96ba9b4251a0fb67eb45613c18d457cb2c3b2 /compiler
parentd56631cb57511f95eece9e61972e142a0d9e812c (diff)
downloadhaskell-6f547477aba779646caa7043d65825c59f10256b.tar.gz
Add static flag -fsimple-list-literals
The new static flag -fsimple-list-literals makes ExplicitList literals be desugared in the straightforward way, rather than using 'build' as now. See SLPJ comments with Note [Desugaring explicit lists]. I don't expect this flag to be used by users (hence no docs). It's just there to let me try the performance effects of switching on and off.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/deSugar/DsExpr.lhs20
-rw-r--r--compiler/main/StaticFlagParser.hs4
-rw-r--r--compiler/main/StaticFlags.hs5
3 files changed, 26 insertions, 3 deletions
diff --git a/compiler/deSugar/DsExpr.lhs b/compiler/deSugar/DsExpr.lhs
index b91380dcbc..6126b6302e 100644
--- a/compiler/deSugar/DsExpr.lhs
+++ b/compiler/deSugar/DsExpr.lhs
@@ -47,6 +47,7 @@ import CoreUtils
import MkCore
import DynFlags
+import StaticFlags
import CostCentre
import Id
import PrelInfo
@@ -609,6 +610,23 @@ allocation in some nofib programs. Specifically
Of course, if rules aren't turned on then there is pretty much no
point doing this fancy stuff, and it may even be harmful.
+
+=======> Note by SLPJ Dec 08.
+
+I'm unconvinced that we should *ever* generate a build for an explicit
+list. See the comments in GHC.Base about the foldr/cons rule, which
+points out that (foldr k z [a,b,c]) may generate *much* less code than
+(a `k` b `k` c `k` z).
+
+Furthermore generating builds messes up the LHS of RULES.
+Example: the foldr/single rule in GHC.Base
+ foldr k z [x] = ...
+We do not want to generate a build invocation on the LHS of this RULE!
+
+To test this I've added a (static) flag -fsimple-list-literals, which
+makes all list literals be generated via the simple route.
+
+
\begin{code}
dsExplicitList :: PostTcType -> [LHsExpr Id] -> DsM CoreExpr
@@ -616,7 +634,7 @@ dsExplicitList :: PostTcType -> [LHsExpr Id] -> DsM CoreExpr
dsExplicitList elt_ty xs = do
dflags <- getDOptsDs
xs' <- mapM dsLExpr xs
- if not (dopt Opt_EnableRewriteRules dflags)
+ if opt_SimpleListLiterals || not (dopt Opt_EnableRewriteRules dflags)
then return $ mkListExpr elt_ty xs'
else mkBuildExpr elt_ty (mkSplitExplicitList (thisPackage dflags) xs')
where
diff --git a/compiler/main/StaticFlagParser.hs b/compiler/main/StaticFlagParser.hs
index e68a111a84..0ed93563bd 100644
--- a/compiler/main/StaticFlagParser.hs
+++ b/compiler/main/StaticFlagParser.hs
@@ -159,8 +159,7 @@ static_flags = [
Supported
-- Pass all remaining "-f<blah>" options to hsc
- , Flag "f" (AnySuffixPred (isStaticFlag) addOpt)
- Supported
+ , Flag "f" (AnySuffixPred isStaticFlag addOpt) Supported
]
isStaticFlag :: String -> Bool
@@ -178,6 +177,7 @@ isStaticFlag f =
"fno-hi-version-check",
"dno-black-holing",
"fno-state-hack",
+ "fsimple-list-literals",
"fno-ds-multi-tyvar",
"fruntime-types",
"fno-pre-inlining",
diff --git a/compiler/main/StaticFlags.hs b/compiler/main/StaticFlags.hs
index 2398c20086..99f3f84ccd 100644
--- a/compiler/main/StaticFlags.hs
+++ b/compiler/main/StaticFlags.hs
@@ -43,6 +43,7 @@ module StaticFlags (
-- optimisation opts
opt_DsMultiTyVar,
opt_NoStateHack,
+ opt_SimpleListLiterals,
opt_SpecInlineJoinPoints,
opt_CprOff,
opt_SimplNoPreInlining,
@@ -227,8 +228,12 @@ opt_DsMultiTyVar = not (lookUp (fsLit "-fno-ds-multi-tyvar"))
opt_SpecInlineJoinPoints :: Bool
opt_SpecInlineJoinPoints = lookUp (fsLit "-fspec-inline-join-points")
+opt_SimpleListLiterals :: Bool
+opt_SimpleListLiterals = lookUp (fsLit "-fsimple-list-literals")
+
opt_NoStateHack :: Bool
opt_NoStateHack = lookUp (fsLit "-fno-state-hack")
+
opt_CprOff :: Bool
opt_CprOff = lookUp (fsLit "-fcpr-off")
-- Switch off CPR analysis in the new demand analyser