42 return TTI.getShuffleCost(Kind, DstTy, Tp,
CostKind, Mask, Index, SubTp,
47 Mask, NumSrcElts, NumSubElts, Index)) {
48 if (Index + NumSubElts > NumSrcElts &&
49 Index + NumSrcElts <=
static_cast<int>(Mask.size()))
53 return TTI.getShuffleCost(Kind, DstTy, Tp,
CostKind, Mask, Index, SubTp,
57std::pair<InstructionCost, InstructionCost>
68 if (Opcode == Instruction::Load || Opcode == Instruction::Store) {
77 ScalarCost =
TTI.getPointersChainCost(
78 Ptrs, BasePtr, TTI::PointersChainInfo::getUnitStride(), ScalarTy,
82 for (
Value *V : Ptrs) {
92 if (!Ptr || !Ptr->hasOneUse())
96 if (PtrsRetainedInVecCode.
size() == Ptrs.size()) {
101 VecCost =
TTI.getPointersChainCost(PtrsRetainedInVecCode, BasePtr,
102 TTI::PointersChainInfo::getKnownStride(),
114 return Ptr && !Ptr->hasAllConstantIndices();
116 ? TTI::PointersChainInfo::getUnknownStride()
117 : TTI::PointersChainInfo::getKnownStride();
120 TTI.getPointersChainCost(Ptrs, BasePtr, PtrsInfo, ScalarTy,
CostKind);
124 if (It != Ptrs.
end())
129 VecCost =
TTI.getGEPCost(BaseGEP->getSourceElementType(),
130 BaseGEP->getPointerOperand(), Indices,
CostKind,
135 return std::make_pair(ScalarCost, VecCost);
142 return 2 *
TTI.getMemIntrinsicInstrCost(
146 TTI.getArithmeticInstrCost(Instruction::Xor, CmpTy,
CostKind) +
147 TTI.getCmpSelInstrCost(Instruction::Select, VecTy, CmpTy,
152 unsigned Opcode,
Type *ScalarTy,
167 {PaddedVecTy, PaddedVecTy, MaskTy});
169 if (!MaskedCost.isValid() || MaskedCost >= DirectCost)
172 *PaddedTy = PaddedVecTy;
179 const APInt &DemandedElts,
bool Insert,
bool Extract,
183 "ScalableVectorType is not supported.");
188 assert(ReVec &&
"Only supported by REVEC.");
191 unsigned ScalarTyNumElements = VecTy->getNumElements();
194 if (!DemandedElts[
I])
198 I * ScalarTyNumElements, VecTy);
201 I * ScalarTyNumElements, VecTy);
205 return TTI.getScalarizationOverhead(Ty, DemandedElts, Insert, Extract,
213 ArrayRef<std::tuple<Value *, User *, int>> ScalarUserAndIdx) {
214 if (Opcode == Instruction::ExtractElement) {
216 assert(ReVec &&
"Only supported by REVEC.");
220 Index * VecTy->getNumElements(), VecTy);
223 return TTI.getVectorInstrCost(Opcode, Val,
CostKind, Index, Scalar,
228 bool ReVec,
unsigned Opcode,
Type *Dst,
232 assert(ReVec &&
"Only supported by REVEC.");
240 return TTI.getExtractWithExtendCost(Opcode, Dst, VecTy, Index,
CostKind);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements a class to represent arbitrary precision integral constant values and operations...
static cl::opt< OutputCostKind > CostKind("cost-kind", cl::desc("Target cost kind"), cl::init(OutputCostKind::RecipThroughput), cl::values(clEnumValN(OutputCostKind::RecipThroughput, "throughput", "Reciprocal throughput"), clEnumValN(OutputCostKind::Latency, "latency", "Instruction latency"), clEnumValN(OutputCostKind::CodeSize, "code-size", "Code size"), clEnumValN(OutputCostKind::SizeAndLatency, "size-latency", "Code size and latency"), clEnumValN(OutputCostKind::All, "all", "Print all cost kinds")))
Provides some synthesis utilities to produce sequences of values.
This file defines the SmallVector class.
Class for arbitrary precision integers.
unsigned getBitWidth() const
Return the number of bits in the APInt.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
static Type * makeCmpResultType(Type *opnd_type)
Create a result type for fcmp/icmp.
Class to represent fixed width SIMD vectors.
unsigned getNumElements() const
static LLVM_ABI FixedVectorType * get(Type *ElementType, unsigned NumElts)
static InstructionCost getInvalid(CostType Val=0)
Information for memory intrinsic cost model.
static LLVM_ABI bool isInsertSubvectorMask(ArrayRef< int > Mask, int NumSrcElts, int &NumSubElts, int &Index)
Return true if this shuffle mask is an insert subvector mask.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
The instances of the Type class are immutable: once they are created, they are never changed.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
LLVM Value Representation.
Base class of all SIMD vector types.
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
A private "module" namespace for types and utilities used by this pass.
std::pair< InstructionCost, InstructionCost > getGEPCosts(const TargetTransformInfo &TTI, ArrayRef< Value * > Ptrs, Value *BasePtr, unsigned Opcode, const TTI::TargetCostKind CostKind, Type *ScalarTy, VectorType *VecTy)
Calculate the scalar and the vector costs from vectorizing set of GEPs.
Intrinsic::ID getMaskedDivRemIntrinsic(unsigned Opcode)
unsigned getNumElements(Type *Ty)
Type * getWidenedType(Type *ScalarTy, unsigned VF)
InstructionCost getShuffleCost(const TargetTransformInfo &TTI, TTI::ShuffleKind Kind, VectorType *Tp, const TTI::TargetCostKind CostKind, ArrayRef< int > Mask, int Index, VectorType *SubTp, ArrayRef< const Value * > Args)
Returns the cost of the shuffle instructions with the given Kind, vector type Tp and optional Mask.
InstructionCost getBlendedLoadCost(const TargetTransformInfo &TTI, Type *VecTy, Align Alignment, unsigned AddressSpace, const TTI::TargetCostKind CostKind)
Returns the cost of a BlendedLoadVectorize node loading VecTy: two masked loads (one per candidate ba...
FixedVectorType * getMaskedDivRemType(const TargetTransformInfo &TTI, unsigned Opcode, Type *ScalarTy, unsigned NumElts, bool ReVec)
For a non-power-of-2 NumElts-wide integer div/rem Opcode, returns the padded full-register vector typ...
InstructionCost getVectorInstrCost(const TargetTransformInfo &TTI, bool ReVec, Type *ScalarTy, unsigned Opcode, Type *Val, const TTI::TargetCostKind CostKind, unsigned Index, Value *Scalar, ArrayRef< std::tuple< Value *, User *, int > > ScalarUserAndIdx)
This is similar to TargetTransformInfo::getVectorInstrCost, but if ScalarTy is a FixedVectorType,...
InstructionCost getScalarizationOverhead(const TargetTransformInfo &TTI, bool ReVec, Type *ScalarTy, VectorType *Ty, const APInt &DemandedElts, bool Insert, bool Extract, const TTI::TargetCostKind CostKind, bool ForPoisonSrc, ArrayRef< Value * > VL, TTI::VectorInstrContext VIC)
This is similar to TargetTransformInfo::getScalarizationOverhead, but if ScalarTy is a FixedVectorTyp...
InstructionCost getExtractWithExtendCost(const TargetTransformInfo &TTI, bool ReVec, unsigned Opcode, Type *Dst, VectorType *VecTy, unsigned Index, const TTI::TargetCostKind CostKind)
This is similar to TargetTransformInfo::getExtractWithExtendCost, but if Dst is a FixedVectorType,...
InstructionCost getMaskedDivRemCost(const TargetTransformInfo &TTI, bool ReVec, unsigned Opcode, Type *ScalarTy, unsigned NumElts, const TTI::TargetCostKind CostKind, FixedVectorType **PaddedTy)
For a non-power-of-2 NumElts-wide integer div/rem Opcode, checks if padding to a full register and us...
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Type * toScalarizedTy(Type *Ty)
A helper for converting vectorized types to scalarized (non-vector) types.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
bool isVectorizedTy(Type *Ty)
Returns true if Ty is a vector type or a struct of vector types where all vector types share the same...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
constexpr auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
constexpr detail::IsaCheckPredicate< Types... > IsaPred
Function object wrapper for the llvm::isa type check.
This struct is a compact representation of a valid (non-zero power of two) alignment.