Skip to content

Commit 968f346

Browse files
committed
MainOp may not be the first insturction in a bundle
1 parent ea092b6 commit 968f346

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8795,12 +8795,8 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
87958795

87968796
BlockScheduling &BS = *BSRef;
87978797

8798-
SmallVector<Value *> MainOpIsTheFirst(UniqueValues);
8799-
auto MainOpIter = find(MainOpIsTheFirst, S.getMainOp());
8800-
std::rotate(MainOpIsTheFirst.begin(), MainOpIter, std::next(MainOpIter));
8801-
88028798
std::optional<ScheduleData *> Bundle =
8803-
BS.tryScheduleBundle(MainOpIsTheFirst, this, S);
8799+
BS.tryScheduleBundle(UniqueValues, this, S);
88048800
#ifdef EXPENSIVE_CHECKS
88058801
// Make sure we didn't break any internal invariants
88068802
BS.verify();
@@ -17467,7 +17463,6 @@ BoUpSLP::BlockScheduling::buildBundle(ArrayRef<Value *> VL) {
1746717463
std::optional<BoUpSLP::ScheduleData *>
1746817464
BoUpSLP::BlockScheduling::tryScheduleBundle(ArrayRef<Value *> VL, BoUpSLP *SLP,
1746917465
const InstructionsState &S) {
17470-
assert(VL[0] == S.getMainOp() && "MainOp must be the first element of VL.");
1747117466
// No need to schedule PHIs, insertelement, extractelement and extractvalue
1747217467
// instructions.
1747317468
if (isa<PHINode>(S.getMainOp()) ||
@@ -17557,21 +17552,21 @@ BoUpSLP::BlockScheduling::tryScheduleBundle(ArrayRef<Value *> VL, BoUpSLP *SLP,
1755717552
auto *Bundle = buildBundle(VL);
1755817553
TryScheduleBundleImpl(ReSchedule, Bundle);
1755917554
if (!Bundle->isReady()) {
17560-
cancelScheduling(VL, S.getMainOp());
17555+
cancelScheduling(VL, Bundle->Inst);
1756117556
return std::nullopt;
1756217557
}
1756317558
return Bundle;
1756417559
}
1756517560

1756617561
void BoUpSLP::BlockScheduling::cancelScheduling(ArrayRef<Value *> VL,
17567-
Value *OpValue) {
17568-
if (isa<PHINode>(OpValue) || isVectorLikeInstWithConstOps(OpValue) ||
17562+
Value *Inst) {
17563+
if (isa<PHINode>(Inst) || isVectorLikeInstWithConstOps(Inst) ||
1756917564
doesNotNeedToSchedule(VL))
1757017565
return;
1757117566

17572-
if (doesNotNeedToBeScheduled(OpValue))
17573-
OpValue = *find_if_not(VL, doesNotNeedToBeScheduled);
17574-
ScheduleData *Bundle = getScheduleData(OpValue);
17567+
if (doesNotNeedToBeScheduled(Inst))
17568+
Inst = *find_if_not(VL, doesNotNeedToBeScheduled);
17569+
ScheduleData *Bundle = getScheduleData(Inst);
1757517570
LLVM_DEBUG(dbgs() << "SLP: cancel scheduling of " << *Bundle << "\n");
1757617571
assert(!Bundle->IsScheduled &&
1757717572
"Can't cancel bundle which is already scheduled");

0 commit comments

Comments
 (0)