Skip to content

Commit 4d1d668

Browse files
committed
[𝘀𝗽𝗿] initial version
Created using spr 1.3.5
1 parent d0e4af8 commit 4d1d668

File tree

1 file changed

+2
-32
lines changed

1 file changed

+2
-32
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15349,13 +15349,10 @@ InstructionCost BoUpSLP::getGatherCost(ArrayRef<Value *> VL, bool ForPoisonSrc,
1534915349
Type *ScalarTy) const {
1535015350
const unsigned VF = VL.size();
1535115351
auto *VecTy = getWidenedType(ScalarTy, VF);
15352-
bool DuplicateNonConst = false;
1535315352
// Find the cost of inserting/extracting values from the vector.
1535415353
// Check if the same elements are inserted several times and count them as
1535515354
// shuffle candidates.
15356-
APInt ShuffledElements = APInt::getZero(VF);
1535715355
APInt DemandedElements = APInt::getZero(VF);
15358-
DenseMap<Value *, unsigned> UniqueElements;
1535915356
constexpr TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
1536015357
InstructionCost Cost;
1536115358
auto EstimateInsertCost = [&](unsigned I, Value *V) {
@@ -15364,32 +15361,18 @@ InstructionCost BoUpSLP::getGatherCost(ArrayRef<Value *> VL, bool ForPoisonSrc,
1536415361
Cost += TTI->getCastInstrCost(Instruction::Trunc, ScalarTy, V->getType(),
1536515362
TTI::CastContextHint::None, CostKind);
1536615363
};
15367-
SmallVector<int> ShuffleMask(VF, PoisonMaskElem);
1536815364
SmallVector<int> ConstantShuffleMask(VF, PoisonMaskElem);
1536915365
std::iota(ConstantShuffleMask.begin(), ConstantShuffleMask.end(), 0);
1537015366
for (auto [I, V] : enumerate(VL)) {
1537115367
// No need to shuffle duplicates for constants.
15372-
if ((ForPoisonSrc && isConstant(V)) || isa<UndefValue>(V)) {
15373-
ShuffledElements.setBit(I);
15374-
ShuffleMask[I] = isa<PoisonValue>(V) ? PoisonMaskElem : I;
15368+
if ((ForPoisonSrc && isConstant(V)) || isa<UndefValue>(V))
1537515369
continue;
15376-
}
1537715370

1537815371
if (isConstant(V)) {
1537915372
ConstantShuffleMask[I] = I + VF;
15380-
ShuffleMask[I] = I;
15381-
continue;
15382-
}
15383-
auto Res = UniqueElements.try_emplace(V, I);
15384-
if (Res.second) {
15385-
EstimateInsertCost(I, V);
15386-
ShuffleMask[I] = I;
1538715373
continue;
1538815374
}
15389-
15390-
DuplicateNonConst = true;
15391-
ShuffledElements.setBit(I);
15392-
ShuffleMask[I] = Res.first->second;
15375+
EstimateInsertCost(I, V);
1539315376
}
1539415377
// FIXME: add a cost for constant vector materialization.
1539515378
bool IsAnyNonUndefConst =
@@ -15398,15 +15381,6 @@ InstructionCost BoUpSLP::getGatherCost(ArrayRef<Value *> VL, bool ForPoisonSrc,
1539815381
if (!ForPoisonSrc && IsAnyNonUndefConst) {
1539915382
Cost += ::getShuffleCost(*TTI, TargetTransformInfo::SK_PermuteTwoSrc, VecTy,
1540015383
ConstantShuffleMask);
15401-
// Update the shuffle mask for shuffling with incoming source (all elements
15402-
// are used!) or with constant subvector.
15403-
for_each(enumerate(ShuffleMask), [&](auto P) {
15404-
if ((!ForPoisonSrc && P.value() == PoisonMaskElem) ||
15405-
ConstantShuffleMask[P.index()] != PoisonMaskElem)
15406-
P.value() = P.index();
15407-
else if (P.value() != PoisonMaskElem)
15408-
P.value() += VF;
15409-
});
1541015384
}
1541115385

1541215386
// 2. Insert unique non-constants.
@@ -15415,10 +15389,6 @@ InstructionCost BoUpSLP::getGatherCost(ArrayRef<Value *> VL, bool ForPoisonSrc,
1541515389
/*Insert=*/true,
1541615390
/*Extract=*/false, CostKind,
1541715391
ForPoisonSrc && !IsAnyNonUndefConst, VL);
15418-
// 3. Shuffle duplicates.
15419-
if (DuplicateNonConst)
15420-
Cost += ::getShuffleCost(*TTI, TargetTransformInfo::SK_PermuteSingleSrc,
15421-
VecTy, ShuffleMask, CostKind);
1542215392
return Cost;
1542315393
}
1542415394

0 commit comments

Comments
 (0)