@@ -5574,22 +5574,7 @@ class BoUpSLP {
5574
5574
if (auto *SD = dyn_cast<ScheduleData>(Data)) {
5575
5575
SD->setScheduled(/*Scheduled=*/true);
5576
5576
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, {});
5593
5578
} else {
5594
5579
ScheduleBundle &Bundle = *cast<ScheduleBundle>(Data);
5595
5580
Bundle.setScheduled(/*Scheduled=*/true);
@@ -20868,7 +20853,23 @@ BoUpSLP::BlockScheduling::tryScheduleBundle(ArrayRef<Value *> VL, BoUpSLP *SLP,
20868
20853
for (Value *V : VL) {
20869
20854
if (S.isNonSchedulable(V))
20870
20855
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)) {
20872
20873
// If the scheduling region got new instructions at the lower end (or it
20873
20874
// is a new region for the first bundle). This makes it necessary to
20874
20875
// recalculate all dependencies.
0 commit comments