Use PredIteratorCache in LCSSA, which gives a 37% overall speedup on the testcase from PR3549. More improvements to come.
llvm-svn: 69788
This commit is contained in:
parent
9fd114d577
commit
bb754826c9
|
@ -40,6 +40,7 @@
|
||||||
#include "llvm/Analysis/ScalarEvolution.h"
|
#include "llvm/Analysis/ScalarEvolution.h"
|
||||||
#include "llvm/Support/CFG.h"
|
#include "llvm/Support/CFG.h"
|
||||||
#include "llvm/Support/Compiler.h"
|
#include "llvm/Support/Compiler.h"
|
||||||
|
#include "llvm/Support/PredIteratorCache.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
@ -55,6 +56,7 @@ namespace {
|
||||||
LoopInfo *LI;
|
LoopInfo *LI;
|
||||||
DominatorTree *DT;
|
DominatorTree *DT;
|
||||||
std::vector<BasicBlock*> LoopBlocks;
|
std::vector<BasicBlock*> LoopBlocks;
|
||||||
|
PredIteratorCache PredCache;
|
||||||
|
|
||||||
virtual bool runOnLoop(Loop *L, LPPassManager &LPM);
|
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.
|
/// runOnFunction - Process all loops in the function, inner-most out.
|
||||||
bool LCSSA::runOnLoop(Loop *L, LPPassManager &LPM) {
|
bool LCSSA::runOnLoop(Loop *L, LPPassManager &LPM) {
|
||||||
|
PredCache.clear();
|
||||||
|
|
||||||
LI = &LPM.getAnalysis<LoopInfo>();
|
LI = &LPM.getAnalysis<LoopInfo>();
|
||||||
DT = &getAnalysis<DominatorTree>();
|
DT = &getAnalysis<DominatorTree>();
|
||||||
|
@ -163,7 +166,7 @@ void LCSSA::ProcessInstruction(Instruction *Instr,
|
||||||
Phi = PN;
|
Phi = PN;
|
||||||
|
|
||||||
// Add inputs from inside the loop for this PHI.
|
// 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);
|
PN->addIncoming(Instr, *PI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -264,7 +267,7 @@ Value *LCSSA::GetValueForBlock(DomTreeNode *BB, Instruction *OrigInst,
|
||||||
Phis.insert(std::make_pair(BB, PN));
|
Phis.insert(std::make_pair(BB, PN));
|
||||||
|
|
||||||
// Fill in the incoming values for the block.
|
// 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);
|
PN->addIncoming(GetValueForBlock(DT->getNode(*PI), OrigInst, Phis), *PI);
|
||||||
return PN;
|
return PN;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue