diff options
author | Alexey Bataev <a.bataev@outlook.com> | 2021-03-24 07:13:58 -0700 |
---|---|---|
committer | Alexey Bataev <a.bataev@outlook.com> | 2021-03-25 05:31:58 -0700 |
commit | 568c8741170fcaa6f7fa968578e1b99e94886b46 (patch) | |
tree | 0506be86113d6e29f2a8d3ee7a00c8d348caec99 /llvm/lib | |
parent | 8420a5332486c682c1aaddbcb58a571869d19832 (diff) | |
download | llvm-568c8741170fcaa6f7fa968578e1b99e94886b46.zip llvm-568c8741170fcaa6f7fa968578e1b99e94886b46.tar.gz llvm-568c8741170fcaa6f7fa968578e1b99e94886b46.tar.bz2 |
[SLP]Improve and simplify extendSchedulingRegion.
We do not need to scan further if the upper end or lower end of the
basic block is reached already and the instruction is not found. It
means that the instruction is definitely in the lower part of basic
block or in the upper block relatively.
This should improve compile time for the very big basic blocks.
Differential Revision: https://reviews.llvm.org/D99266
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index d128312..5c3d9d2 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -5338,41 +5338,39 @@ bool BoUpSLP::BlockScheduling::extendSchedulingRegion(Value *V, BasicBlock::reverse_iterator UpperEnd = BB->rend(); BasicBlock::iterator DownIter = ScheduleEnd->getIterator(); BasicBlock::iterator LowerEnd = BB->end(); - while (true) { + while (UpIter != UpperEnd && DownIter != LowerEnd && &*UpIter != I && + &*DownIter != I) { if (++ScheduleRegionSize > ScheduleRegionSizeLimit) { LLVM_DEBUG(dbgs() << "SLP: exceeded schedule region size limit\n"); return false; } - if (UpIter != UpperEnd) { - if (&*UpIter == I) { - initScheduleData(I, ScheduleStart, nullptr, FirstLoadStoreInRegion); - ScheduleStart = I; - if (isOneOf(S, I) != I) - CheckSheduleForI(I); - LLVM_DEBUG(dbgs() << "SLP: extend schedule region start to " << *I - << "\n"); - return true; - } - ++UpIter; - } - if (DownIter != LowerEnd) { - if (&*DownIter == I) { - initScheduleData(ScheduleEnd, I->getNextNode(), LastLoadStoreInRegion, - nullptr); - ScheduleEnd = I->getNextNode(); - if (isOneOf(S, I) != I) - CheckSheduleForI(I); - assert(ScheduleEnd && "tried to vectorize a terminator?"); - LLVM_DEBUG(dbgs() << "SLP: extend schedule region end to " << *I - << "\n"); - return true; - } - ++DownIter; - } - assert((UpIter != UpperEnd || DownIter != LowerEnd) && - "instruction not found in block"); + ++UpIter; + ++DownIter; + } + if (DownIter == LowerEnd || (UpIter != UpperEnd && &*UpIter == I)) { + assert(I->getParent() == ScheduleStart->getParent() && + "Instruction is in wrong basic block."); + initScheduleData(I, ScheduleStart, nullptr, FirstLoadStoreInRegion); + ScheduleStart = I; + if (isOneOf(S, I) != I) + CheckSheduleForI(I); + LLVM_DEBUG(dbgs() << "SLP: extend schedule region start to " << *I + << "\n"); + return true; } + assert((UpIter == UpperEnd || (DownIter != LowerEnd && &*DownIter == I)) && + "Expected to reach top of the basic block or instruction down the " + "lower end."); + assert(I->getParent() == ScheduleEnd->getParent() && + "Instruction is in wrong basic block."); + initScheduleData(ScheduleEnd, I->getNextNode(), LastLoadStoreInRegion, + nullptr); + ScheduleEnd = I->getNextNode(); + if (isOneOf(S, I) != I) + CheckSheduleForI(I); + assert(ScheduleEnd && "tried to vectorize a terminator?"); + LLVM_DEBUG(dbgs() << "SLP: extend schedule region end to " << *I << "\n"); return true; } |