mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Revert "SLPVectorizer: Cache results from memory alias checking."
The alias cache has a problem of incorrect collisions in case a new instruction is allocated at the same address as a previously deleted instruction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225790 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
df70ab2592
commit
046c3e807d
@ -19,7 +19,6 @@
|
|||||||
#include "llvm/ADT/MapVector.h"
|
#include "llvm/ADT/MapVector.h"
|
||||||
#include "llvm/ADT/PostOrderIterator.h"
|
#include "llvm/ADT/PostOrderIterator.h"
|
||||||
#include "llvm/ADT/SetVector.h"
|
#include "llvm/ADT/SetVector.h"
|
||||||
#include "llvm/ADT/Optional.h"
|
|
||||||
#include "llvm/ADT/Statistic.h"
|
#include "llvm/ADT/Statistic.h"
|
||||||
#include "llvm/Analysis/AliasAnalysis.h"
|
#include "llvm/Analysis/AliasAnalysis.h"
|
||||||
#include "llvm/Analysis/AssumptionCache.h"
|
#include "llvm/Analysis/AssumptionCache.h"
|
||||||
@ -389,15 +388,6 @@ static bool InTreeUserNeedToExtract(Value *Scalar, Instruction *UserInst,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \returns the AA location that is being access by the instruction.
|
|
||||||
static AliasAnalysis::Location getLocation(Instruction *I, AliasAnalysis *AA) {
|
|
||||||
if (StoreInst *SI = dyn_cast<StoreInst>(I))
|
|
||||||
return AA->getLocation(SI);
|
|
||||||
if (LoadInst *LI = dyn_cast<LoadInst>(I))
|
|
||||||
return AA->getLocation(LI);
|
|
||||||
return AliasAnalysis::Location();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Bottom Up SLP Vectorizer.
|
/// Bottom Up SLP Vectorizer.
|
||||||
class BoUpSLP {
|
class BoUpSLP {
|
||||||
public:
|
public:
|
||||||
@ -565,35 +555,6 @@ private:
|
|||||||
};
|
};
|
||||||
typedef SmallVector<ExternalUser, 16> UserList;
|
typedef SmallVector<ExternalUser, 16> UserList;
|
||||||
|
|
||||||
/// Checks if two instructions may access the same memory.
|
|
||||||
///
|
|
||||||
/// \p Loc1 is the location of \p Inst1. It is passed explicitly because it
|
|
||||||
/// is invariant in the calling loop.
|
|
||||||
bool isAliased(const AliasAnalysis::Location &Loc1, Instruction *Inst1,
|
|
||||||
Instruction *Inst2) {
|
|
||||||
|
|
||||||
// First check if the result is already in the cache.
|
|
||||||
AliasCacheKey key = std::make_pair(Inst1, Inst2);
|
|
||||||
Optional<bool> &result = AliasCache[key];
|
|
||||||
if (result.hasValue()) {
|
|
||||||
return result.getValue();
|
|
||||||
}
|
|
||||||
AliasAnalysis::Location Loc2 = getLocation(Inst2, AA);
|
|
||||||
bool aliased = true;
|
|
||||||
if (Loc1.Ptr && Loc2.Ptr) {
|
|
||||||
// Do the alias check.
|
|
||||||
aliased = AA->alias(Loc1, Loc2);
|
|
||||||
}
|
|
||||||
// Store the result in the cache.
|
|
||||||
result = aliased;
|
|
||||||
return aliased;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef std::pair<Instruction *, Instruction *> AliasCacheKey;
|
|
||||||
|
|
||||||
/// Cache for alias results.
|
|
||||||
DenseMap<AliasCacheKey, Optional<bool>> AliasCache;
|
|
||||||
|
|
||||||
/// A list of values that need to extracted out of the tree.
|
/// A list of values that need to extracted out of the tree.
|
||||||
/// This list holds pairs of (Internal Scalar : External User).
|
/// This list holds pairs of (Internal Scalar : External User).
|
||||||
UserList ExternalUses;
|
UserList ExternalUses;
|
||||||
@ -830,7 +791,7 @@ private:
|
|||||||
/// Checks if a bundle of instructions can be scheduled, i.e. has no
|
/// Checks if a bundle of instructions can be scheduled, i.e. has no
|
||||||
/// cyclic dependencies. This is only a dry-run, no instructions are
|
/// cyclic dependencies. This is only a dry-run, no instructions are
|
||||||
/// actually moved at this stage.
|
/// actually moved at this stage.
|
||||||
bool tryScheduleBundle(ArrayRef<Value *> VL, BoUpSLP *SLP);
|
bool tryScheduleBundle(ArrayRef<Value *> VL, AliasAnalysis *AA);
|
||||||
|
|
||||||
/// Un-bundles a group of instructions.
|
/// Un-bundles a group of instructions.
|
||||||
void cancelScheduling(ArrayRef<Value *> VL);
|
void cancelScheduling(ArrayRef<Value *> VL);
|
||||||
@ -847,7 +808,7 @@ private:
|
|||||||
/// Updates the dependency information of a bundle and of all instructions/
|
/// Updates the dependency information of a bundle and of all instructions/
|
||||||
/// bundles which depend on the original bundle.
|
/// bundles which depend on the original bundle.
|
||||||
void calculateDependencies(ScheduleData *SD, bool InsertInReadyList,
|
void calculateDependencies(ScheduleData *SD, bool InsertInReadyList,
|
||||||
BoUpSLP *SLP);
|
AliasAnalysis *AA);
|
||||||
|
|
||||||
/// Sets all instruction in the scheduling region to un-scheduled.
|
/// Sets all instruction in the scheduling region to un-scheduled.
|
||||||
void resetSchedule();
|
void resetSchedule();
|
||||||
@ -1108,7 +1069,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth) {
|
|||||||
}
|
}
|
||||||
BlockScheduling &BS = *BSRef.get();
|
BlockScheduling &BS = *BSRef.get();
|
||||||
|
|
||||||
if (!BS.tryScheduleBundle(VL, this)) {
|
if (!BS.tryScheduleBundle(VL, AA)) {
|
||||||
DEBUG(dbgs() << "SLP: We are not able to schedule this bundle!\n");
|
DEBUG(dbgs() << "SLP: We are not able to schedule this bundle!\n");
|
||||||
BS.cancelScheduling(VL);
|
BS.cancelScheduling(VL);
|
||||||
newTreeEntry(VL, false);
|
newTreeEntry(VL, false);
|
||||||
@ -2499,7 +2460,7 @@ void BoUpSLP::optimizeGatherSequence() {
|
|||||||
// Groups the instructions to a bundle (which is then a single scheduling entity)
|
// Groups the instructions to a bundle (which is then a single scheduling entity)
|
||||||
// and schedules instructions until the bundle gets ready.
|
// and schedules instructions until the bundle gets ready.
|
||||||
bool BoUpSLP::BlockScheduling::tryScheduleBundle(ArrayRef<Value *> VL,
|
bool BoUpSLP::BlockScheduling::tryScheduleBundle(ArrayRef<Value *> VL,
|
||||||
BoUpSLP *SLP) {
|
AliasAnalysis *AA) {
|
||||||
if (isa<PHINode>(VL[0]))
|
if (isa<PHINode>(VL[0]))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -2556,7 +2517,7 @@ bool BoUpSLP::BlockScheduling::tryScheduleBundle(ArrayRef<Value *> VL,
|
|||||||
DEBUG(dbgs() << "SLP: try schedule bundle " << *Bundle << " in block "
|
DEBUG(dbgs() << "SLP: try schedule bundle " << *Bundle << " in block "
|
||||||
<< BB->getName() << "\n");
|
<< BB->getName() << "\n");
|
||||||
|
|
||||||
calculateDependencies(Bundle, true, SLP);
|
calculateDependencies(Bundle, true, AA);
|
||||||
|
|
||||||
// Now try to schedule the new bundle. As soon as the bundle is "ready" it
|
// Now try to schedule the new bundle. As soon as the bundle is "ready" it
|
||||||
// means that there are no cyclic dependencies and we can schedule it.
|
// means that there are no cyclic dependencies and we can schedule it.
|
||||||
@ -2687,9 +2648,18 @@ void BoUpSLP::BlockScheduling::initScheduleData(Instruction *FromI,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \returns the AA location that is being access by the instruction.
|
||||||
|
static AliasAnalysis::Location getLocation(Instruction *I, AliasAnalysis *AA) {
|
||||||
|
if (StoreInst *SI = dyn_cast<StoreInst>(I))
|
||||||
|
return AA->getLocation(SI);
|
||||||
|
if (LoadInst *LI = dyn_cast<LoadInst>(I))
|
||||||
|
return AA->getLocation(LI);
|
||||||
|
return AliasAnalysis::Location();
|
||||||
|
}
|
||||||
|
|
||||||
void BoUpSLP::BlockScheduling::calculateDependencies(ScheduleData *SD,
|
void BoUpSLP::BlockScheduling::calculateDependencies(ScheduleData *SD,
|
||||||
bool InsertInReadyList,
|
bool InsertInReadyList,
|
||||||
BoUpSLP *SLP) {
|
AliasAnalysis *AA) {
|
||||||
assert(SD->isSchedulingEntity());
|
assert(SD->isSchedulingEntity());
|
||||||
|
|
||||||
SmallVector<ScheduleData *, 10> WorkList;
|
SmallVector<ScheduleData *, 10> WorkList;
|
||||||
@ -2734,14 +2704,14 @@ void BoUpSLP::BlockScheduling::calculateDependencies(ScheduleData *SD,
|
|||||||
// Handle the memory dependencies.
|
// Handle the memory dependencies.
|
||||||
ScheduleData *DepDest = BundleMember->NextLoadStore;
|
ScheduleData *DepDest = BundleMember->NextLoadStore;
|
||||||
if (DepDest) {
|
if (DepDest) {
|
||||||
Instruction *SrcInst = BundleMember->Inst;
|
AliasAnalysis::Location SrcLoc = getLocation(BundleMember->Inst, AA);
|
||||||
AliasAnalysis::Location SrcLoc = getLocation(SrcInst, SLP->AA);
|
|
||||||
bool SrcMayWrite = BundleMember->Inst->mayWriteToMemory();
|
bool SrcMayWrite = BundleMember->Inst->mayWriteToMemory();
|
||||||
|
|
||||||
while (DepDest) {
|
while (DepDest) {
|
||||||
assert(isInSchedulingRegion(DepDest));
|
assert(isInSchedulingRegion(DepDest));
|
||||||
if (SrcMayWrite || DepDest->Inst->mayWriteToMemory()) {
|
if (SrcMayWrite || DepDest->Inst->mayWriteToMemory()) {
|
||||||
if (SLP->isAliased(SrcLoc, SrcInst, DepDest->Inst)) {
|
AliasAnalysis::Location DstLoc = getLocation(DepDest->Inst, AA);
|
||||||
|
if (!SrcLoc.Ptr || !DstLoc.Ptr || AA->alias(SrcLoc, DstLoc)) {
|
||||||
DepDest->MemoryDependencies.push_back(BundleMember);
|
DepDest->MemoryDependencies.push_back(BundleMember);
|
||||||
BundleMember->Dependencies++;
|
BundleMember->Dependencies++;
|
||||||
ScheduleData *DestBundle = DepDest->FirstInBundle;
|
ScheduleData *DestBundle = DepDest->FirstInBundle;
|
||||||
@ -2809,7 +2779,7 @@ void BoUpSLP::scheduleBlock(BlockScheduling *BS) {
|
|||||||
"scheduler and vectorizer have different opinion on what is a bundle");
|
"scheduler and vectorizer have different opinion on what is a bundle");
|
||||||
SD->FirstInBundle->SchedulingPriority = Idx++;
|
SD->FirstInBundle->SchedulingPriority = Idx++;
|
||||||
if (SD->isSchedulingEntity()) {
|
if (SD->isSchedulingEntity()) {
|
||||||
BS->calculateDependencies(SD, false, this);
|
BS->calculateDependencies(SD, false, AA);
|
||||||
NumToSchedule++;
|
NumToSchedule++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user