summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2009-10-31 01:28:06 +0000
committerEvan Cheng <evan.cheng@apple.com>2009-10-31 01:28:06 +0000
commitc16d8f2054b73c94c7cb78043fdac5b06e0fcee8 (patch)
tree1ef06453dffd226026dcfc67f0e574a44c18fdc7 /llvm/lib
parentea88910dbf214977c5769d3cb09b6fc4e9532e85 (diff)
downloadbcm5719-llvm-c16d8f2054b73c94c7cb78043fdac5b06e0fcee8.tar.gz
bcm5719-llvm-c16d8f2054b73c94c7cb78043fdac5b06e0fcee8.zip
Revert 85634. It's breaking consumer-typeset (and others).
llvm-svn: 85641
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp32
1 files changed, 15 insertions, 17 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 672ed0af1ba..e1741a00676 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -10981,24 +10981,22 @@ Instruction *InstCombiner::visitPHINode(PHINode &PN) {
}
}
- // If there are multiple PHIs, sort their operands so that they all list
- // the blocks in the same order. This will help identical PHIs be eliminated
- // by other passes. Other passes shouldn't depend on this for correctness
- // however.
- PHINode *FirstPN = cast<PHINode>(PN.getParent()->begin());
- if (&PN != FirstPN)
- for (unsigned i = 0, e = FirstPN->getNumIncomingValues(); i != e; ++i) {
+ // Sort the PHI node operands to match the pred iterator order. This will
+ // help identical PHIs be eliminated by other passes. Other passes shouldn't
+ // depend on this for correctness however.
+ unsigned i = 0;
+ for (pred_iterator PI = pred_begin(PN.getParent()),
+ PE = pred_end(PN.getParent()); PI != PE; ++PI, ++i)
+ if (PN.getIncomingBlock(i) != *PI) {
+ unsigned j = PN.getBasicBlockIndex(*PI);
+ Value *VA = PN.getIncomingValue(i);
BasicBlock *BBA = PN.getIncomingBlock(i);
- BasicBlock *BBB = FirstPN->getIncomingBlock(i);
- if (BBA != BBB) {
- Value *VA = PN.getIncomingValue(i);
- unsigned j = FirstPN->getBasicBlockIndex(BBA);
- Value *VB = PN.getIncomingValue(j);
- PN.setIncomingBlock(i, BBB);
- PN.setIncomingValue(i, VB);
- PN.setIncomingBlock(j, BBA);
- PN.setIncomingValue(j, VA);
- }
+ Value *VB = PN.getIncomingValue(j);
+ BasicBlock *BBB = PN.getIncomingBlock(j);
+ PN.setIncomingBlock(i, BBB);
+ PN.setIncomingValue(i, VB);
+ PN.setIncomingBlock(j, BBA);
+ PN.setIncomingValue(j, VA);
}
return 0;
OpenPOWER on IntegriCloud