Change MemDep::getNonLocalDependency to return its results as

a smallvector instead of a DenseMap.  This speeds up GVN by 5%
on 403.gcc.

llvm-svn: 60255
This commit is contained in:
Chris Lattner 2008-11-29 21:33:22 +00:00
parent b8ec75bc35
commit 1c6b62eb4d
3 changed files with 13 additions and 13 deletions

View File

@ -175,7 +175,8 @@ namespace llvm {
/// This method assumes the instruction returns a "nonlocal" dependency
/// within its own block.
void getNonLocalDependency(Instruction *QueryInst,
DenseMap<BasicBlock*, MemDepResult> &Result);
SmallVectorImpl<std::pair<BasicBlock*,
MemDepResult> > &Result);
/// removeInstruction - Remove an instruction from the dependence analysis,
/// updating the dependence of instructions that previously depended on it.

View File

@ -104,8 +104,10 @@ getCallSiteDependency(CallSite C, BasicBlock::iterator ScanIt,
/// This method assumes the instruction returns a "nonlocal" dependency
/// within its own block.
///
void MemoryDependenceAnalysis::getNonLocalDependency(Instruction *QueryInst,
DenseMap<BasicBlock*, MemDepResult> &Result) {
void MemoryDependenceAnalysis::
getNonLocalDependency(Instruction *QueryInst,
SmallVectorImpl<std::pair<BasicBlock*,
MemDepResult> > &Result) {
assert(getDependency(QueryInst).isNonLocal() &&
"getNonLocalDependency should only be used on insts with non-local deps!");
DenseMap<BasicBlock*, DepResultTy> &Cache = NonLocalDeps[QueryInst];
@ -128,10 +130,7 @@ void MemoryDependenceAnalysis::getNonLocalDependency(Instruction *QueryInst,
} else {
// Seed DirtyBlocks with each of the preds of QueryInst's block.
BasicBlock *QueryBB = QueryInst->getParent();
// FIXME: use range insertion/append.
for (pred_iterator PI = pred_begin(QueryBB), E = pred_end(QueryBB);
PI != E; ++PI)
DirtyBlocks.push_back(*PI);
DirtyBlocks.append(pred_begin(QueryBB), pred_end(QueryBB));
NumUncacheNonlocal++;
}
@ -173,7 +172,7 @@ void MemoryDependenceAnalysis::getNonLocalDependency(Instruction *QueryInst,
// Copy the result into the output set.
for (DenseMap<BasicBlock*, DepResultTy>::iterator I = Cache.begin(),
E = Cache.end(); I != E; ++I)
Result[I->first] = ConvToResult(I->second);
Result.push_back(std::make_pair(I->first, ConvToResult(I->second)));
}
/// getDependency - Return the instruction on which a memory operation

View File

@ -495,11 +495,11 @@ uint32_t ValueTable::lookup_or_add(Value* V) {
}
DenseMap<BasicBlock*, MemDepResult> deps;
SmallVector<std::pair<BasicBlock*, MemDepResult>, 32> deps;
MD->getNonLocalDependency(C, deps);
CallInst* cdep = 0;
for (DenseMap<BasicBlock*, MemDepResult>
for (SmallVector<std::pair<BasicBlock*, MemDepResult>, 32>
::iterator I = deps.begin(), E = deps.end(); I != E; ++I) {
if (I->second.isNone()) {
valueNumbering.insert(std::make_pair(V, nextValueNumber));
@ -871,7 +871,7 @@ bool GVN::processNonLocalLoad(LoadInst* L,
MemoryDependenceAnalysis& MD = getAnalysis<MemoryDependenceAnalysis>();
// Find the non-local dependencies of the load
DenseMap<BasicBlock*, MemDepResult> deps;
SmallVector<std::pair<BasicBlock*, MemDepResult>, 32> deps;
MD.getNonLocalDependency(L, deps);
// If we had to process more than one hundred blocks to find the
@ -885,8 +885,8 @@ bool GVN::processNonLocalLoad(LoadInst* L,
DenseMap<BasicBlock*, Value*> repl;
// Filter out useless results (non-locals, etc)
for (DenseMap<BasicBlock*, MemDepResult>::iterator I = deps.begin(),
E = deps.end(); I != E; ++I) {
for (SmallVector<std::pair<BasicBlock*, MemDepResult>, 32>::iterator
I = deps.begin(), E = deps.end(); I != E; ++I) {
if (I->second.isNone()) {
repl[I->first] = UndefValue::get(L->getType());
continue;