summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGergo ERDI <gergo@erdi.hu>2021-11-16 11:16:20 +0800
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-11-25 05:01:59 -0500
commitbe0a9470ad76f7dc63e05a84215a2a4d0fd833fd (patch)
tree58a98d21fa1963260e1b9ededf4ab249680cd49c
parentc9cead1ff7c5d3304543d52522ef4da96b802652 (diff)
downloadhaskell-be0a9470ad76f7dc63e05a84215a2a4d0fd833fd.tar.gz
Add specific optimization flag for Cmm control flow analysis (#20500)
-rw-r--r--compiler/GHC/Cmm/Pipeline.hs2
-rw-r--r--compiler/GHC/Driver/Flags.hs1
-rw-r--r--compiler/GHC/Driver/Session.hs2
-rw-r--r--docs/users_guide/using-optimisation.rst12
4 files changed, 15 insertions, 2 deletions
diff --git a/compiler/GHC/Cmm/Pipeline.hs b/compiler/GHC/Cmm/Pipeline.hs
index 481f2bb545..7de0ce0cb8 100644
--- a/compiler/GHC/Cmm/Pipeline.hs
+++ b/compiler/GHC/Cmm/Pipeline.hs
@@ -142,7 +142,7 @@ cpsTop logger platform dflags proc =
----------- Control-flow optimisations -----------------------------
g <- {-# SCC "cmmCfgOpts(2)" #-}
- return $ if optLevel dflags >= 1
+ return $ if gopt Opt_CmmControlFlow dflags
then map (cmmCfgOptsProc splitting_proc_points) g
else g
g <- return (map removeUnreachableBlocksProc g)
diff --git a/compiler/GHC/Driver/Flags.hs b/compiler/GHC/Driver/Flags.hs
index 341851c81b..e7205a8620 100644
--- a/compiler/GHC/Driver/Flags.hs
+++ b/compiler/GHC/Driver/Flags.hs
@@ -212,6 +212,7 @@ data GeneralFlag
| Opt_CmmSink
| Opt_CmmStaticPred
| Opt_CmmElimCommonBlocks
+ | Opt_CmmControlFlow
| Opt_AsmShortcutting
| Opt_OmitYields
| Opt_FunToThunk -- allow GHC.Core.Opt.WorkWrap.Utils.mkWorkerArgs to remove all value lambdas
diff --git a/compiler/GHC/Driver/Session.hs b/compiler/GHC/Driver/Session.hs
index 7c5d0c71a5..e4c86e94c9 100644
--- a/compiler/GHC/Driver/Session.hs
+++ b/compiler/GHC/Driver/Session.hs
@@ -3376,6 +3376,7 @@ fFlagsDeps = [
flagSpec "alignment-sanitisation" Opt_AlignmentSanitisation,
flagSpec "num-constant-folding" Opt_NumConstantFolding,
flagSpec "fast-pap-calls" Opt_FastPAPCalls,
+ flagSpec "cmm-control-flow" Opt_CmmControlFlow,
flagSpec "show-warning-groups" Opt_ShowWarnGroups,
flagSpec "hide-source-paths" Opt_HideSourcePaths,
flagSpec "show-loaded-modules" Opt_ShowLoadedModules,
@@ -3854,6 +3855,7 @@ optLevelFlags -- see Note [Documenting optimisation flags]
, ([1,2], Opt_CSE)
, ([1,2], Opt_StgCSE)
, ([2], Opt_StgLiftLams)
+ , ([1,2], Opt_CmmControlFlow)
, ([1,2], Opt_EnableRewriteRules)
-- Off for -O0. Otherwise we desugar list literals
diff --git a/docs/users_guide/using-optimisation.rst b/docs/users_guide/using-optimisation.rst
index 6d33c5b5bc..5fa9a81a5e 100644
--- a/docs/users_guide/using-optimisation.rst
+++ b/docs/users_guide/using-optimisation.rst
@@ -227,6 +227,17 @@ by saying ``-fno-wombat``.
loops and hot code paths. This information is then used by the
register allocation and code layout passes.
+.. ghc-flag:: -fcmm-control-flow
+ :shortdesc: Enable control flow optimisation in the Cmm backend. Implied by :ghc-flag:`-O`.
+ :type: dynamic
+ :reverse: -fno-cmm-control-flow
+ :category:
+
+ :default: on
+
+ Enables some control flow optimisations in the Cmm code
+ generator, merging basic blocks and avoiding jumps right after jumps.
+
.. ghc-flag:: -fasm-shortcutting
:shortdesc: Enable shortcutting on assembly. Implied by :ghc-flag:`-O2`.
:type: dynamic
@@ -1554,4 +1565,3 @@ by saying ``-fno-wombat``.
This flag sets the size (in bytes) threshold above which the second approach
is used. You can disable the second approach entirely by setting the
threshold to 0.
-