[llvm-commits] [llvm] r52631 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp
Owen Anderson
resistor at mac.com
Mon Jun 23 10:49:45 PDT 2008
Author: resistor
Date: Mon Jun 23 12:49:45 2008
New Revision: 52631
URL: http://llvm.org/viewvc/llvm-project?rev=52631&view=rev
Log:
Tighten the conditions under which we do PRE, remove some unneeded code, and correct our preserved analyses list, since we
do now change the CFG by splitting critical edges during PRE.
Modified:
llvm/trunk/lib/Transforms/Scalar/GVN.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=52631&r1=52630&r2=52631&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Mon Jun 23 12:49:45 2008
@@ -719,10 +719,11 @@
// This transformation requires dominator postdominator info
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
- AU.setPreservesCFG();
AU.addRequired<DominatorTree>();
AU.addRequired<MemoryDependenceAnalysis>();
AU.addRequired<AliasAnalysis>();
+
+ AU.addPreserved<DominatorTree>();
AU.addPreserved<AliasAnalysis>();
AU.addPreserved<MemoryDependenceAnalysis>();
}
@@ -1019,7 +1020,11 @@
}
Value* GVN::lookupNumber(BasicBlock* BB, uint32_t num) {
- ValueNumberScope* locals = localAvail[BB];
+ DenseMap<BasicBlock*, ValueNumberScope*>::iterator I = localAvail.find(BB);
+ if (I == localAvail.end())
+ return 0;
+
+ ValueNumberScope* locals = I->second;
while (locals) {
DenseMap<uint32_t, Value*>::iterator I = locals->table.find(num);
@@ -1167,9 +1172,9 @@
for (BasicBlock::iterator BI = CurrentBlock->begin(),
BE = CurrentBlock->end(); BI != BE; ) {
- if (isa<AllocaInst>(BI) || isa<TerminatorInst>(BI) ||
- isa<LoadInst>(BI) || isa<StoreInst>(BI) ||
- isa<CallInst>(BI) || isa<PHINode>(BI)) {
+ if (isa<AllocationInst>(BI) || isa<TerminatorInst>(BI) ||
+ isa<PHINode>(BI) || BI->mayReadFromMemory() ||
+ BI->mayWriteToMemory()) {
BI++;
continue;
}
@@ -1282,13 +1287,6 @@
Phi->addIncoming(predMap[*PI], *PI);
VN.add(Phi, valno);
-
- // The newly created PHI completely replaces the old instruction,
- // so we need to update the maps to reflect this.
- DomTreeNode* DTN = getAnalysis<DominatorTree>()[CurrentBlock];
- for (DomTreeNode::iterator UI = DTN->begin(), UE = DTN->end();
- UI != UE; ++UI)
- localAvail[(*UI)->getBlock()]->table[valno] = Phi;
localAvail[CurrentBlock]->table[valno] = Phi;
BI->replaceAllUsesWith(Phi);
More information about the llvm-commits
mailing list