[llvm-commits] [llvm] r83701 - in /llvm/trunk/lib/Transforms: Scalar/GVN.cpp Utils/LCSSA.cpp

Chris Lattner sabre at nondot.org
Fri Oct 9 23:22:45 PDT 2009


Author: lattner
Date: Sat Oct 10 01:22:45 2009
New Revision: 83701

URL: http://llvm.org/viewvc/llvm-project?rev=83701&view=rev
Log:
random tidying

Modified:
    llvm/trunk/lib/Transforms/Scalar/GVN.cpp
    llvm/trunk/lib/Transforms/Utils/LCSSA.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=83701&r1=83700&r2=83701&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Sat Oct 10 01:22:45 2009
@@ -816,8 +816,9 @@
   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 @@
 
   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 @@
   // 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

Modified: llvm/trunk/lib/Transforms/Utils/LCSSA.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LCSSA.cpp?rev=83701&r1=83700&r2=83701&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LCSSA.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LCSSA.cpp Sat Oct 10 01:22:45 2009
@@ -197,9 +197,8 @@
   for (Value::use_iterator UI = Instr->use_begin(), E = Instr->use_end();
        UI != E;) {
     BasicBlock *UserBB = cast<Instruction>(*UI)->getParent();
-    if (PHINode *P = dyn_cast<PHINode>(*UI)) {
+    if (PHINode *P = dyn_cast<PHINode>(*UI))
       UserBB = P->getIncomingBlock(UI);
-    }
     
     // If the user is in the loop, don't rewrite it!
     if (UserBB == Instr->getParent() || inLoop(UserBB)) {
@@ -231,12 +230,11 @@
   for (Loop::block_iterator BB = L->block_begin(), BE = L->block_end();
        BB != BE; ++BB) {
     for (BasicBlock::iterator I = (*BB)->begin(), E = (*BB)->end(); I != E; ++I)
-      for (Value::use_iterator UI = I->use_begin(), UE = I->use_end(); UI != UE;
-           ++UI) {
+      for (Value::use_iterator UI = I->use_begin(), UE = I->use_end();
+           UI != UE; ++UI) {
         BasicBlock *UserBB = cast<Instruction>(*UI)->getParent();
-        if (PHINode* p = dyn_cast<PHINode>(*UI)) {
+        if (PHINode *p = dyn_cast<PHINode>(*UI))
           UserBB = p->getIncomingBlock(UI);
-        }
         
         if (*BB != UserBB && !inLoop(UserBB)) {
           AffectedValues.insert(I);
@@ -288,7 +286,7 @@
   Phis.insert(std::make_pair(BB, PN));
                                  
   // Fill in the incoming values for the block.
-  for (BasicBlock** PI = PredCache.GetPreds(BBN); *PI; ++PI)
+  for (BasicBlock **PI = PredCache.GetPreds(BBN); *PI; ++PI)
     PN->addIncoming(GetValueForBlock(DT->getNode(*PI), OrigInst, Phis), *PI);
   return PN;
 }





More information about the llvm-commits mailing list