[llvm-commits] CVS: llvm/lib/Transforms/Utils/LCSSA.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Jun 13 18:14:09 PDT 2006
Changes in directory llvm/lib/Transforms/Utils:
LCSSA.cpp updated: 1.22 -> 1.23
---
Log message:
Use the PotDoms map to memoize 'dominating value' lookup. With this patch,
LCSSA is still the slowest pass when gccas'ing 252.eon, but now it only takes
39s instead of 289s. :)
---
Diffs of the changes: (+14 -17)
LCSSA.cpp | 31 ++++++++++++++-----------------
1 files changed, 14 insertions(+), 17 deletions(-)
Index: llvm/lib/Transforms/Utils/LCSSA.cpp
diff -u llvm/lib/Transforms/Utils/LCSSA.cpp:1.22 llvm/lib/Transforms/Utils/LCSSA.cpp:1.23
--- llvm/lib/Transforms/Utils/LCSSA.cpp:1.22 Tue Jun 13 15:50:09 2006
+++ llvm/lib/Transforms/Utils/LCSSA.cpp Tue Jun 13 20:13:57 2006
@@ -74,8 +74,12 @@
private:
SetVector<Instruction*> getLoopValuesUsedOutsideLoop(Loop *L);
Instruction *getValueDominatingBlock(BasicBlock *BB,
+ std::map<BasicBlock*, Instruction*>& PotDoms) {
+ return getValueDominatingDTNode(DT->getNode(BB), PotDoms);
+ }
+ Instruction *getValueDominatingDTNode(DominatorTree::Node *Node,
std::map<BasicBlock*, Instruction*>& PotDoms);
-
+
/// inLoop - returns true if the given block is within the current loop
const bool inLoop(BasicBlock* B) {
return std::binary_search(LoopBlocks.begin(), LoopBlocks.end(), B);
@@ -237,8 +241,8 @@
}
}
} else {
- Value *NewVal = getValueDominatingBlock((*II)->getParent(), Phis);
- (*II)->replaceUsesOfWith(Instr, NewVal);
+ Value *NewVal = getValueDominatingBlock((*II)->getParent(), Phis);
+ (*II)->replaceUsesOfWith(Instr, NewVal);
}
}
}
@@ -275,19 +279,12 @@
/// getValueDominatingBlock - Return the value within the potential dominators
/// map that dominates the given block.
-Instruction *LCSSA::getValueDominatingBlock(BasicBlock *BB,
- std::map<BasicBlock*, Instruction*>& PotDoms) {
- DominatorTree::Node* bbNode = DT->getNode(BB);
- while (bbNode != 0) {
- std::map<BasicBlock*, Instruction*>::iterator I =
- PotDoms.find(bbNode->getBlock());
- if (I != PotDoms.end()) {
- return (*I).second;
- }
- bbNode = bbNode->getIDom();
- }
-
- assert(0 && "No dominating value found.");
+Instruction *LCSSA::getValueDominatingDTNode(DominatorTree::Node *Node,
+ std::map<BasicBlock*, Instruction*>& PotDoms) {
+ assert(Node != 0 && "Didn't find dom value?");
+ Instruction *&CacheSlot = PotDoms[Node->getBlock()];
+ if (CacheSlot) return CacheSlot;
- return 0;
+ // Otherwise, return the value of the idom and remember this for next time.
+ return CacheSlot = getValueDominatingDTNode(Node->getIDom(), PotDoms);
}
More information about the llvm-commits
mailing list