From 07ff3539f5342bdac019c68bb362cb222b3f71d9 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 14 Dec 2010 07:20:29 +0000 Subject: [PATCH] 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 --- lib/Transforms/Utils/SimplifyCFG.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index 026391a75da..11148b5101c 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(AfterPHIIt)) { PHINode *PN = cast(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