[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LCSSA.cpp

Owen Anderson resistor at mac.com
Sat Jun 3 17:55:31 PDT 2006



Changes in directory llvm/lib/Transforms/Scalar:

LCSSA.cpp updated: 1.12 -> 1.13
---
Log message:

Some more clean-up, and squash an IDF-Phi related bug.


---
Diffs of the changes:  (+13 -16)

 LCSSA.cpp |   29 +++++++++++++----------------
 1 files changed, 13 insertions(+), 16 deletions(-)


Index: llvm/lib/Transforms/Scalar/LCSSA.cpp
diff -u llvm/lib/Transforms/Scalar/LCSSA.cpp:1.12 llvm/lib/Transforms/Scalar/LCSSA.cpp:1.13
--- llvm/lib/Transforms/Scalar/LCSSA.cpp:1.12	Sat Jun  3 19:02:23 2006
+++ llvm/lib/Transforms/Scalar/LCSSA.cpp	Sat Jun  3 19:55:19 2006
@@ -50,7 +50,7 @@
     
   
     LoopInfo *LI;  // Loop information
-    DominatorTree *DT;       // Dominator Tree for the current Loop...
+    DominatorTree *DT;       // Dominator Tree for the current Function...
     DominanceFrontier *DF;   // Current Dominance Frontier
     std::vector<BasicBlock*> *LoopBlocks;
     
@@ -149,7 +149,8 @@
   for (std::vector<BasicBlock*>::const_iterator BBI = exitBlocks.begin(),
       BBE = exitBlocks.end(); BBI != BBE; ++BBI)
     if (DT->getNode(Instr->getParent())->dominates(DT->getNode(*BBI))) {
-      PHINode *phi = new PHINode(Instr->getType(), "lcssa", (*BBI)->begin());
+      PHINode *phi = new PHINode(Instr->getType(), Instr->getName()+".lcssa",
+                                 (*BBI)->begin());
       workList.push_back(phi);
       Phis[*BBI] = phi;
     }
@@ -174,12 +175,15 @@
       const DominanceFrontier::DomSetType &S = it->second;
       for (DominanceFrontier::DomSetType::const_iterator P = S.begin(),
            PE = S.end(); P != PE; ++P) {
-        Instruction *&Phi = Phis[*P];
-        if (Phi == 0) {
-          // Still doesn't have operands...
-          Phi = new PHINode(Instr->getType(), "lcssa", (*P)->begin());
+        if (DT->getNode(Instr->getParent())->dominates(DT->getNode(*P))) {
+          Instruction *&Phi = Phis[*P];
+          if (Phi == 0) {
+            // Still doesn't have operands...
+            Phi = new PHINode(Instr->getType(), Instr->getName()+".lcssa",
+                              (*P)->begin());
           
-          workList.push_back(cast<PHINode>(Phi));
+            workList.push_back(cast<PHINode>(Phi));
+          }
         }
       }
     }
@@ -200,18 +204,11 @@
   for (Instruction::use_iterator UI = Instr->use_begin(), UE = Instr->use_end();
        UI != UE; ++UI) {
     Instruction* use = cast<Instruction>(*UI);
-    // Don't need to update uses within the loop body, and we don't want to
-    // overwrite the Phi nodes that we inserted into the exit blocks either.
-    if (!inLoopBlocks(use->getParent()) &&
-        !(std::binary_search(exitBlocks.begin(), exitBlocks.end(),
-        use->getParent()) && isa<PHINode>(use)))
+    // Don't need to update uses within the loop body.
+    if (!inLoopBlocks(use->getParent()))
       Uses.push_back(use);
   }
   
-  // Deliberately remove the initial instruction from Phis set.  It would mess
-  // up use-replacement.
-  Phis.erase(Instr->getParent());
-  
   for (std::vector<Instruction*>::iterator II = Uses.begin(), IE = Uses.end();
        II != IE; ++II) {
     if (PHINode* phi = dyn_cast<PHINode>(*II)) {






More information about the llvm-commits mailing list