1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 19:42:54 +02:00

Eliminate PHI nodes with constant values during normal GVN processing, even when

they're not related to eliminating a load.

llvm-svn: 41081
This commit is contained in:
Owen Anderson 2007-08-14 18:33:27 +00:00
parent d9a7b61a64
commit b970937b06

View File

@ -946,7 +946,27 @@ bool GVN::processInstruction(Instruction* I,
unsigned num = VN.lookup_or_add(I);
if (currAvail.test(num)) {
if (PHINode* p = dyn_cast<PHINode>(I)) {
Value* constVal = p->hasConstantValue();
if (constVal) {
if (Instruction* inst = dyn_cast<Instruction>(constVal)) {
DominatorTree &DT = getAnalysis<DominatorTree>();
if (DT.dominates(inst, p)) {
for (PhiMapType::iterator PI = phiMap.begin(), PE = phiMap.end();
PI != PE; ++PI)
if (PI->second.count(p))
PI->second.erase(p);
p->replaceAllUsesWith(inst);
toErase.push_back(p);
}
} else {
p->replaceAllUsesWith(constVal);
toErase.push_back(p);
}
}
} else if (currAvail.test(num)) {
Value* repl = find_leader(currAvail, num);
VN.erase(I);