aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-12-01 07:29:03 +0000
committerChris Lattner <sabre@nondot.org>2008-12-01 07:29:03 +0000
commit09713794c17061ae36cc696cfc928c5a0c2bdc75 (patch)
treebb8390c016953d245612b998042d04f44fa3275f
parenta3522000ab9c821f48856d0c25ada8297c1c2914 (diff)
pull the predMap densemap out of the inner loop of performPRE, so
that it isn't reallocated all the time. This is a tiny speedup for GVN: 3.90->3.88s git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60338 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/GVN.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp
index 9189f41c19..2995b1000a 100644
--- a/lib/Transforms/Scalar/GVN.cpp
+++ b/lib/Transforms/Scalar/GVN.cpp
@@ -1225,6 +1225,7 @@ bool GVN::processBlock(DomTreeNode* DTN) {
bool GVN::performPRE(Function& F) {
bool changed = false;
SmallVector<std::pair<TerminatorInst*, unsigned>, 4> toSplit;
+ DenseMap<BasicBlock*, Value*> predMap;
for (df_iterator<BasicBlock*> DI = df_begin(&F.getEntryBlock()),
DE = df_end(&F.getEntryBlock()); DI != DE; ++DI) {
BasicBlock* CurrentBlock = *DI;
@@ -1252,7 +1253,8 @@ bool GVN::performPRE(Function& F) {
unsigned numWith = 0;
unsigned numWithout = 0;
BasicBlock* PREPred = 0;
- DenseMap<BasicBlock*, Value*> predMap;
+ predMap.clear();
+
for (pred_iterator PI = pred_begin(CurrentBlock),
PE = pred_end(CurrentBlock); PI != PE; ++PI) {
// We're not interested in PRE where the block is its
@@ -1359,7 +1361,7 @@ bool GVN::performPRE(Function& F) {
Instruction* erase = BI;
BI++;
- DEBUG(cerr << "GVN removed: " << *erase);
+ DEBUG(cerr << "GVN PRE removed: " << *erase);
MD->removeInstruction(erase);
erase->eraseFromParent();
changed = true;