@@ -5574,22 +5574,7 @@ class BoUpSLP {
55745574 if (auto *SD = dyn_cast<ScheduleData>(Data)) {
55755575 SD->setScheduled(/*Scheduled=*/true);
55765576 LLVM_DEBUG(dbgs() << "SLP: schedule " << *SD << "\n");
5577- SmallVector<ScheduleBundle> PseudoBundles;
5578- SmallVector<ScheduleBundle *> Bundles;
5579- Instruction *In = SD->getInst();
5580- if (R.isVectorized(In)) {
5581- ArrayRef<TreeEntry *> Entries = R.getTreeEntries(In);
5582- for (TreeEntry *TE : Entries) {
5583- if (!isa<ExtractValueInst, ExtractElementInst, CallBase>(In) &&
5584- In->getNumOperands() != TE->getNumOperands())
5585- continue;
5586- ScheduleBundle &Bundle = PseudoBundles.emplace_back();
5587- Bundle.setTreeEntry(TE);
5588- Bundle.add(SD);
5589- Bundles.push_back(&Bundle);
5590- }
5591- }
5592- ProcessBundleMember(SD, Bundles);
5577+ ProcessBundleMember(SD, {});
55935578 } else {
55945579 ScheduleBundle &Bundle = *cast<ScheduleBundle>(Data);
55955580 Bundle.setScheduled(/*Scheduled=*/true);
@@ -20868,7 +20853,23 @@ BoUpSLP::BlockScheduling::tryScheduleBundle(ArrayRef<Value *> VL, BoUpSLP *SLP,
2086820853 for (Value *V : VL) {
2086920854 if (S.isNonSchedulable(V))
2087020855 continue;
20871- if (!extendSchedulingRegion(V, S)) {
20856+ // For copybales with parent nodes, which do not need to be scheduled, the
20857+ // parents should not be commutative, otherwise may incorrectly handle deps
20858+ // because of the potential reordering of commutative operations.
20859+ if ((S.isCopyableElement(V) && EI.UserTE && !EI.UserTE->isGather() &&
20860+ EI.UserTE->hasState() && EI.UserTE->doesNotNeedToSchedule() &&
20861+ any_of(EI.UserTE->Scalars,
20862+ [&](Value *V) {
20863+ if (isa<PoisonValue>(V))
20864+ return false;
20865+ auto *I = dyn_cast<Instruction>(V);
20866+ return isCommutative(
20867+ (I && EI.UserTE->isAltShuffle())
20868+ ? EI.UserTE->getMatchingMainOpOrAltOp(I)
20869+ : EI.UserTE->getMainOp(),
20870+ V);
20871+ })) ||
20872+ !extendSchedulingRegion(V, S)) {
2087220873 // If the scheduling region got new instructions at the lower end (or it
2087320874 // is a new region for the first bundle). This makes it necessary to
2087420875 // recalculate all dependencies.
0 commit comments