summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/BranchFolding.cpp
diff options
context:
space:
mode:
authorChristopher Lamb <christopher.lamb@gmail.com>2007-12-10 07:24:06 +0000
committerChristopher Lamb <christopher.lamb@gmail.com>2007-12-10 07:24:06 +0000
commitd202e03fe56ca9c95ee20060f293f77cc2d77160 (patch)
treefe2ba577968d536779164c0d7a7197c4c1d0edcd /llvm/lib/CodeGen/BranchFolding.cpp
parentb6a8cfea24b0ab70a5d04e1feab8fb8501026d69 (diff)
downloadbcm5719-llvm-d202e03fe56ca9c95ee20060f293f77cc2d77160.tar.gz
bcm5719-llvm-d202e03fe56ca9c95ee20060f293f77cc2d77160.zip
Improve branch folding by recgonizing that explict successor relationships impact the value of fall-through choices.
llvm-svn: 44785
Diffstat (limited to 'llvm/lib/CodeGen/BranchFolding.cpp')
-rw-r--r--llvm/lib/CodeGen/BranchFolding.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp
index d4b1e90fd54..0f8c6629bae 100644
--- a/llvm/lib/CodeGen/BranchFolding.cpp
+++ b/llvm/lib/CodeGen/BranchFolding.cpp
@@ -775,6 +775,11 @@ static bool IsBetterFallthrough(MachineBasicBlock *MBB1,
// optimize branches that branch to either a return block or an assert block
// into a fallthrough to the return.
if (MBB1->empty() || MBB2->empty()) return false;
+
+ // If there is a clear successor ordering we make sure that one block
+ // will fall through to the next
+ if (MBB1->isSuccessor(MBB2)) return true;
+ if (MBB2->isSuccessor(MBB1)) return false;
MachineInstr *MBB1I = --MBB1->end();
MachineInstr *MBB2I = --MBB2->end();
OpenPOWER on IntegriCloud