use SimplifyInstruction instead of reimplementing part of it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121757 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-12-14 07:20:29 +00:00
parent 995ba1bd49
commit 07ff3539f5

View File

@ -1172,17 +1172,14 @@ static bool FoldTwoEntryPHINode(PHINode *PN, const TargetData *TD) {
BasicBlock::iterator AfterPHIIt = BB->begin();
while (isa<PHINode>(AfterPHIIt)) {
PHINode *PN = cast<PHINode>(AfterPHIIt++);
if (PN->getIncomingValue(0) == PN->getIncomingValue(1)) {
if (PN->getIncomingValue(0) != PN)
PN->replaceAllUsesWith(PN->getIncomingValue(0));
else
PN->replaceAllUsesWith(UndefValue::get(PN->getType()));
} else if (!DominatesMergePoint(PN->getIncomingValue(0), BB,
&AggressiveInsts) ||
!DominatesMergePoint(PN->getIncomingValue(1), BB,
&AggressiveInsts)) {
return false;
if (Value *V = SimplifyInstruction(PN, TD)) {
PN->replaceAllUsesWith(V);
continue;
}
if (!DominatesMergePoint(PN->getIncomingValue(0), BB, &AggressiveInsts) ||
!DominatesMergePoint(PN->getIncomingValue(1), BB, &AggressiveInsts))
return false;
}
// If we all PHI nodes are promotable, check to make sure that all