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

Owen Anderson resistor at mac.com
Tue Jun 13 12:37:30 PDT 2006



Changes in directory llvm/lib/Transforms/Utils:

LCSSA.cpp updated: 1.20 -> 1.21
---
Log message:

Fix a bug that was causing major slowdowns in povray.  This was due to LCSSA
not handling PHI nodes correctly when determining if a value was live-out.

This patch reduces the number of detected live-out variables in the testcase
from 6565 to 485.


---
Diffs of the changes:  (+7 -2)

 LCSSA.cpp |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)


Index: llvm/lib/Transforms/Utils/LCSSA.cpp
diff -u llvm/lib/Transforms/Utils/LCSSA.cpp:1.20 llvm/lib/Transforms/Utils/LCSSA.cpp:1.21
--- llvm/lib/Transforms/Utils/LCSSA.cpp:1.20	Mon Jun 12 02:10:16 2006
+++ llvm/lib/Transforms/Utils/LCSSA.cpp	Tue Jun 13 14:37:18 2006
@@ -91,6 +91,7 @@
 /// runOnFunction - Process all loops in the function, inner-most out.
 bool LCSSA::runOnFunction(Function &F) {
   bool changed = false;
+  
   LI = &getAnalysis<LoopInfo>();
   DF = &getAnalysis<DominanceFrontier>();
   DT = &getAnalysis<DominatorTree>();
@@ -107,7 +108,7 @@
 bool LCSSA::visitSubloop(Loop* L) {
   for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I)
     visitSubloop(*I);
-  
+    
   // Speed up queries by creating a sorted list of blocks
   LoopBlocks.clear();
   LoopBlocks.insert(LoopBlocks.end(), L->block_begin(), L->block_end());
@@ -162,7 +163,6 @@
       phi = new PHINode(Instr->getType(), Instr->getName()+".lcssa",
                                  (*BBI)->begin());
       workList.push_back(cast<PHINode>(phi));
-      Phis[*BBI] = phi;
     }
   }
   
@@ -253,6 +253,11 @@
       for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E;
            ++UI) {
         BasicBlock *UserBB = cast<Instruction>(*UI)->getParent();
+        if (PHINode* p = dyn_cast<PHINode>(*UI)) {
+          unsigned OperandNo = UI.getOperandNo();
+          UserBB = p->getIncomingBlock(OperandNo/2);
+        }
+        
         if (!inLoop(UserBB)) {
           AffectedValues.insert(I);
           break;






More information about the llvm-commits mailing list