aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-12-09 19:25:07 +0000
committerChris Lattner <sabre@nondot.org>2008-12-09 19:25:07 +0000
commit91bcf6450ab063204a7ccd933d7db40028485147 (patch)
tree7e37ec83a93cd3f46828692c02f02f2c20816387 /lib
parentae1993114f71c286e0d737776ad48d9eefd3c67a (diff)
downloadexternal_llvm-91bcf6450ab063204a7ccd933d7db40028485147.zip
external_llvm-91bcf6450ab063204a7ccd933d7db40028485147.tar.gz
external_llvm-91bcf6450ab063204a7ccd933d7db40028485147.tar.bz2
Switch GVN::processNonLocalLoad to using the new
MemDep::getNonLocalPointerDependency method. There are some open issues with this (missed optimizations) and plenty of future work, but this does allow GVN to eliminate *slightly* more loads (49246 vs 49033). Switching over now allows simplification of the other code path in memdep. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60780 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Scalar/GVN.cpp31
1 files changed, 11 insertions, 20 deletions
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp
index 4b9e2b0..ec300fa 100644
--- a/lib/Transforms/Scalar/GVN.cpp
+++ b/lib/Transforms/Scalar/GVN.cpp
@@ -938,18 +938,17 @@ SpeculationFailure:
bool GVN::processNonLocalLoad(LoadInst *LI,
SmallVectorImpl<Instruction*> &toErase) {
// Find the non-local dependencies of the load.
- const MemoryDependenceAnalysis::NonLocalDepInfo &deps =
- MD->getNonLocalDependency(LI);
- //DEBUG(cerr << "INVESTIGATING NONLOCAL LOAD: " << deps.size() << *LI);
+ SmallVector<MemoryDependenceAnalysis::NonLocalDepEntry, 64> Deps;
+ MD->getNonLocalPointerDependency(LI->getOperand(0), true, LI->getParent(),
+ Deps);
+ //DEBUG(cerr << "INVESTIGATING NONLOCAL LOAD: " << Deps.size() << *LI);
// If we had to process more than one hundred blocks to find the
// dependencies, this load isn't worth worrying about. Optimizing
// it will be too expensive.
- if (deps.size() > 100)
+ if (Deps.size() > 100)
return false;
- BasicBlock *EntryBlock = &LI->getParent()->getParent()->getEntryBlock();
-
// Filter out useless results (non-locals, etc). Keep track of the blocks
// where we have a value available in repl, also keep track of whether we see
// dependencies that produce an unknown value for the load (such as a call
@@ -957,18 +956,9 @@ bool GVN::processNonLocalLoad(LoadInst *LI,
SmallVector<std::pair<BasicBlock*, Value*>, 16> ValuesPerBlock;
SmallVector<BasicBlock*, 16> UnavailableBlocks;
- for (unsigned i = 0, e = deps.size(); i != e; ++i) {
- BasicBlock *DepBB = deps[i].first;
- MemDepResult DepInfo = deps[i].second;
-
- if (DepInfo.isNonLocal()) {
- // If this is a non-local dependency in the entry block, then we depend on
- // the value live-in at the start of the function. We could insert a load
- // in the entry block to get this, but for now we'll just bail out.
- if (DepBB == EntryBlock)
- UnavailableBlocks.push_back(DepBB);
- continue;
- }
+ for (unsigned i = 0, e = Deps.size(); i != e; ++i) {
+ BasicBlock *DepBB = Deps[i].first;
+ MemDepResult DepInfo = Deps[i].second;
if (DepInfo.isClobber()) {
UnavailableBlocks.push_back(DepBB);
@@ -984,7 +974,7 @@ bool GVN::processNonLocalLoad(LoadInst *LI,
continue;
}
- if (StoreInst* S = dyn_cast<StoreInst>(DepInfo.getInst())) {
+ if (StoreInst* S = dyn_cast<StoreInst>(DepInst)) {
// Reject loads and stores that are to the same address but are of
// different types.
// NOTE: 403.gcc does have this case (e.g. in readonly_fields_p) because
@@ -997,7 +987,7 @@ bool GVN::processNonLocalLoad(LoadInst *LI,
ValuesPerBlock.push_back(std::make_pair(DepBB, S->getOperand(0)));
- } else if (LoadInst* LD = dyn_cast<LoadInst>(DepInfo.getInst())) {
+ } else if (LoadInst* LD = dyn_cast<LoadInst>(DepInst)) {
if (LD->getType() != LI->getType()) {
UnavailableBlocks.push_back(DepBB);
continue;
@@ -1019,6 +1009,7 @@ bool GVN::processNonLocalLoad(LoadInst *LI,
if (UnavailableBlocks.empty()) {
// Use cached PHI construction information from previous runs
SmallPtrSet<Instruction*, 4> &p = phiMap[LI->getPointerOperand()];
+ // FIXME: What does phiMap do? Are we positive it isn't getting invalidated?
for (SmallPtrSet<Instruction*, 4>::iterator I = p.begin(), E = p.end();
I != E; ++I) {
if ((*I)->getParent() == LI->getParent()) {