mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-15 19:24:33 +00:00
Use information already present in the ValueTable to fast-fail when we know there won't be a value number match. This speeds up GVN on a case where there are very few redundancies by ~25%.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53108 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -166,6 +166,7 @@ namespace {
|
|||||||
void setAliasAnalysis(AliasAnalysis* A) { AA = A; }
|
void setAliasAnalysis(AliasAnalysis* A) { AA = A; }
|
||||||
void setMemDep(MemoryDependenceAnalysis* M) { MD = M; }
|
void setMemDep(MemoryDependenceAnalysis* M) { MD = M; }
|
||||||
void setDomTree(DominatorTree* D) { DT = D; }
|
void setDomTree(DominatorTree* D) { DT = D; }
|
||||||
|
uint32_t getNextUnusedValueNumber() { return nextValueNumber; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1058,11 +1059,12 @@ bool GVN::processInstruction(Instruction *I,
|
|||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t nextNum = VN.getNextUnusedValueNumber();
|
||||||
unsigned num = VN.lookup_or_add(I);
|
unsigned num = VN.lookup_or_add(I);
|
||||||
|
|
||||||
// Allocations are always uniquely numbered, so we can save time and memory
|
// Allocations are always uniquely numbered, so we can save time and memory
|
||||||
// by fast failing them.
|
// by fast failing them.
|
||||||
if (isa<AllocationInst>(I)) {
|
if (isa<AllocationInst>(I) || isa<TerminatorInst>(I)) {
|
||||||
localAvail[I->getParent()]->table.insert(std::make_pair(num, I));
|
localAvail[I->getParent()]->table.insert(std::make_pair(num, I));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1082,6 +1084,13 @@ bool GVN::processInstruction(Instruction *I,
|
|||||||
} else {
|
} else {
|
||||||
localAvail[I->getParent()]->table.insert(std::make_pair(num, I));
|
localAvail[I->getParent()]->table.insert(std::make_pair(num, I));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the number we were assigned was a brand new VN, then we don't
|
||||||
|
// need to do a lookup to see if the number already exists
|
||||||
|
// somewhere in the domtree: it can't!
|
||||||
|
} else if (num == nextNum) {
|
||||||
|
localAvail[I->getParent()]->table.insert(std::make_pair(num, I));
|
||||||
|
|
||||||
// Perform value-number based elimination
|
// Perform value-number based elimination
|
||||||
} else if (Value* repl = lookupNumber(I->getParent(), num)) {
|
} else if (Value* repl = lookupNumber(I->getParent(), num)) {
|
||||||
// Remove it!
|
// Remove it!
|
||||||
@@ -1092,7 +1101,7 @@ bool GVN::processInstruction(Instruction *I,
|
|||||||
I->replaceAllUsesWith(repl);
|
I->replaceAllUsesWith(repl);
|
||||||
toErase.push_back(I);
|
toErase.push_back(I);
|
||||||
return true;
|
return true;
|
||||||
} else if (!I->isTerminator()) {
|
} else {
|
||||||
localAvail[I->getParent()]->table.insert(std::make_pair(num, I));
|
localAvail[I->getParent()]->table.insert(std::make_pair(num, I));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user