[commit: ghc] master: Comments about control-flow optimisation (d43bf5d)
git at git.haskell.org
git at git.haskell.org
Fri Oct 18 13:35:35 UTC 2013
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/d43bf5d8f8474724faba818627e7e3b920bcdb2e/ghc
>---------------------------------------------------------------
commit d43bf5d8f8474724faba818627e7e3b920bcdb2e
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date: Fri Oct 18 13:51:56 2013 +0100
Comments about control-flow optimisation
>---------------------------------------------------------------
d43bf5d8f8474724faba818627e7e3b920bcdb2e
compiler/cmm/CmmContFlowOpt.hs | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/compiler/cmm/CmmContFlowOpt.hs b/compiler/cmm/CmmContFlowOpt.hs
index b816a0c..f39ab3c 100644
--- a/compiler/cmm/CmmContFlowOpt.hs
+++ b/compiler/cmm/CmmContFlowOpt.hs
@@ -56,25 +56,26 @@ cmmCfgOptsProc _ top = top
-- This optimisation does three things:
--
-- - If a block finishes with an unconditional branch, then we may
--- be able to concatenate the block it points to and remove the
--- branch. We do this either if the destination block is small
--- (e.g. just another branch), or if this is the only jump to
--- this particular destination block.
+-- be able to duplicate the block it points to and remove the
+-- branch. We do this if either
+-- a) the destination block is small (e.g. just another branch), or
+-- b) this is the only jump to this particular destination block.
--
-- - If a block finishes in a call whose continuation block is a
-- goto, then we can shortcut the destination, making the
--- continuation block the destination of the goto.
+-- destination of the goto into the continuation. E.g.
+-- call g returns to L ==> call g returns to M
+-- L: goto M M: ...blah...
+-- M: ...blah...
-- (but see Note [shortcut call returns])
--
--- - removes any unreachable blocks from the graph. This is a side
+-- - Remove any unreachable blocks from the graph. This is a side
-- effect of starting with a postorder DFS traversal of the graph
---
-- Both transformations are improved by working from the end of the
-- graph towards the beginning, because we may be able to perform many
-- shortcuts in one go.
-
-- We need to walk over the blocks from the end back to the
-- beginning. We are going to maintain the "current" graph
-- (BlockEnv CmmBlock) as we go, and also a mapping from BlockId
More information about the ghc-commits
mailing list