summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/BranchFolding.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-10-22 00:03:58 +0000
committerDan Gohman <gohman@apple.com>2009-10-22 00:03:58 +0000
commitff97acd8f1c9a0b067ad97e4987e0e48d0d8f39e (patch)
tree502895a183e183e4e3043a4bcb84dab0f42155ac /llvm/lib/CodeGen/BranchFolding.cpp
parent649bf5c04b6010f8b1a4cf8fadab941cf0baf420 (diff)
downloadbcm5719-llvm-ff97acd8f1c9a0b067ad97e4987e0e48d0d8f39e.tar.gz
bcm5719-llvm-ff97acd8f1c9a0b067ad97e4987e0e48d0d8f39e.zip
Revert the main portion of r31856. It was causing BranchFolding
to break up CFG diamonds by banishing one of the blocks to the end of the function, which is bad for code density and branch size. This does pessimize MultiSource/Benchmarks/Ptrdist/yacr2, the benchmark cited as the reason for the change, however I've examined the code and it looks more like a case of gaming a particular branch than of being generally applicable. llvm-svn: 84803
Diffstat (limited to 'llvm/lib/CodeGen/BranchFolding.cpp')
-rw-r--r--llvm/lib/CodeGen/BranchFolding.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp
index f9abeacbdbb..66c5aa5ff78 100644
--- a/llvm/lib/CodeGen/BranchFolding.cpp
+++ b/llvm/lib/CodeGen/BranchFolding.cpp
@@ -945,15 +945,15 @@ bool BranchFolder::OptimizeBlock(MachineBasicBlock *MBB) {
}
}
- // If this block doesn't fall through (e.g. it ends with an uncond branch or
- // has no successors) and if the pred falls through into this block, and if
- // it would otherwise fall through into the block after this, move this
- // block to the end of the function.
+ // If this block has no successors (e.g. it is a return block or ends with
+ // a call to a no-return function like abort or __cxa_throw) and if the pred
+ // falls through into this block, and if it would otherwise fall through
+ // into the block after this, move this block to the end of the function.
//
// We consider it more likely that execution will stay in the function (e.g.
// due to loops) than it is to exit it. This asserts in loops etc, moving
// the assert condition out of the loop body.
- if (!PriorCond.empty() && PriorFBB == 0 &&
+ if (MBB->succ_empty() && !PriorCond.empty() && PriorFBB == 0 &&
MachineFunction::iterator(PriorTBB) == FallThrough &&
!CanFallThrough(MBB)) {
bool DoTransform = true;
OpenPOWER on IntegriCloud