[llvm] 19b1d3b - Reland [SLP] Provide an universal interface for FixedVectorType::get. NFC.
Han-Kuan Chen via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 29 23:16:41 PDT 2023
Author: Han-Kuan Chen
Date: 2023-06-29T23:15:52-07:00
New Revision: 19b1d3bd7eeecbeb1e45045960faf325c7bc5c64
URL: https://github.com/llvm/llvm-project/commit/19b1d3bd7eeecbeb1e45045960faf325c7bc5c64
DIFF: https://github.com/llvm/llvm-project/commit/19b1d3bd7eeecbeb1e45045960faf325c7bc5c64.diff
LOG: Reland [SLP] Provide an universal interface for FixedVectorType::get. NFC.
Differential Revision: https://reviews.llvm.org/D154114
Added:
Modified:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 82563091f7ce0d..0e87c5dc56a4f4 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -1079,6 +1079,10 @@ static bool doesNotNeedToSchedule(ArrayRef<Value *> VL) {
(all_of(VL, isUsedOutsideBlock) || all_of(VL, areAllOperandsNonInsts));
}
+static FixedVectorType *makeScalarTyToVectorTy(Type *ScalarTy, unsigned VF) {
+ return FixedVectorType::get(ScalarTy, VF);
+}
+
namespace slpvectorizer {
/// Bottom Up SLP Vectorizer.
@@ -1428,7 +1432,7 @@ class BoUpSLP {
if (getUnderlyingObject(LI1->getPointerOperand()) ==
getUnderlyingObject(LI2->getPointerOperand()) &&
R.TTI->isLegalMaskedGather(
- FixedVectorType::get(LI1->getType(), NumLanes),
+ makeScalarTyToVectorTy(LI1->getType(), NumLanes),
LI1->getAlign()))
return LookAheadHeuristics::ScoreMaskedGatherCandidate;
return LookAheadHeuristics::ScoreFail;
@@ -3920,7 +3924,7 @@ static LoadsState canVectorizeLoads(ArrayRef<Value *> VL, const Value *VL0,
for (Value *V : VL)
CommonAlignment =
std::min(CommonAlignment, cast<LoadInst>(V)->getAlign());
- auto *VecTy = FixedVectorType::get(ScalarTy, VL.size());
+ FixedVectorType *VecTy = makeScalarTyToVectorTy(ScalarTy, VL.size());
if (TTI.isLegalMaskedGather(VecTy, CommonAlignment) &&
!TTI.forceScalarizeMaskedGather(VecTy, CommonAlignment))
return LoadsState::ScatterVectorize;
@@ -4221,7 +4225,8 @@ BoUpSLP::getReorderingData(const TreeEntry &TE, bool TopToBottom) {
find_if(TE.Scalars, [](Value *V) { return !isConstant(V); });
if (It == TE.Scalars.begin())
return OrdersType();
- auto *Ty = FixedVectorType::get(TE.Scalars.front()->getType(), Sz);
+ FixedVectorType *Ty =
+ makeScalarTyToVectorTy(TE.Scalars.front()->getType(), Sz);
if (It != TE.Scalars.end()) {
OrdersType Order(Sz, Sz);
unsigned Idx = std::distance(TE.Scalars.begin(), It);
@@ -4333,8 +4338,8 @@ void BoUpSLP::reorderTopToBottom() {
// x86. Reordering them into [fsub,fadd] blocks this pattern. So we need
// to take into account their order when looking for the most used order.
if (TE->isAltShuffle()) {
- VectorType *VecTy =
- FixedVectorType::get(TE->Scalars[0]->getType(), TE->Scalars.size());
+ FixedVectorType *VecTy =
+ makeScalarTyToVectorTy(TE->Scalars[0]->getType(), TE->Scalars.size());
unsigned Opcode0 = TE->getOpcode();
unsigned Opcode1 = TE->getAltOpcode();
// The opcode mask selects between the two opcodes.
@@ -6171,7 +6176,7 @@ unsigned BoUpSLP::canMapToVector(Type *T, const DataLayout &DL) const {
if (!isValidElementType(EltTy))
return 0;
- uint64_t VTSize = DL.getTypeStoreSizeInBits(FixedVectorType::get(EltTy, N));
+ uint64_t VTSize = DL.getTypeStoreSizeInBits(makeScalarTyToVectorTy(EltTy, N));
if (VTSize < MinVecRegSize || VTSize > MaxVecRegSize || VTSize != DL.getTypeStoreSizeInBits(T))
return 0;
return N;
@@ -6277,7 +6282,7 @@ getVectorCallCosts(CallInst *CI, FixedVectorType *VecTy,
SmallVector<Type *, 4> VecTys;
for (Use &Arg : CI->args())
VecTys.push_back(
- FixedVectorType::get(Arg->getType(), VecTy->getNumElements()));
+ makeScalarTyToVectorTy(Arg->getType(), VecTy->getNumElements()));
FastMathFlags FMF;
if (auto *FPCI = dyn_cast<FPMathOperator>(CI))
FMF = FPCI->getFastMathFlags();
@@ -6751,7 +6756,8 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
InstructionCost getBuildVectorCost(ArrayRef<Value *> VL, Value *Root) {
if ((!Root && allConstant(VL)) || all_of(VL, UndefValue::classof))
return TTI::TCC_Free;
- auto *VecTy = FixedVectorType::get(VL.front()->getType(), VL.size());
+ FixedVectorType *VecTy =
+ makeScalarTyToVectorTy(VL.front()->getType(), VL.size());
InstructionCost GatherCost = 0;
SmallVector<Value *> Gathers(VL.begin(), VL.end());
// Improve gather cost for gather of loads, if we can group some of the
@@ -6828,7 +6834,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
LI->getAlign(), LI->getPointerAddressSpace(),
CostKind, TTI::OperandValueInfo(), LI);
}
- auto *LoadTy = FixedVectorType::get(LI->getType(), VF);
+ FixedVectorType *LoadTy = makeScalarTyToVectorTy(LI->getType(), VF);
Align Alignment = LI->getAlign();
GatherCost +=
VectorizedCnt *
@@ -6878,7 +6884,8 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
/// extracted values from \p VL.
InstructionCost computeExtractCost(ArrayRef<Value *> VL, ArrayRef<int> Mask,
TTI::ShuffleKind ShuffleKind) {
- auto *VecTy = FixedVectorType::get(VL.front()->getType(), VL.size());
+ FixedVectorType *VecTy =
+ makeScalarTyToVectorTy(VL.front()->getType(), VL.size());
unsigned NumOfParts = TTI.getNumberOfParts(VecTy);
if (ShuffleKind != TargetTransformInfo::SK_PermuteSingleSrc ||
@@ -6930,7 +6937,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
// cost to extract the vector with EltsPerVector elements.
Cost += TTI.getShuffleCost(
TargetTransformInfo::SK_PermuteSingleSrc,
- FixedVectorType::get(VecTy->getElementType(), EltsPerVector),
+ makeScalarTyToVectorTy(VecTy->getElementType(), EltsPerVector),
RegMask);
}
return Cost;
@@ -6959,7 +6966,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
return TTI::TCC_Free;
return TTI.getShuffleCost(
TTI::SK_PermuteTwoSrc,
- FixedVectorType::get(
+ makeScalarTyToVectorTy(
cast<VectorType>(V1->getType())->getElementType(), Mask.size()),
Mask);
}
@@ -6969,7 +6976,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
return TTI::TCC_Free;
return TTI.getShuffleCost(
TTI::SK_PermuteSingleSrc,
- FixedVectorType::get(
+ makeScalarTyToVectorTy(
cast<VectorType>(V1->getType())->getElementType(), Mask.size()),
Mask);
}
@@ -7003,7 +7010,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
CommonVF = VF = E->Scalars.size();
}
V1 = Constant::getNullValue(
- FixedVectorType::get(E->Scalars.front()->getType(), VF));
+ makeScalarTyToVectorTy(E->Scalars.front()->getType(), VF));
}
if (!V2 && !P2.isNull()) {
const TreeEntry *E = P2.get<const TreeEntry *>();
@@ -7014,7 +7021,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
if (CommonVF)
VF = CommonVF;
V2 = Constant::getNullValue(
- FixedVectorType::get(E->Scalars.front()->getType(), VF));
+ makeScalarTyToVectorTy(E->Scalars.front()->getType(), VF));
}
return BaseShuffleAnalysis::createShuffle<InstructionCost>(V1, V2, Mask,
Builder);
@@ -7032,7 +7039,8 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
return nullptr;
Value *VecBase = nullptr;
ArrayRef<Value *> VL = E->Scalars;
- auto *VecTy = FixedVectorType::get(VL.front()->getType(), VL.size());
+ FixedVectorType *VecTy =
+ makeScalarTyToVectorTy(VL.front()->getType(), VL.size());
// If the resulting type is scalarized, do not adjust the cost.
unsigned VecNumParts = TTI.getNumberOfParts(VecTy);
if (VecNumParts == VecTy->getNumElements())
@@ -7102,8 +7110,8 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
// Need to round up the subvector type vectorization factor to avoid a
// crash in cost model functions. Make SubVT so that Idx + VF of SubVT
// <= EENumElts.
- auto *SubVT =
- FixedVectorType::get(VecTy->getElementType(), EENumElts - Idx);
+ FixedVectorType *SubVT =
+ makeScalarTyToVectorTy(VecTy->getElementType(), EENumElts - Idx);
Cost += TTI.getShuffleCost(TargetTransformInfo::SK_ExtractSubvector,
EEVTy, std::nullopt, CostKind, Idx, SubVT);
}
@@ -7174,7 +7182,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
"Expected vector length for the final value before action.");
Value *V = Vec.dyn_cast<Value *>();
if (!Vec.isNull() && !V)
- V = Constant::getNullValue(FixedVectorType::get(
+ V = Constant::getNullValue(makeScalarTyToVectorTy(
Vec.get<const TreeEntry *>()->Scalars.front()->getType(),
CommonMask.size()));
Action(V, CommonMask);
@@ -7210,16 +7218,17 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
ScalarTy = CI->getOperand(0)->getType();
else if (auto *IE = dyn_cast<InsertElementInst>(VL[0]))
ScalarTy = IE->getOperand(1)->getType();
- auto *VecTy = FixedVectorType::get(ScalarTy, VL.size());
+ FixedVectorType *VecTy = makeScalarTyToVectorTy(ScalarTy, VL.size());
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
// If we have computed a smaller type for the expression, update VecTy so
// that the costs will be accurate.
if (MinBWs.count(VL[0]))
- VecTy = FixedVectorType::get(
+ VecTy = makeScalarTyToVectorTy(
IntegerType::get(F->getContext(), MinBWs[VL[0]].first), VL.size());
unsigned EntryVF = E->getVectorFactor();
- auto *FinalVecTy = FixedVectorType::get(VecTy->getElementType(), EntryVF);
+ FixedVectorType *FinalVecTy =
+ makeScalarTyToVectorTy(VecTy->getElementType(), EntryVF);
bool NeedToShuffleReuses = !E->ReuseShuffleIndices.empty();
if (E->State == TreeEntry::NeedToGather) {
@@ -7307,10 +7316,10 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
return Estimator.finalize(
E->ReuseShuffleIndices, E->Scalars.size(),
[&](Value *&Vec, SmallVectorImpl<int> &Mask) {
- Vec = Estimator.gather(GatheredScalars,
- Constant::getNullValue(FixedVectorType::get(
- GatheredScalars.front()->getType(),
- GatheredScalars.size())));
+ Vec = Estimator.gather(
+ GatheredScalars, Constant::getNullValue(makeScalarTyToVectorTy(
+ GatheredScalars.front()->getType(),
+ GatheredScalars.size())));
});
}
if (!all_of(GatheredScalars, PoisonValue::classof)) {
@@ -7318,7 +7327,7 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
bool SameGathers = VL.equals(Gathers);
Value *BV = Estimator.gather(
Gathers, SameGathers ? nullptr
- : Constant::getNullValue(FixedVectorType::get(
+ : Constant::getNullValue(makeScalarTyToVectorTy(
GatheredScalars.front()->getType(),
GatheredScalars.size())));
SmallVector<int> ReuseMask(Gathers.size(), PoisonMaskElem);
@@ -7500,7 +7509,7 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
NumElts = ATy->getNumElements();
else
NumElts = AggregateTy->getStructNumElements();
- SrcVecTy = FixedVectorType::get(ScalarTy, NumElts);
+ SrcVecTy = makeScalarTyToVectorTy(ScalarTy, NumElts);
}
if (I->hasOneUse()) {
Instruction *Ext = I->user_back();
@@ -7595,8 +7604,8 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
// need to shift the vector.
// Do not calculate the cost if the actual size is the register size and
// we can merge this shuffle with the following SK_Select.
- auto *InsertVecTy =
- FixedVectorType::get(SrcVecTy->getElementType(), InsertVecSz);
+ FixedVectorType *InsertVecTy =
+ makeScalarTyToVectorTy(SrcVecTy->getElementType(), InsertVecSz);
if (!IsIdentity)
Cost += TTI->getShuffleCost(TargetTransformInfo::SK_PermuteSingleSrc,
InsertVecTy, Mask);
@@ -7612,8 +7621,8 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
buildUseMask(NumElts, InsertMask, UseMask::UndefsAsMask));
if (!InMask.all() && NumScalars != NumElts && !IsWholeSubvector) {
if (InsertVecSz != VecSz) {
- auto *ActualVecTy =
- FixedVectorType::get(SrcVecTy->getElementType(), VecSz);
+ FixedVectorType *ActualVecTy =
+ makeScalarTyToVectorTy(SrcVecTy->getElementType(), VecSz);
Cost += TTI->getShuffleCost(TTI::SK_InsertSubvector, ActualVecTy,
std::nullopt, CostKind, OffsetBeg - Offset,
InsertVecTy);
@@ -7652,7 +7661,7 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
};
auto GetVectorCost = [=](InstructionCost CommonCost) {
Type *SrcTy = VL0->getOperand(0)->getType();
- auto *SrcVecTy = FixedVectorType::get(SrcTy, VL.size());
+ FixedVectorType *SrcVecTy = makeScalarTyToVectorTy(SrcTy, VL.size());
InstructionCost VecCost = CommonCost;
// Check if the values are candidates to demote.
if (!MinBWs.count(VL0) || VecTy != SrcVecTy)
@@ -7693,7 +7702,8 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
VI);
};
auto GetVectorCost = [&](InstructionCost CommonCost) {
- auto *MaskTy = FixedVectorType::get(Builder.getInt1Ty(), VL.size());
+ FixedVectorType *MaskTy =
+ makeScalarTyToVectorTy(Builder.getInt1Ty(), VL.size());
InstructionCost VecCost = TTI->getCmpSelInstrCost(
E->getOpcode(), VecTy, MaskTy, VecPred, CostKind, VL0);
@@ -7893,7 +7903,8 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
VecCost +=
TTI->getArithmeticInstrCost(E->getAltOpcode(), VecTy, CostKind);
} else if (auto *CI0 = dyn_cast<CmpInst>(VL0)) {
- auto *MaskTy = FixedVectorType::get(Builder.getInt1Ty(), VL.size());
+ FixedVectorType *MaskTy =
+ makeScalarTyToVectorTy(Builder.getInt1Ty(), VL.size());
VecCost = TTI->getCmpSelInstrCost(E->getOpcode(), VecTy, MaskTy,
CI0->getPredicate(), CostKind, VL0);
VecCost += TTI->getCmpSelInstrCost(
@@ -7903,8 +7914,8 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
} else {
Type *Src0SclTy = E->getMainOp()->getOperand(0)->getType();
Type *Src1SclTy = E->getAltOp()->getOperand(0)->getType();
- auto *Src0Ty = FixedVectorType::get(Src0SclTy, VL.size());
- auto *Src1Ty = FixedVectorType::get(Src1SclTy, VL.size());
+ FixedVectorType *Src0Ty = makeScalarTyToVectorTy(Src0SclTy, VL.size());
+ FixedVectorType *Src1Ty = makeScalarTyToVectorTy(Src1SclTy, VL.size());
VecCost = TTI->getCastInstrCost(E->getOpcode(), VecTy, Src0Ty,
TTI::CastContextHint::None, CostKind);
VecCost += TTI->getCastInstrCost(E->getAltOpcode(), VecTy, Src1Ty,
@@ -8184,7 +8195,7 @@ InstructionCost BoUpSLP::getSpillCost() const {
auto *ScalarTy = II->getType();
if (auto *VectorTy = dyn_cast<FixedVectorType>(ScalarTy))
ScalarTy = VectorTy->getElementType();
- V.push_back(FixedVectorType::get(ScalarTy, BundleWidth));
+ V.push_back(makeScalarTyToVectorTy(ScalarTy, BundleWidth));
}
Cost += NumCalls * TTI->getCostOfKeepingLiveOverCall(V);
}
@@ -8480,14 +8491,15 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals) {
// If we plan to rewrite the tree in a smaller type, we will need to sign
// extend the extracted value back to the original type. Here, we account
// for the extract and the added cost of the sign extend if needed.
- auto *VecTy = FixedVectorType::get(EU.Scalar->getType(), BundleWidth);
+ FixedVectorType *VecTy =
+ makeScalarTyToVectorTy(EU.Scalar->getType(), BundleWidth);
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
auto *ScalarRoot = VectorizableTree[0]->Scalars[0];
if (MinBWs.count(ScalarRoot)) {
auto *MinTy = IntegerType::get(F->getContext(), MinBWs[ScalarRoot].first);
auto Extend =
MinBWs[ScalarRoot].second ? Instruction::SExt : Instruction::ZExt;
- VecTy = FixedVectorType::get(MinTy, BundleWidth);
+ VecTy = makeScalarTyToVectorTy(MinTy, BundleWidth);
ExtractCost += TTI->getExtractWithExtendCost(Extend, EU.Scalar->getType(),
VecTy, EU.Lane);
} else {
@@ -8513,7 +8525,7 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals) {
OrigMask.begin());
C = TTI->getShuffleCost(
TTI::SK_PermuteSingleSrc,
- FixedVectorType::get(TE->getMainOp()->getType(), VecVF), OrigMask);
+ makeScalarTyToVectorTy(TE->getMainOp()->getType(), VecVF), OrigMask);
LLVM_DEBUG(
dbgs() << "SLP: Adding cost " << C
<< " for final shuffle of insertelement external users.\n";
@@ -8527,7 +8539,7 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals) {
for (int I = 0, E = FirstUsers.size(); I < E; ++I) {
Value *Base = cast<Instruction>(FirstUsers[I].first)->getOperand(0);
unsigned VF = ShuffleMasks[I].begin()->second.size();
- auto *FTy = FixedVectorType::get(
+ FixedVectorType *FTy = makeScalarTyToVectorTy(
cast<VectorType>(FirstUsers[I].first->getType())->getElementType(), VF);
auto Vector = ShuffleMasks[I].takeVector();
auto &&EstimateShufflesCost = [this, FTy,
@@ -8932,7 +8944,7 @@ InstructionCost BoUpSLP::getGatherCost(ArrayRef<Value *> VL,
Type *ScalarTy = VL[0]->getType();
if (StoreInst *SI = dyn_cast<StoreInst>(VL[0]))
ScalarTy = SI->getValueOperand()->getType();
- auto *VecTy = FixedVectorType::get(ScalarTy, VL.size());
+ FixedVectorType *VecTy = makeScalarTyToVectorTy(ScalarTy, VL.size());
bool DuplicateNonConst = false;
// Find the cost of inserting/extracting values from the vector.
// Check if the same elements are inserted several times and count them as
@@ -9194,7 +9206,7 @@ Value *BoUpSLP::gather(ArrayRef<Value *> VL, Value *Root) {
};
Value *Val0 =
isa<StoreInst>(VL[0]) ? cast<StoreInst>(VL[0])->getValueOperand() : VL[0];
- FixedVectorType *VecTy = FixedVectorType::get(Val0->getType(), VL.size());
+ FixedVectorType *VecTy = makeScalarTyToVectorTy(Val0->getType(), VL.size());
Value *Vec = Root ? Root : PoisonValue::get(VecTy);
SmallVector<int> NonConsts;
// Insert constant values at first.
@@ -9317,7 +9329,7 @@ class BoUpSLP::ShuffleInstructionBuilder final : public BaseShuffleAnalysis {
}
Value *createIdentity(Value *V) { return V; }
Value *createPoison(Type *Ty, unsigned VF) {
- return PoisonValue::get(FixedVectorType::get(Ty, VF));
+ return PoisonValue::get(makeScalarTyToVectorTy(Ty, VF));
}
/// Resizes 2 input vector to match the sizes, if the they are not equal
/// yet. The smallest vector is resized to the size of the larger vector.
@@ -9395,8 +9407,8 @@ class BoUpSLP::ShuffleInstructionBuilder final : public BaseShuffleAnalysis {
return nullptr;
// Postpone gather emission, will be emitted after the end of the
// process to keep correct order.
- auto *VecTy = FixedVectorType::get(E->Scalars.front()->getType(),
- E->getVectorFactor());
+ FixedVectorType *VecTy = makeScalarTyToVectorTy(
+ E->Scalars.front()->getType(), E->getVectorFactor());
return Builder.CreateAlignedLoad(
VecTy, PoisonValue::get(PointerType::getUnqual(VecTy->getContext())),
MaybeAlign());
@@ -9912,7 +9924,7 @@ ResTy BoUpSLP::processBuildVector(const TreeEntry *E, Args &...Params) {
ShuffleBuilder.add(Vec1, ExtractMask);
IsNonPoisoned &= isGuaranteedNotToBePoison(Vec1);
} else {
- ShuffleBuilder.add(PoisonValue::get(FixedVectorType::get(
+ ShuffleBuilder.add(PoisonValue::get(makeScalarTyToVectorTy(
ScalarTy, GatheredScalars.size())),
ExtractMask);
}
@@ -10063,7 +10075,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
ScalarTy = Store->getValueOperand()->getType();
else if (auto *IE = dyn_cast<InsertElementInst>(VL0))
ScalarTy = IE->getOperand(1)->getType();
- auto *VecTy = FixedVectorType::get(ScalarTy, E->Scalars.size());
+ FixedVectorType *VecTy = makeScalarTyToVectorTy(ScalarTy, E->Scalars.size());
switch (ShuffleOrOp) {
case Instruction::PHI: {
assert((E->ReorderIndices.empty() ||
@@ -10504,7 +10516,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
// Add return type if intrinsic is overloaded on it.
if (isVectorIntrinsicWithOverloadTypeAtArg(IID, -1))
TysForDecl.push_back(
- FixedVectorType::get(CI->getType(), E->Scalars.size()));
+ makeScalarTyToVectorTy(CI->getType(), E->Scalars.size()));
for (int j = 0, e = CI->arg_size(); j < e; ++j) {
ValueList OpVL;
// Some intrinsics have scalar arguments. This argument should not be
@@ -10738,7 +10750,7 @@ Value *BoUpSLP::vectorizeTree(
}
auto BundleWidth = VectorizableTree[0]->Scalars.size();
auto *MinTy = IntegerType::get(F->getContext(), MinBWs[ScalarRoot].first);
- auto *VecTy = FixedVectorType::get(MinTy, BundleWidth);
+ FixedVectorType *VecTy = makeScalarTyToVectorTy(MinTy, BundleWidth);
auto *Trunc = Builder.CreateTrunc(VectorRoot, VecTy);
VectorizableTree[0]->VectorizedValue = Trunc;
}
@@ -11189,8 +11201,8 @@ void BoUpSLP::optimizeGatherSequence() {
return SM1.size() - LastUndefsCnt > 1 &&
TTI->getNumberOfParts(SI1->getType()) ==
TTI->getNumberOfParts(
- FixedVectorType::get(SI1->getType()->getElementType(),
- SM1.size() - LastUndefsCnt));
+ makeScalarTyToVectorTy(SI1->getType()->getElementType(),
+ SM1.size() - LastUndefsCnt));
};
// Perform O(N^2) search over the gather/shuffle sequences and merge identical
// instructions. TODO: We can further optimize this scan if we split the
@@ -12500,7 +12512,7 @@ bool SLPVectorizerPass::tryToVectorizeList(ArrayRef<Value *> VL, BoUpSLP &R,
// No actual vectorization should happen, if number of parts is the same as
// provided vectorization factor (i.e. the scalar type is used for vector
// code during codegen).
- auto *VecTy = FixedVectorType::get(ScalarTy, VF);
+ FixedVectorType *VecTy = makeScalarTyToVectorTy(ScalarTy, VF);
if (TTI->getNumberOfParts(VecTy) == VF)
continue;
for (unsigned I = NextInst; I < MaxInst; ++I) {
@@ -13747,7 +13759,7 @@ class HorizontalReduction {
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
Value *FirstReducedVal = ReducedVals.front();
Type *ScalarTy = FirstReducedVal->getType();
- FixedVectorType *VectorTy = FixedVectorType::get(ScalarTy, ReduxWidth);
+ FixedVectorType *VectorTy = makeScalarTyToVectorTy(ScalarTy, ReduxWidth);
InstructionCost VectorCost = 0, ScalarCost;
// If all of the reduced values are constant, the vector cost is 0, since
// the reduction value can be calculated at the compile time.
More information about the llvm-commits
mailing list