@@ -13443,15 +13443,14 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
1344313443 for_each(SubMask, [&](int &Idx) {
1344413444 if (Idx == PoisonMaskElem)
1344513445 return;
13446- Idx = (Idx % VF) - (( MinElement / NewVF) * NewVF ) +
13446+ Idx = (Idx % VF) - (MinElement % VF ) +
1344713447 (Idx >= static_cast<int>(VF) ? NewVF : 0);
1344813448 });
13449- } else {
13450- NewVF = VF;
13449+ VF = NewVF;
1345113450 }
1345213451
1345313452 constexpr TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
13454- auto *VecTy = getWidenedType(VL.front()->getType(), NewVF );
13453+ auto *VecTy = getWidenedType(VL.front()->getType(), VF );
1345513454 auto *MaskVecTy = getWidenedType(VL.front()->getType(), SubMask.size());
1345613455 auto GetShuffleCost = [&,
1345713456 &TTI = *TTI](ArrayRef<int> Mask,
@@ -13476,7 +13475,7 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
1347613475 APInt DemandedElts = APInt::getAllOnes(SubMask.size());
1347713476 bool IsIdentity = true;
1347813477 for (auto [I, Idx] : enumerate(FirstMask)) {
13479- if (Idx >= static_cast<int>(NewVF )) {
13478+ if (Idx >= static_cast<int>(VF )) {
1348013479 Idx = PoisonMaskElem;
1348113480 } else {
1348213481 DemandedElts.clearBit(I);
@@ -13499,12 +13498,12 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
1349913498 APInt DemandedElts = APInt::getAllOnes(SubMask.size());
1350013499 bool IsIdentity = true;
1350113500 for (auto [I, Idx] : enumerate(SecondMask)) {
13502- if (Idx < static_cast<int>(NewVF ) && Idx >= 0) {
13501+ if (Idx < static_cast<int>(VF ) && Idx >= 0) {
1350313502 Idx = PoisonMaskElem;
1350413503 } else {
1350513504 DemandedElts.clearBit(I);
1350613505 if (Idx != PoisonMaskElem) {
13507- Idx -= NewVF ;
13506+ Idx -= VF ;
1350813507 IsIdentity &= static_cast<int>(I) == Idx;
1350913508 }
1351013509 }
@@ -13524,24 +13523,12 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
1352413523 /*Extract=*/false, CostKind);
1352513524 const TreeEntry *BestEntry = nullptr;
1352613525 if (FirstShuffleCost < ShuffleCost) {
13527- std::for_each(std::next(Mask.begin(), Part * VL.size()),
13528- std::next(Mask.begin(), (Part + 1) * VL.size()),
13529- [&](int &Idx) {
13530- if (Idx >= static_cast<int>(VF))
13531- Idx = PoisonMaskElem;
13532- });
13526+ copy(FirstMask, std::next(Mask.begin(), Part * VL.size()));
1353313527 BestEntry = Entries.front();
1353413528 ShuffleCost = FirstShuffleCost;
1353513529 }
1353613530 if (SecondShuffleCost < ShuffleCost) {
13537- std::for_each(std::next(Mask.begin(), Part * VL.size()),
13538- std::next(Mask.begin(), (Part + 1) * VL.size()),
13539- [&](int &Idx) {
13540- if (Idx < static_cast<int>(VF))
13541- Idx = PoisonMaskElem;
13542- else
13543- Idx -= VF;
13544- });
13531+ copy(SecondMask, std::next(Mask.begin(), Part * VL.size()));
1354513532 BestEntry = Entries[1];
1354613533 ShuffleCost = SecondShuffleCost;
1354713534 }
0 commit comments