mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-02 08:46:37 +00:00
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
This commit is contained in:
parent
ae1993114f
commit
91bcf6450a
@ -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()) {
|
||||
|
Loading…
Reference in New Issue
Block a user