diff options
author | Chris Lattner <sabre@nondot.org> | 2009-10-10 06:22:45 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-10-10 06:22:45 +0000 |
commit | 2d7f1d24bf32418de4ff817284eb5222726c2c62 (patch) | |
tree | 2a64ffd684c815d3edb2862b945aad3a4110f61f /lib/Transforms/Scalar/GVN.cpp | |
parent | bcea859fc1dd1af9ac66ec93ea04ce9a19c8451c (diff) | |
download | llvm-2d7f1d24bf32418de4ff817284eb5222726c2c62.tar.gz llvm-2d7f1d24bf32418de4ff817284eb5222726c2c62.tar.bz2 llvm-2d7f1d24bf32418de4ff817284eb5222726c2c62.tar.xz |
random tidying
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83701 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/GVN.cpp')
-rw-r--r-- | lib/Transforms/Scalar/GVN.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp index 86bbc602e3..bd5b02895e 100644 --- a/lib/Transforms/Scalar/GVN.cpp +++ b/lib/Transforms/Scalar/GVN.cpp @@ -816,8 +816,9 @@ Value *GVN::GetValueForBlock(BasicBlock *BB, Instruction *Orig, else NumPreds = std::distance(pred_begin(BB), pred_end(BB)); - // Otherwise, the idom is the loop, so we need to insert a PHI node. Do so - // now, then get values to fill in the incoming values for the PHI. + // Otherwise, we may need to insert a PHI node. Do so now, then get values to + // fill in the incoming values for the PHI. If the PHI ends up not being + // needed, we can always remove it later. PHINode *PN = PHINode::Create(Orig->getType(), Orig->getName()+".rle", BB->begin()); PN->reserveOperandSpace(NumPreds); @@ -832,7 +833,8 @@ Value *GVN::GetValueForBlock(BasicBlock *BB, Instruction *Orig, VN.getAliasAnalysis()->copyValue(Orig, PN); - // Attempt to collapse PHI nodes that are trivially redundant + // Attempt to collapse PHI nodes that are trivially redundant. This happens + // when we construct a PHI that ends up not being needed. Value *v = CollapsePhi(PN); if (!v) { // Cache our phi construction results @@ -1777,8 +1779,8 @@ Value *GVN::AttemptRedundancyElimination(Instruction *orig, unsigned valno) { // If we didn't find instances, give up. Otherwise, perform phi construction. if (Results.size() == 0) return 0; - else - return GetValueForBlock(BaseBlock, orig, Results, true); + + return GetValueForBlock(BaseBlock, orig, Results, true); } /// processInstruction - When calculating availability, handle an instruction |