[llvm] a83441e - Revert "[SLP] Simplify extendSchedulingRegion"
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 23 13:12:14 PST 2022
Author: Philip Reames
Date: 2022-02-23T13:12:07-08:00
New Revision: a83441e8cdb2b59e9bd6b8ec6ac1ead27a664ad4
URL: https://github.com/llvm/llvm-project/commit/a83441e8cdb2b59e9bd6b8ec6ac1ead27a664ad4
DIFF: https://github.com/llvm/llvm-project/commit/a83441e8cdb2b59e9bd6b8ec6ac1ead27a664ad4.diff
LOG: Revert "[SLP] Simplify extendSchedulingRegion"
This reverts commit 8c85f3a0523070ef656e30e368df0a679c1400cd.
Added:
Modified:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 921662ad6cb8..47e23fb636e5 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -7618,8 +7618,21 @@ BoUpSLP::BlockScheduling::extendSchedulingRegion(Value *V,
LLVM_DEBUG(dbgs() << "SLP: initialize schedule region to " << *I << "\n");
return;
}
-
- if (I->comesBefore(ScheduleStart)) {
+ // Search up and down at the same time, because we don't know if the new
+ // instruction is above or below the existing scheduling region.
+ BasicBlock::reverse_iterator UpIter =
+ ++ScheduleStart->getIterator().getReverse();
+ BasicBlock::reverse_iterator UpperEnd = BB->rend();
+ BasicBlock::iterator DownIter = ScheduleEnd->getIterator();
+ BasicBlock::iterator LowerEnd = BB->end();
+ while (UpIter != UpperEnd && DownIter != LowerEnd && &*UpIter != I &&
+ &*DownIter != I) {
+ ++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)
@@ -7628,14 +7641,17 @@ BoUpSLP::BlockScheduling::extendSchedulingRegion(Value *V,
<< "\n");
return;
}
-
- auto *NextI = I->getNextNode();
- assert(NextI && "tried to vectorize a terminator?");
- assert(ScheduleEnd->comesBefore(NextI) && "must extend?");
- initScheduleData(ScheduleEnd, NextI, LastLoadStoreInRegion, nullptr);
- ScheduleEnd = NextI;
+ 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;
}
More information about the llvm-commits
mailing list