@@ -15727,13 +15727,10 @@ InstructionCost BoUpSLP::getGatherCost(ArrayRef<Value *> VL, bool ForPoisonSrc,
1572715727 Type *ScalarTy) const {
1572815728 const unsigned VF = VL.size();
1572915729 auto *VecTy = getWidenedType(ScalarTy, VF);
15730- bool DuplicateNonConst = false;
1573115730 // Find the cost of inserting/extracting values from the vector.
1573215731 // Check if the same elements are inserted several times and count them as
1573315732 // shuffle candidates.
15734- APInt ShuffledElements = APInt::getZero(VF);
1573515733 APInt DemandedElements = APInt::getZero(VF);
15736- DenseMap<Value *, unsigned> UniqueElements;
1573715734 constexpr TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
1573815735 InstructionCost Cost;
1573915736 auto EstimateInsertCost = [&](unsigned I, Value *V) {
@@ -15742,32 +15739,18 @@ InstructionCost BoUpSLP::getGatherCost(ArrayRef<Value *> VL, bool ForPoisonSrc,
1574215739 Cost += TTI->getCastInstrCost(Instruction::Trunc, ScalarTy, V->getType(),
1574315740 TTI::CastContextHint::None, CostKind);
1574415741 };
15745- SmallVector<int> ShuffleMask(VF, PoisonMaskElem);
1574615742 SmallVector<int> ConstantShuffleMask(VF, PoisonMaskElem);
1574715743 std::iota(ConstantShuffleMask.begin(), ConstantShuffleMask.end(), 0);
1574815744 for (auto [I, V] : enumerate(VL)) {
1574915745 // No need to shuffle duplicates for constants.
15750- if ((ForPoisonSrc && isConstant(V)) || isa<UndefValue>(V)) {
15751- ShuffledElements.setBit(I);
15752- ShuffleMask[I] = isa<PoisonValue>(V) ? PoisonMaskElem : I;
15746+ if ((ForPoisonSrc && isConstant(V)) || isa<UndefValue>(V))
1575315747 continue;
15754- }
1575515748
1575615749 if (isConstant(V)) {
1575715750 ConstantShuffleMask[I] = I + VF;
15758- ShuffleMask[I] = I;
15759- continue;
15760- }
15761- auto Res = UniqueElements.try_emplace(V, I);
15762- if (Res.second) {
15763- EstimateInsertCost(I, V);
15764- ShuffleMask[I] = I;
1576515751 continue;
1576615752 }
15767-
15768- DuplicateNonConst = true;
15769- ShuffledElements.setBit(I);
15770- ShuffleMask[I] = Res.first->second;
15753+ EstimateInsertCost(I, V);
1577115754 }
1577215755 // FIXME: add a cost for constant vector materialization.
1577315756 bool IsAnyNonUndefConst =
@@ -15776,15 +15759,6 @@ InstructionCost BoUpSLP::getGatherCost(ArrayRef<Value *> VL, bool ForPoisonSrc,
1577615759 if (!ForPoisonSrc && IsAnyNonUndefConst) {
1577715760 Cost += ::getShuffleCost(*TTI, TargetTransformInfo::SK_PermuteTwoSrc, VecTy,
1577815761 ConstantShuffleMask);
15779- // Update the shuffle mask for shuffling with incoming source (all elements
15780- // are used!) or with constant subvector.
15781- for_each(enumerate(ShuffleMask), [&](auto P) {
15782- if ((!ForPoisonSrc && P.value() == PoisonMaskElem) ||
15783- ConstantShuffleMask[P.index()] != PoisonMaskElem)
15784- P.value() = P.index();
15785- else if (P.value() != PoisonMaskElem)
15786- P.value() += VF;
15787- });
1578815762 }
1578915763
1579015764 // 2. Insert unique non-constants.
@@ -15793,10 +15767,6 @@ InstructionCost BoUpSLP::getGatherCost(ArrayRef<Value *> VL, bool ForPoisonSrc,
1579315767 /*Insert=*/true,
1579415768 /*Extract=*/false, CostKind,
1579515769 ForPoisonSrc && !IsAnyNonUndefConst, VL);
15796- // 3. Shuffle duplicates.
15797- if (DuplicateNonConst)
15798- Cost += ::getShuffleCost(*TTI, TargetTransformInfo::SK_PermuteSingleSrc,
15799- VecTy, ShuffleMask, CostKind);
1580015770 return Cost;
1580115771}
1580215772
0 commit comments