summaryrefslogtreecommitdiff
path: root/compiler/codeGen
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2015-09-21 09:14:33 +0100
committerSimon Marlow <marlowsd@gmail.com>2015-09-23 14:07:44 +0100
commit939a7d6367501d43be73f4e41db7395af1194989 (patch)
treee915a6cc270fca5e0b4c803b38e5467f9f4d61c3 /compiler/codeGen
parent65bf7baa81772b7f07a4c74d3510dbd2ef03592d (diff)
downloadhaskell-939a7d6367501d43be73f4e41db7395af1194989.tar.gz
Annotate CmmBranch with an optional likely target
Summary: This allows the code generator to give hints to later code generation steps about which branch is most likely to be taken. Right now it is only taken into account in one place: a special case in CmmContFlowOpt that swapped branches over to maximise the chance of fallthrough, which is now disabled when there is a likelihood setting. Test Plan: validate Reviewers: austin, simonpj, bgamari, ezyang, tibbe Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1273
Diffstat (limited to 'compiler/codeGen')
-rw-r--r--compiler/codeGen/StgCmmExpr.hs3
-rw-r--r--compiler/codeGen/StgCmmLayout.hs5
-rw-r--r--compiler/codeGen/StgCmmMonad.hs6
-rw-r--r--compiler/codeGen/StgCmmUtils.hs2
4 files changed, 9 insertions, 7 deletions
diff --git a/compiler/codeGen/StgCmmExpr.hs b/compiler/codeGen/StgCmmExpr.hs
index 747f71a630..29db20a765 100644
--- a/compiler/codeGen/StgCmmExpr.hs
+++ b/compiler/codeGen/StgCmmExpr.hs
@@ -876,7 +876,8 @@ emitEnter fun = do
; tscope <- getTickScope
; emit $
copyout <*>
- mkCbranch (cmmIsTagged dflags (CmmReg nodeReg)) lret lcall <*>
+ mkCbranch (cmmIsTagged dflags (CmmReg nodeReg))
+ lret lcall Nothing <*>
outOfLine lcall (the_call,tscope) <*>
mkLabel lret tscope <*>
copyin
diff --git a/compiler/codeGen/StgCmmLayout.hs b/compiler/codeGen/StgCmmLayout.hs
index c3d8873cfb..593dd6cc18 100644
--- a/compiler/codeGen/StgCmmLayout.hs
+++ b/compiler/codeGen/StgCmmLayout.hs
@@ -226,9 +226,10 @@ slowCall fun stg_args
(mkIntExpr dflags n_args)
tscope <- getTickScope
- emit (mkCbranch (cmmIsTagged dflags funv) is_tagged_lbl slow_lbl
+ emit (mkCbranch (cmmIsTagged dflags funv)
+ is_tagged_lbl slow_lbl (Just True)
<*> mkLabel is_tagged_lbl tscope
- <*> mkCbranch correct_arity fast_lbl slow_lbl
+ <*> mkCbranch correct_arity fast_lbl slow_lbl (Just True)
<*> mkLabel fast_lbl tscope
<*> fast_code
<*> mkBranch end_lbl
diff --git a/compiler/codeGen/StgCmmMonad.hs b/compiler/codeGen/StgCmmMonad.hs
index f7a13f9c98..1acf31b327 100644
--- a/compiler/codeGen/StgCmmMonad.hs
+++ b/compiler/codeGen/StgCmmMonad.hs
@@ -831,7 +831,7 @@ mkCmmIfThenElse e tbranch fbranch = do
endif <- newLabelC
tid <- newLabelC
fid <- newLabelC
- return $ catAGraphs [ mkCbranch e tid fid
+ return $ catAGraphs [ mkCbranch e tid fid Nothing
, mkLabel tid tscp, tbranch, mkBranch endif
, mkLabel fid tscp, fbranch, mkLabel endif tscp ]
@@ -839,14 +839,14 @@ mkCmmIfGoto :: CmmExpr -> BlockId -> FCode CmmAGraph
mkCmmIfGoto e tid = do
endif <- newLabelC
tscp <- getTickScope
- return $ catAGraphs [ mkCbranch e tid endif, mkLabel endif tscp ]
+ return $ catAGraphs [ mkCbranch e tid endif Nothing, mkLabel endif tscp ]
mkCmmIfThen :: CmmExpr -> CmmAGraph -> FCode CmmAGraph
mkCmmIfThen e tbranch = do
endif <- newLabelC
tid <- newLabelC
tscp <- getTickScope
- return $ catAGraphs [ mkCbranch e tid endif
+ return $ catAGraphs [ mkCbranch e tid endif Nothing
, mkLabel tid tscp, tbranch, mkLabel endif tscp ]
diff --git a/compiler/codeGen/StgCmmUtils.hs b/compiler/codeGen/StgCmmUtils.hs
index db771c2f9a..a03625262c 100644
--- a/compiler/codeGen/StgCmmUtils.hs
+++ b/compiler/codeGen/StgCmmUtils.hs
@@ -558,7 +558,7 @@ mk_float_switch :: Width -> CmmExpr -> BlockId
-> FCode CmmAGraph
mk_float_switch rep scrut deflt _bounds [(lit,blk)]
= do dflags <- getDynFlags
- return $ mkCbranch (cond dflags) deflt blk
+ return $ mkCbranch (cond dflags) deflt blk Nothing
where
cond dflags = CmmMachOp ne [scrut, CmmLit cmm_lit]
where