[llvm-commits] [llvm] r50094 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
Chris Lattner
sabre at nondot.org
Mon Apr 21 23:36:15 PDT 2008
Author: lattner
Date: Tue Apr 22 01:36:15 2008
New Revision: 50094
URL: http://llvm.org/viewvc/llvm-project?rev=50094&view=rev
Log:
refactor some code, no functionality change.
Modified:
llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=50094&r1=50093&r2=50094&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Tue Apr 22 01:36:15 2008
@@ -57,6 +57,8 @@
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 @@
// 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 @@
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 @@
".thr_comm", this);
}
-
DOUT << " Threading edge from '" << PredBB->getNameStart() << "' to '"
<< SuccBB->getNameStart() << "' with cost: " << JumpThreadCost
<< ", across block:\n "
More information about the llvm-commits
mailing list