aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2008-07-16 17:52:31 +0000
committerOwen Anderson <resistor@mac.com>2008-07-16 17:52:31 +0000
commit5d0af038a718ff31b1ecf0894bae951e41960e0d (patch)
treedbcafafe3e3c5d4a378754e648a71afcc83205ab
parent5af8f0e67e407437709f4011295fa324d1e00316 (diff)
There's no need to iterate block merging and PRE. In fact, iterating the latter
could cause problems for memdep when it breaks critical edges. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53691 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/GVN.cpp26
1 files changed, 12 insertions, 14 deletions
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp
index 7bbfbadf01..986d755bad 100644
--- a/lib/Transforms/Scalar/GVN.cpp
+++ b/lib/Transforms/Scalar/GVN.cpp
@@ -727,7 +727,6 @@ namespace {
AU.addPreserved<DominatorTree>();
AU.addPreserved<AliasAnalysis>();
- AU.addPreserved<MemoryDependenceAnalysis>();
}
// Helper fuctions
@@ -1121,11 +1120,22 @@ bool GVN::runOnFunction(Function& F) {
bool changed = false;
bool shouldContinue = true;
+ // Merge unconditional branches, allowing PRE to catch more
+ // optimization opportunities.
+ for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ) {
+ BasicBlock* BB = FI;
+ ++FI;
+ changed |= mergeBlockIntoPredecessor(BB);
+ }
+
while (shouldContinue) {
shouldContinue = iterateOnFunction(F);
changed |= shouldContinue;
}
+ if (EnablePRE)
+ changed |= performPRE(F);
+
return changed;
}
@@ -1382,15 +1392,6 @@ bool GVN::iterateOnFunction(Function &F) {
VN.clear();
phiMap.clear();
- // Merge unconditional branches, allowing PRE to catch more
- // optimization opportunities.
- bool mergedBlocks = false;
- for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ) {
- BasicBlock* BB = FI;
- ++FI;
- mergedBlocks |= mergeBlockIntoPredecessor(BB);
- }
-
for (DenseMap<BasicBlock*, ValueNumberScope*>::iterator
I = localAvail.begin(), E = localAvail.end(); I != E; ++I)
delete I->second;
@@ -1404,8 +1405,5 @@ bool GVN::iterateOnFunction(Function &F) {
DE = df_end(DT.getRootNode()); DI != DE; ++DI)
changed |= processBlock(*DI);
- if (EnablePRE)
- changed |= performPRE(F);
-
- return changed || mergedBlocks;
+ return changed;
}