Skip to content

Commit 986fc02

Browse files
committed
[SLP][REVEC] Fix cost model for getBuildVectorCost with FixedVectorType
ScalarTy. BoUpSLP::gather always use CreateInsertVector for FixedVectorType ScalarTy.
1 parent 6d3d5f3 commit 986fc02

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9198,10 +9198,18 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
91989198
bool NeedShuffle =
91999199
count(VL, *It) > 1 &&
92009200
(VL.front() != *It || !all_of(VL.drop_front(), IsaPred<UndefValue>));
9201-
if (!NeedShuffle)
9201+
if (!NeedShuffle) {
9202+
if (isa<FixedVectorType>(ScalarTy)) {
9203+
assert(SLPReVec && "FixedVectorType is not expected.");
9204+
return TTI.getShuffleCost(
9205+
TTI::SK_InsertSubvector, VecTy, {}, CostKind,
9206+
std::distance(VL.begin(), It) * getNumElements(ScalarTy),
9207+
cast<FixedVectorType>(ScalarTy));
9208+
}
92029209
return TTI.getVectorInstrCost(Instruction::InsertElement, VecTy,
92039210
CostKind, std::distance(VL.begin(), It),
92049211
PoisonValue::get(VecTy), *It);
9212+
}
92059213

92069214
SmallVector<int> ShuffleMask(VL.size(), PoisonMaskElem);
92079215
transform(VL, ShuffleMask.begin(), [](Value *V) {

0 commit comments

Comments
 (0)