summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-04-22 06:36:15 +0000
committerChris Lattner <sabre@nondot.org>2008-04-22 06:36:15 +0000
commite369c35a8420a4b51a337cab2c7ee288ffe5b789 (patch)
tree54db6d973f3edac3fe8ae77fb69f0c6225b55038 /llvm/lib/Transforms
parent3cc28ce1edd448064654676cce1d865f611b1a35 (diff)
downloadbcm5719-llvm-e369c35a8420a4b51a337cab2c7ee288ffe5b789.tar.gz
bcm5719-llvm-e369c35a8420a4b51a337cab2c7ee288ffe5b789.zip
refactor some code, no functionality change.
llvm-svn: 50094
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/JumpThreading.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
index b68a969bc16..fd75c90d9a4 100644
--- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
@@ -57,6 +57,8 @@ namespace {
bool runOnFunction(Function &F);
bool ThreadBlock(BasicBlock *BB);
void ThreadEdge(BasicBlock *BB, BasicBlock *PredBB, BasicBlock *SuccBB);
+
+ bool ProcessJumpOnPHI(PHINode *PN);
};
char JumpThreading::ID = 0;
RegisterPass<JumpThreading> X("jump-threading", "Jump Threading");
@@ -158,8 +160,17 @@ bool JumpThreading::ThreadBlock(BasicBlock *BB) {
// See if this is a phi node in the current block.
PHINode *PN = dyn_cast<PHINode>(Condition);
- if (!PN || PN->getParent() != BB) return false;
+ if (PN && PN->getParent() == BB)
+ return ProcessJumpOnPHI(PN);
+ return false;
+}
+
+/// ProcessJumpOnPHI - We have a conditional branch of switch on a PHI node in
+/// the current block. See if there are any simplifications we can do based on
+/// inputs to the phi node.
+///
+bool JumpThreading::ProcessJumpOnPHI(PHINode *PN) {
// See if the phi node has any constant values. If so, we can determine where
// the corresponding predecessor will branch.
unsigned PredNo = ~0U;
@@ -177,6 +188,7 @@ bool JumpThreading::ThreadBlock(BasicBlock *BB) {
return false;
// See if the cost of duplicating this block is low enough.
+ BasicBlock *BB = PN->getParent();
unsigned JumpThreadCost = getJumpThreadDuplicationCost(BB);
if (JumpThreadCost > Threshold) {
DOUT << " Not threading BB '" << BB->getNameStart()
@@ -210,7 +222,6 @@ bool JumpThreading::ThreadBlock(BasicBlock *BB) {
".thr_comm", this);
}
-
DOUT << " Threading edge from '" << PredBB->getNameStart() << "' to '"
<< SuccBB->getNameStart() << "' with cost: " << JumpThreadCost
<< ", across block:\n "
OpenPOWER on IntegriCloud