summaryrefslogtreecommitdiff
path: root/compiler/main/DynFlags.hs
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2016-12-09 10:26:34 -0500
committerBen Gamari <ben@smart-cactus.org>2016-12-09 10:27:34 -0500
commitd3b546b1a6058f26d5659c7f2000a7b25b7ea2ba (patch)
tree96929e66f77af1c5f9ce451c032a24e988de57b3 /compiler/main/DynFlags.hs
parent61932cd3eb0d5d22cb35d118fb9f87298881cd77 (diff)
downloadhaskell-d3b546b1a6058f26d5659c7f2000a7b25b7ea2ba.tar.gz
Scrutinee Constant Folding
This patch introduces new rules to perform constant folding through case-expressions. E.g., ``` case t -# 10# of _ { ===> case t of _ { 5# -> e1 15# -> e1 8# -> e2 18# -> e2 DEFAULT -> e DEFAULT -> e ``` The initial motivation is that it allows "Merge Nested Cases" optimization to kick in and to further simplify the code (see Trac #12877). Currently we recognize the following operations for Word# and Int#: Add, Sub, Xor, Not and Negate (for Int# only). Test Plan: validate Reviewers: simonpj, austin, bgamari Reviewed By: simonpj, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2762 GHC Trac Issues: #12877
Diffstat (limited to 'compiler/main/DynFlags.hs')
-rw-r--r--compiler/main/DynFlags.hs3
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index cbf247c49d..d7cde29557 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -445,6 +445,7 @@ data GeneralFlag
| Opt_IgnoreAsserts
| Opt_DoEtaReduction
| Opt_CaseMerge
+ | Opt_CaseFolding -- Constant folding through case-expressions
| Opt_UnboxStrictFields
| Opt_UnboxSmallStrictFields
| Opt_DictsCheap
@@ -3561,6 +3562,7 @@ fFlagsDeps = [
flagSpec "building-cabal-package" Opt_BuildingCabalPackage,
flagSpec "call-arity" Opt_CallArity,
flagSpec "case-merge" Opt_CaseMerge,
+ flagSpec "case-folding" Opt_CaseFolding,
flagSpec "cmm-elim-common-blocks" Opt_CmmElimCommonBlocks,
flagSpec "cmm-sink" Opt_CmmSink,
flagSpec "cse" Opt_CSE,
@@ -4012,6 +4014,7 @@ optLevelFlags -- see Note [Documenting optimisation flags]
, ([1,2], Opt_CallArity)
, ([1,2], Opt_CaseMerge)
+ , ([1,2], Opt_CaseFolding)
, ([1,2], Opt_CmmElimCommonBlocks)
, ([1,2], Opt_CmmSink)
, ([1,2], Opt_CSE)