aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-12-24 19:32:55 +0000
committerChris Lattner <sabre@nondot.org>2007-12-24 19:32:55 +0000
commitebe807597f3ee67f6c5f9cd462ba325b579a2680 (patch)
tree67314ced755085cf68cf6a8f14860be5a09c4536 /lib/Transforms
parent44cb8efdc19207fdb12c261821fbcb0516b8bcbd (diff)
downloadexternal_llvm-ebe807597f3ee67f6c5f9cd462ba325b579a2680.zip
external_llvm-ebe807597f3ee67f6c5f9cd462ba325b579a2680.tar.gz
external_llvm-ebe807597f3ee67f6c5f9cd462ba325b579a2680.tar.bz2
add a -backedge-hack llc-beta option to codegenprepare.
When specified, don't split backedges of single-bb loops. This helps address PR1877 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45344 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/CodeGenPrepare.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp
index 7c7352d..f31183c 100644
--- a/lib/Transforms/Scalar/CodeGenPrepare.cpp
+++ b/lib/Transforms/Scalar/CodeGenPrepare.cpp
@@ -37,6 +37,8 @@ using namespace llvm;
namespace {
cl::opt<bool> OptExtUses("optimize-ext-uses",
cl::init(true), cl::Hidden);
+ // LLCBETA option.
+ cl::opt<bool> DontHackBackedge("backedge-hack", cl::Hidden);
}
namespace {
@@ -264,7 +266,7 @@ void CodeGenPrepare::EliminateMostlyEmptyBlock(BasicBlock *BB) {
}
-/// SplitEdgeNicely - Split the critical edge from TI to it's specified
+/// SplitEdgeNicely - Split the critical edge from TI to its specified
/// successor if it will improve codegen. We only do this if the successor has
/// phi nodes (otherwise critical edges are ok). If there is already another
/// predecessor of the succ that is empty (and thus has no phi nodes), use it
@@ -275,9 +277,15 @@ static void SplitEdgeNicely(TerminatorInst *TI, unsigned SuccNum, Pass *P) {
assert(isa<PHINode>(Dest->begin()) &&
"This should only be called if Dest has a PHI!");
+ // As a hack, never split backedges of loops. Even though the copy for any
+ // PHIs inserted on the backedge would be dead for exits from the loop, we
+ // assume that the cost of *splitting* the backedge would be too high.
+ if (DontHackBackedge && Dest == TIBB)
+ return;
+
/// TIPHIValues - This array is lazily computed to determine the values of
/// PHIs in Dest that TI would provide.
- std::vector<Value*> TIPHIValues;
+ SmallVector<Value*, 32> TIPHIValues;
// Check to see if Dest has any blocks that can be used as a split edge for
// this terminator.