Revert 85634. It's breaking consumer-typeset (and others).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85641 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Evan Cheng
2009-10-31 01:28:06 +00:00
parent c933acf096
commit a4006c6dbf

View File

@@ -10981,24 +10981,22 @@ Instruction *InstCombiner::visitPHINode(PHINode &PN) {
} }
} }
// If there are multiple PHIs, sort their operands so that they all list // Sort the PHI node operands to match the pred iterator order. This will
// the blocks in the same order. This will help identical PHIs be eliminated // help identical PHIs be eliminated by other passes. Other passes shouldn't
// by other passes. Other passes shouldn't depend on this for correctness // depend on this for correctness however.
// however. unsigned i = 0;
PHINode *FirstPN = cast<PHINode>(PN.getParent()->begin()); for (pred_iterator PI = pred_begin(PN.getParent()),
if (&PN != FirstPN) PE = pred_end(PN.getParent()); PI != PE; ++PI, ++i)
for (unsigned i = 0, e = FirstPN->getNumIncomingValues(); i != e; ++i) { if (PN.getIncomingBlock(i) != *PI) {
unsigned j = PN.getBasicBlockIndex(*PI);
Value *VA = PN.getIncomingValue(i);
BasicBlock *BBA = PN.getIncomingBlock(i); BasicBlock *BBA = PN.getIncomingBlock(i);
BasicBlock *BBB = FirstPN->getIncomingBlock(i); Value *VB = PN.getIncomingValue(j);
if (BBA != BBB) { BasicBlock *BBB = PN.getIncomingBlock(j);
Value *VA = PN.getIncomingValue(i); PN.setIncomingBlock(i, BBB);
unsigned j = FirstPN->getBasicBlockIndex(BBA); PN.setIncomingValue(i, VB);
Value *VB = PN.getIncomingValue(j); PN.setIncomingBlock(j, BBA);
PN.setIncomingBlock(i, BBB); PN.setIncomingValue(j, VA);
PN.setIncomingValue(i, VB);
PN.setIncomingBlock(j, BBA);
PN.setIncomingValue(j, VA);
}
} }
return 0; return 0;