From 7be3f1e0788163775cd7c9e4dc6bc82578f28f9e Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Tue, 13 Jun 2006 19:37:18 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28771 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Utils/LCSSA.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/Transforms/Utils/LCSSA.cpp b/lib/Transforms/Utils/LCSSA.cpp index ac540c9aaac..37ab7ee7ff2 100644 --- a/lib/Transforms/Utils/LCSSA.cpp +++ b/lib/Transforms/Utils/LCSSA.cpp @@ -91,6 +91,7 @@ const PassInfo *llvm::LCSSAID = X.getPassInfo(); /// runOnFunction - Process all loops in the function, inner-most out. bool LCSSA::runOnFunction(Function &F) { bool changed = false; + LI = &getAnalysis(); DF = &getAnalysis(); DT = &getAnalysis(); @@ -107,7 +108,7 @@ bool LCSSA::runOnFunction(Function &F) { 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 @@ void LCSSA::processInstruction(Instruction* Instr, phi = new PHINode(Instr->getType(), Instr->getName()+".lcssa", (*BBI)->begin()); workList.push_back(cast(phi)); - Phis[*BBI] = phi; } } @@ -253,6 +253,11 @@ SetVector LCSSA::getLoopValuesUsedOutsideLoop(Loop *L) { for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E; ++UI) { BasicBlock *UserBB = cast(*UI)->getParent(); + if (PHINode* p = dyn_cast(*UI)) { + unsigned OperandNo = UI.getOperandNo(); + UserBB = p->getIncomingBlock(OperandNo/2); + } + if (!inLoop(UserBB)) { AffectedValues.insert(I); break;