mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
SLPVectorizer: limit the number of alias checks to reduce the runtime.
In case of blocks with many memory-accessing instructions, alias checking can take lot of time (because calculating the memory dependencies has quadratic complexity). I chose a limit which resulted in no changes when running the benchmarks. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226439 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -75,6 +75,10 @@ static const unsigned MinVecRegSize = 128;
|
|||||||
|
|
||||||
static const unsigned RecursionMaxDepth = 12;
|
static const unsigned RecursionMaxDepth = 12;
|
||||||
|
|
||||||
|
// Limit the number of alias checks. The limit is chosen so that
|
||||||
|
// it has no negative effect on the llvm benchmarks.
|
||||||
|
static const unsigned AliasedCheckLimit = 10;
|
||||||
|
|
||||||
/// \returns the parent basic block if all of the instructions in \p VL
|
/// \returns the parent basic block if all of the instructions in \p VL
|
||||||
/// are in the same block or null otherwise.
|
/// are in the same block or null otherwise.
|
||||||
static BasicBlock *getSameBlock(ArrayRef<Value *> VL) {
|
static BasicBlock *getSameBlock(ArrayRef<Value *> VL) {
|
||||||
@@ -2754,11 +2758,22 @@ void BoUpSLP::BlockScheduling::calculateDependencies(ScheduleData *SD,
|
|||||||
Instruction *SrcInst = BundleMember->Inst;
|
Instruction *SrcInst = BundleMember->Inst;
|
||||||
AliasAnalysis::Location SrcLoc = getLocation(SrcInst, SLP->AA);
|
AliasAnalysis::Location SrcLoc = getLocation(SrcInst, SLP->AA);
|
||||||
bool SrcMayWrite = BundleMember->Inst->mayWriteToMemory();
|
bool SrcMayWrite = BundleMember->Inst->mayWriteToMemory();
|
||||||
|
unsigned numAliased = 0;
|
||||||
|
|
||||||
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)) {
|
|
||||||
|
// Limit the number of alias checks, becaus SLP->isAliased() is
|
||||||
|
// the expensive part in the following loop.
|
||||||
|
if (numAliased >= AliasedCheckLimit
|
||||||
|
|| SLP->isAliased(SrcLoc, SrcInst, DepDest->Inst)) {
|
||||||
|
|
||||||
|
// We increment the counter only if the locations are aliased
|
||||||
|
// (instead of counting all alias checks). This gives a better
|
||||||
|
// balance between reduced runtime accurate dependencies.
|
||||||
|
numAliased++;
|
||||||
|
|
||||||
DepDest->MemoryDependencies.push_back(BundleMember);
|
DepDest->MemoryDependencies.push_back(BundleMember);
|
||||||
BundleMember->Dependencies++;
|
BundleMember->Dependencies++;
|
||||||
ScheduleData *DestBundle = DepDest->FirstInBundle;
|
ScheduleData *DestBundle = DepDest->FirstInBundle;
|
||||||
|
Reference in New Issue
Block a user