summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-12-14 07:20:29 +0000
committerChris Lattner <sabre@nondot.org>2010-12-14 07:20:29 +0000
commitb42d293faa46c80a64dbee5e4ee4a7859f1629f7 (patch)
tree7c82a9317c9a83400e2c49f59d7698d983b8c68d /llvm/lib/Transforms/Utils/SimplifyCFG.cpp
parentfb73de482ccfea39cdc26d8ec183deaf0af528c0 (diff)
downloadbcm5719-llvm-b42d293faa46c80a64dbee5e4ee4a7859f1629f7.tar.gz
bcm5719-llvm-b42d293faa46c80a64dbee5e4ee4a7859f1629f7.zip
use SimplifyInstruction instead of reimplementing part of it.
llvm-svn: 121757
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 026391a75da..11148b5101c 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -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
OpenPOWER on IntegriCloud