mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-05 02:07:16 +00:00
Remove dead code in GVN: now that SimplifyInstruction is called
systematically, CollapsePhi will always return null here. Note that CollapsePhi did an extra check, isSafeReplacement, which the SimplifyInstruction logic does not do. I think that check was bogus - I guess we will soon find out! (It was originally added in commit 41998 without a testcase). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119456 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6678e7b6eb
commit
d32c4a1756
@ -701,7 +701,6 @@ namespace {
|
||||
bool processBlock(BasicBlock *BB);
|
||||
void dump(DenseMap<uint32_t, Value*>& d);
|
||||
bool iterateOnFunction(Function &F);
|
||||
Value *CollapsePhi(PHINode* p);
|
||||
bool performPRE(Function& F);
|
||||
Value *lookupNumber(BasicBlock *BB, uint32_t num);
|
||||
void cleanupGlobalSets();
|
||||
@ -733,33 +732,6 @@ void GVN::dump(DenseMap<uint32_t, Value*>& d) {
|
||||
errs() << "}\n";
|
||||
}
|
||||
|
||||
static bool isSafeReplacement(PHINode* p, Instruction *inst) {
|
||||
if (!isa<PHINode>(inst))
|
||||
return true;
|
||||
|
||||
for (Instruction::use_iterator UI = p->use_begin(), E = p->use_end();
|
||||
UI != E; ++UI)
|
||||
if (PHINode* use_phi = dyn_cast<PHINode>(*UI))
|
||||
if (use_phi->getParent() == inst->getParent())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Value *GVN::CollapsePhi(PHINode *PN) {
|
||||
Value *ConstVal = PN->hasConstantValue(DT);
|
||||
if (!ConstVal) return 0;
|
||||
|
||||
Instruction *Inst = dyn_cast<Instruction>(ConstVal);
|
||||
if (!Inst)
|
||||
return ConstVal;
|
||||
|
||||
if (DT->dominates(Inst, PN))
|
||||
if (isSafeReplacement(PN, Inst))
|
||||
return Inst;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// IsValueFullyAvailableInBlock - Return true if we can prove that the value
|
||||
/// we're analyzing is fully available in the specified block. As we go, keep
|
||||
/// track of which blocks we know are fully alive in FullyAvailableBlocks. This
|
||||
@ -1954,21 +1926,8 @@ bool GVN::processInstruction(Instruction *I,
|
||||
return false;
|
||||
}
|
||||
|
||||
// Collapse PHI nodes
|
||||
if (PHINode* p = dyn_cast<PHINode>(I)) {
|
||||
Value *constVal = CollapsePhi(p);
|
||||
|
||||
if (constVal) {
|
||||
p->replaceAllUsesWith(constVal);
|
||||
if (MD && constVal->getType()->isPointerTy())
|
||||
MD->invalidateCachedPointerInfo(constVal);
|
||||
VN.erase(p);
|
||||
|
||||
toErase.push_back(p);
|
||||
} else {
|
||||
localAvail[I->getParent()]->table.insert(std::make_pair(Num, I));
|
||||
}
|
||||
|
||||
if (isa<PHINode>(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!
|
||||
|
Loading…
Reference in New Issue
Block a user