diff options
author | Owen Anderson <resistor@mac.com> | 2009-04-22 08:09:13 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-04-22 08:09:13 +0000 |
commit | 68fbd735f1e0761a3ba16aec4dcb1c1f163f9749 (patch) | |
tree | a106c99ccd8cb5fc68a465722ad7679aa42bffb5 /lib/Transforms/Utils/LCSSA.cpp | |
parent | 747972914ae73379fd837e5a30cea229be792e34 (diff) |
Use PredIteratorCache in LCSSA, which gives a 37% overall speedup on the testcase from PR3549. More improvements to come.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69788 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/LCSSA.cpp')
-rw-r--r-- | lib/Transforms/Utils/LCSSA.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/Transforms/Utils/LCSSA.cpp b/lib/Transforms/Utils/LCSSA.cpp index 9cd7e69557..a9ae7c98da 100644 --- a/lib/Transforms/Utils/LCSSA.cpp +++ b/lib/Transforms/Utils/LCSSA.cpp @@ -40,6 +40,7 @@ #include "llvm/Analysis/ScalarEvolution.h" #include "llvm/Support/CFG.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/PredIteratorCache.h" #include <algorithm> #include <map> using namespace llvm; @@ -55,6 +56,7 @@ namespace { LoopInfo *LI; DominatorTree *DT; std::vector<BasicBlock*> LoopBlocks; + PredIteratorCache PredCache; virtual bool runOnLoop(Loop *L, LPPassManager &LPM); @@ -104,6 +106,7 @@ const PassInfo *const llvm::LCSSAID = &X; /// runOnFunction - Process all loops in the function, inner-most out. bool LCSSA::runOnLoop(Loop *L, LPPassManager &LPM) { + PredCache.clear(); LI = &LPM.getAnalysis<LoopInfo>(); DT = &getAnalysis<DominatorTree>(); @@ -163,7 +166,7 @@ void LCSSA::ProcessInstruction(Instruction *Instr, Phi = PN; // Add inputs from inside the loop for this PHI. - for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) + for (BasicBlock** PI = PredCache.GetPreds(BB); *PI; ++PI) PN->addIncoming(Instr, *PI); } } @@ -264,7 +267,7 @@ Value *LCSSA::GetValueForBlock(DomTreeNode *BB, Instruction *OrigInst, Phis.insert(std::make_pair(BB, PN)); // Fill in the incoming values for the block. - for (pred_iterator PI = pred_begin(BBN), E = pred_end(BBN); PI != E; ++PI) + for (BasicBlock** PI = PredCache.GetPreds(BBN); *PI; ++PI) PN->addIncoming(GetValueForBlock(DT->getNode(*PI), OrigInst, Phis), *PI); return PN; } |