diff options
author | klebinger.andreas@gmx.at <klebinger.andreas@gmx.at> | 2018-06-07 13:26:19 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-06-07 18:06:29 -0400 |
commit | efea32cf2c41d35f2ba5a79bf70cc7768b7b0fd5 (patch) | |
tree | d19e185a39cb2c5dc4862d0056c1bcc78d725f47 /compiler | |
parent | 767536ccf95d8352d146b6544857b28d9c42937e (diff) | |
download | haskell-efea32cf2c41d35f2ba5a79bf70cc7768b7b0fd5.tar.gz |
Check if both branches of an Cmm if have the same target.
This for some reason or the other and makes it into the final
binary. I've added the check to ContFlowOpt as that seems
like a logical place for this.
In a regular nofib run there were 30 occurences of this pattern.
Test Plan: ci
Reviewers: bgamari, simonmar, dfeuer, jrtc27, tdammers
Reviewed By: bgamari, simonmar
Subscribers: tdammers, dfeuer, rwbarton, thomie, carter
GHC Trac Issues: #15188
Differential Revision: https://phabricator.haskell.org/D4740
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/cmm/CmmContFlowOpt.hs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/compiler/cmm/CmmContFlowOpt.hs b/compiler/cmm/CmmContFlowOpt.hs index 9f091da8c2..146c4f3019 100644 --- a/compiler/cmm/CmmContFlowOpt.hs +++ b/compiler/cmm/CmmContFlowOpt.hs @@ -254,8 +254,8 @@ blockConcat splitting_procs g@CmmGraph { g_entry = entry_id } -- unconditional jump to a block that can be shortcut. | Nothing <- callContinuation_maybe last = let oldSuccs = successors last - newSuccs = successors swapcond_last - in ( mapInsert bid (blockJoinTail head swapcond_last) blocks + newSuccs = successors rewrite_last + in ( mapInsert bid (blockJoinTail head rewrite_last) blocks , shortcut_map , if oldSuccs == newSuccs then backEdges @@ -283,8 +283,13 @@ blockConcat splitting_procs g@CmmGraph { g_entry = entry_id } Just b | Just dest <- canShortcut b -> dest _otherwise -> l - -- See Note [Invert Cmm conditionals] - swapcond_last + rewrite_last + -- Sometimes we can get rid of the conditional completely. + | CmmCondBranch _cond t f _l <- shortcut_last + , t == f + = CmmBranch t + + -- See Note [Invert Cmm conditionals] | CmmCondBranch cond t f l <- shortcut_last , hasOnePredecessor t -- inverting will make t a fallthrough , likelyTrue l || (numPreds f > 1) |