diff options
author | Chris Lattner <sabre@nondot.org> | 2010-12-14 07:20:29 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-12-14 07:20:29 +0000 |
commit | 07ff3539f5342bdac019c68bb362cb222b3f71d9 (patch) | |
tree | 75a3cf1fc7b9895f0a0ae1a5292f09993381113d /lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | 995ba1bd49e57dee8e301d5f33a7c01d73b7385d (diff) |
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
Diffstat (limited to 'lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | lib/Transforms/Utils/SimplifyCFG.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index 026391a75d..11148b5101 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/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 |