summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2013-10-18 13:51:56 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2013-10-18 13:51:56 +0100
commitd43bf5d8f8474724faba818627e7e3b920bcdb2e (patch)
tree699c4b61e768d5d4765fb052fc13a4a3f05ce427 /compiler
parent4fa1efe3f1feab103f11fbddc08bccf924ef4ef1 (diff)
downloadhaskell-d43bf5d8f8474724faba818627e7e3b920bcdb2e.tar.gz
Comments about control-flow optimisation
Diffstat (limited to 'compiler')
-rw-r--r--compiler/cmm/CmmContFlowOpt.hs17
1 files changed, 9 insertions, 8 deletions
diff --git a/compiler/cmm/CmmContFlowOpt.hs b/compiler/cmm/CmmContFlowOpt.hs
index b816a0c674..f39ab3c62b 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