summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/LCSSA.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2006-05-28 19:33:28 +0000
committerOwen Anderson <resistor@mac.com>2006-05-28 19:33:28 +0000
commitbd82277cbbd93f8704a6bf52c4842c5e71fb675f (patch)
treec05bd80c9cd5ea7ba1a15d2bd6a8954cd70023ac /lib/Transforms/Utils/LCSSA.cpp
parent492196c89f922cf3a4cc6b426cd1a34414dfb447 (diff)
downloadllvm-bd82277cbbd93f8704a6bf52c4842c5e71fb675f.tar.gz
llvm-bd82277cbbd93f8704a6bf52c4842c5e71fb675f.tar.bz2
llvm-bd82277cbbd93f8704a6bf52c4842c5e71fb675f.tar.xz
Major think-o. Iterate over all live out-of-loop values, and perform the
other calculations on each individually, rather than trying to delay it and do them all at the end. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28527 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/LCSSA.cpp')
-rw-r--r--lib/Transforms/Utils/LCSSA.cpp72
1 files changed, 36 insertions, 36 deletions
diff --git a/lib/Transforms/Utils/LCSSA.cpp b/lib/Transforms/Utils/LCSSA.cpp
index 1142c87f0e..31e480321c 100644
--- a/lib/Transforms/Utils/LCSSA.cpp
+++ b/lib/Transforms/Utils/LCSSA.cpp
@@ -42,7 +42,8 @@
using namespace llvm;
namespace {
- static Statistic<> NumLCSSA("lcssa", "Number of live out of a loop");
+ static Statistic<> NumLCSSA("lcssa",
+ "Number of live out of a loop variables");
class LCSSA : public FunctionPass {
public:
@@ -125,50 +126,49 @@ bool LCSSA::visitSubloop(Loop* L) {
++PI)
phi->addIncoming(*I, *PI);
}
- }
- // Calculate the IDF of these LCSSA Phi nodes, inserting new Phi's where
- // necessary. Keep track of these new Phi's in DFPhis.
- std::map<BasicBlock*, PHINode*> DFPhis;
- for (std::vector<PHINode*>::iterator I = workList.begin(),
- E = workList.end(); I != E; ++I) {
+ // Calculate the IDF of these LCSSA Phi nodes, inserting new Phi's where
+ // necessary. Keep track of these new Phi's in DFPhis.
+ std::map<BasicBlock*, PHINode*> DFPhis;
+ for (std::vector<PHINode*>::iterator DFI = workList.begin(),
+ E = workList.end(); DFI != E; ++DFI) {
- // Get the current Phi's DF, and insert Phi nodes. Add these new
- // nodes to our worklist.
- DominanceFrontier::const_iterator it = DF->find((*I)->getParent());
- if (it != DF->end()) {
- const DominanceFrontier::DomSetType &S = it->second;
- for (DominanceFrontier::DomSetType::const_iterator P = S.begin(),
+ // Get the current Phi's DF, and insert Phi nodes. Add these new
+ // nodes to our worklist.
+ DominanceFrontier::const_iterator it = DF->find((*DFI)->getParent());
+ if (it != DF->end()) {
+ const DominanceFrontier::DomSetType &S = it->second;
+ for (DominanceFrontier::DomSetType::const_iterator P = S.begin(),
PE = S.end(); P != PE; ++P) {
- if (DFPhis[*P] == 0) {
- // Still doesn't have operands...
- PHINode *phi = new PHINode((*I)->getType(), "lcssa");
- (*P)->getInstList().insert((*P)->front(), phi);
- DFPhis[*P] = phi;
+ if (DFPhis[*P] == 0) {
+ // Still doesn't have operands...
+ PHINode *phi = new PHINode((*DFI)->getType(), "lcssa");
+ (*P)->getInstList().insert((*P)->front(), phi);
+ DFPhis[*P] = phi;
- workList.push_back(phi);
+ workList.push_back(phi);
+ }
}
}
- }
- // Get the predecessor blocks of the current Phi, and use them to hook up
- // the operands of the current Phi to any members of DFPhis that dominate
- // it. This is a nop for the Phis inserted directly in the exit blocks,
- // since they are not dominated by any members of DFPhis.
- for (pred_iterator PI = pred_begin((*I)->getParent()),
- E = pred_end((*I)->getParent()); PI != E; ++PI)
- for (std::map<BasicBlock*, PHINode*>::iterator MI = DFPhis.begin(),
- ME = DFPhis.end(); MI != ME; ++MI)
- if (DT->getNode((*MI).first)->dominates(DT->getNode(*PI))) {
- (*I)->addIncoming((*MI).second, *PI);
+ // Get the predecessor blocks of the current Phi, and use them to hook up
+ // the operands of the current Phi to any members of DFPhis that dominate
+ // it. This is a nop for the Phis inserted directly in the exit blocks,
+ // since they are not dominated by any members of DFPhis.
+ for (pred_iterator PI = pred_begin((*DFI)->getParent()),
+ E = pred_end((*DFI)->getParent()); PI != E; ++PI)
+ for (std::map<BasicBlock*, PHINode*>::iterator MI = DFPhis.begin(),
+ ME = DFPhis.end(); MI != ME; ++MI)
+ if (DT->getNode((*MI).first)->dominates(DT->getNode(*PI))) {
+ (*DFI)->addIncoming((*MI).second, *PI);
- // Since dominate() is not cheap, don't do it more than we have to.
- break;
- }
- }
-
- // FIXME: Should update all uses.
+ // Since dominate() is not cheap, don't do it more than we have to.
+ break;
+ }
+ }
+ // FIXME: Should update all uses.
+ }
return true; // FIXME: Should be more intelligent in our return value.
}