const TreeEntry *E2 = P2.get<const TreeEntry *>();
if (E->Scalars.size() == E2->Scalars.size())
CommonVF = VF = E->Scalars.size();
+ } else {
+ // P2 is empty, check that we have same node + reshuffle (if any).
+ if (E->Scalars.size() == Mask.size() && VF != Mask.size()) {
+ VF = E->Scalars.size();
+ SmallVector<int> CommonMask(Mask.begin(), Mask.end());
+ ::addMask(CommonMask, E->getCommonMask());
+ V1 = Constant::getNullValue(
+ FixedVectorType::get(E->Scalars.front()->getType(), VF));
+ return BaseShuffleAnalysis::createShuffle<InstructionCost>(
+ V1, nullptr, CommonMask, Builder);
+ }
}
V1 = Constant::getNullValue(
FixedVectorType::get(E->Scalars.front()->getType(), VF));
dbgs()
<< "SLP: perfect diamond match for gather bundle that starts with "
<< *VL.front() << ".\n");
- return 0;
+ // Restore the mask for previous partially matched values.
+ for (auto [I, V] : enumerate(E->Scalars)) {
+ if (isa<PoisonValue>(V)) {
+ Mask[I] = PoisonMaskElem;
+ continue;
+ }
+ if (Mask[I] == PoisonMaskElem)
+ Mask[I] = Entries.front()->findLaneForValue(V);
+ }
+ Estimator.add(Entries.front(), Mask);
+ return Estimator.finalize(E->ReuseShuffleIndices);
}
if (!Resized) {
unsigned VF1 = Entries.front()->getVectorFactor();