43 assert(Stride &&
"Expected a valid Stride");
44 uint64_t ElementSize =
DL.getTypeAllocSize(ScalarTy).getFixedValue();
46 return ConstantInt::get(Stride->
getContext(), IsReverse ? -Bytes : Bytes);
60 return TTI.getShuffleCost(Kind, DstTy, Tp, CostKind, Mask, Index, SubTp,
65 Mask, NumSrcElts, NumSubElts, Index)) {
66 if (Index + NumSubElts > NumSrcElts &&
67 Index + NumSrcElts <=
static_cast<int>(Mask.size()))
71 return TTI.getShuffleCost(Kind, DstTy, Tp, CostKind, Mask, Index, SubTp, Args,
80 Value *Stride =
nullptr;
86 false, CommonAlignment,
89 if (StridedLoadTy != VecTy)
99 if (Info.InterleaveFactor) {
100 assert(!Info.IsMasked &&
"Masked interleaved loads are not supported");
101 return TTI.getInterleavedMemoryOpCost(
102 Instruction::Load, Info.LoadVecTy, Info.InterleaveFactor, {},
108 Cost =
TTI.getMemIntrinsicInstrCost(
115 Instruction::Load, Info.LoadVecTy, LI0->
getAlign(),
126 CostKind, CompressCostMask);
130std::pair<InstructionCost, InstructionCost>
141 if (Opcode == Instruction::Load || Opcode == Instruction::Store) {
150 ScalarCost =
TTI.getPointersChainCost(
151 Ptrs, BasePtr, TTI::PointersChainInfo::getUnitStride(), ScalarTy,
155 for (
Value *V : Ptrs) {
165 if (!Ptr || !Ptr->hasOneUse())
169 if (PtrsRetainedInVecCode.
size() == Ptrs.size()) {
174 VecCost =
TTI.getPointersChainCost(PtrsRetainedInVecCode, BasePtr,
175 TTI::PointersChainInfo::getKnownStride(),
187 return Ptr && !Ptr->hasAllConstantIndices();
189 ? TTI::PointersChainInfo::getUnknownStride()
190 : TTI::PointersChainInfo::getKnownStride();
192 const bool IsSameBase =
199 Type *AccessTy = ScalarTy;
202 return Ptr && Ptr->hasOneUse() &&
isa<LoadInst>(Ptr->user_back());
205 AccessTy = Ptrs.
front()->user_back()->getType();
208 TTI.getPointersChainCost(Ptrs, BasePtr, PtrsInfo, AccessTy, CostKind);
212 if (It != Ptrs.
end())
219 Type *IdxTy =
DL.getIndexType(VecTy);
220 VecCost =
TTI.getArithmeticInstrCost(Instruction::Add, IdxTy, CostKind);
221 uint64_t Stride =
DL.getTypeAllocSize(BaseGEP->getSourceElementType())
226 VecCost +=
TTI.getArithmeticInstrCost(
227 isPowerOf2_64(Stride) ? Instruction::Shl : Instruction::Mul, IdxTy,
229 }
else if (BaseGEP) {
231 VecCost =
TTI.getGEPCost(BaseGEP->getSourceElementType(),
232 BaseGEP->getPointerOperand(), Indices, CostKind,
237 return std::make_pair(ScalarCost, VecCost);
244 return 2 *
TTI.getMemIntrinsicInstrCost(
248 TTI.getArithmeticInstrCost(Instruction::Xor, CmpTy, CostKind) +
249 TTI.getCmpSelInstrCost(Instruction::Select, VecTy, CmpTy,
260 return TTI.getCastInstrCost(Instruction::BitCast, DstTy, SrcTy, CCH,
265 Type *IntVecTy =
DL.getIntPtrType(DstTy);
266 return TTI.getCastInstrCost(Instruction::IntToPtr, DstTy, IntVecTy, CCH,
268 TTI.getCastInstrCost(Instruction::BitCast, IntVecTy, SrcTy, CCH,
271 Type *IntVecTy =
DL.getIntPtrType(SrcTy);
272 return TTI.getCastInstrCost(Instruction::PtrToInt, IntVecTy, SrcTy, CCH,
274 TTI.getCastInstrCost(Instruction::BitCast, DstTy, IntVecTy, CCH,
280 const std::pair<uint64_t, bool> &MinBW,
283 unsigned BWSz = MinBW.first;
287 VecOpcode = Instruction::Trunc;
289 VecOpcode = MinBW.second ? Instruction::SExt : Instruction::ZExt;
295 unsigned Opcode,
Type *ScalarTy,
310 {PaddedVecTy, PaddedVecTy, MaskTy});
312 if (!MaskedCost.isValid() || MaskedCost >= DirectCost)
315 *PaddedTy = PaddedVecTy;
322 const APInt &DemandedElts,
bool Insert,
bool Extract,
326 "ScalableVectorType is not supported.");
331 assert(ReVec &&
"Only supported by REVEC.");
334 unsigned ScalarTyNumElements = VecTy->getNumElements();
337 if (!DemandedElts[
I])
341 I * ScalarTyNumElements, VecTy);
344 I * ScalarTyNumElements, VecTy);
348 return TTI.getScalarizationOverhead(Ty, DemandedElts, Insert, Extract,
349 CostKind, ForPoisonSrc, VL, VIC);
355 Value *Scalar,
ArrayRef<std::tuple<Value *, User *, int>> ScalarUserAndIdx,
357 if (Opcode == Instruction::ExtractElement) {
359 assert(ReVec &&
"Only supported by REVEC.");
363 Index * VecTy->getNumElements(), VecTy);
366 return TTI.getVectorInstrCost(Opcode, Val, CostKind, Index, Scalar,
367 ScalarUserAndIdx, VIC);
371 bool ReVec,
unsigned Opcode,
Type *Dst,
375 assert(ReVec &&
"Only supported by REVEC.");
383 return TTI.getExtractWithExtendCost(Opcode, Dst, VecTy, Index, CostKind);
407 return TTI.getArithmeticReductionCost(
423 const Instruction *TruncI = TruncIt == ChainInsts.
end() ? nullptr : *TruncIt;
426 const Instruction *CmpI = CmpIt == ChainInsts.
end() ? nullptr : *CmpIt;
434 return TTI.getCastInstrCost(Instruction::Trunc, I1VecTy, VecTy,
435 TTI.getCastContextHint(TruncI), CostKind,
437 TTI.getCastInstrCost(Instruction::BitCast, IntTy, I1VecTy,
438 TTI.getCastContextHint(TruncI), CostKind) +
439 TTI.getCmpSelInstrCost(
442 CostKind,
TTI.getOperandInfo(Root),
TTI.getOperandInfo(CmpRHS),
452 "Expected and/or reduction of i1");
458 return TTI.getCastInstrCost(Instruction::BitCast, IntTy, VectorTy, Ctx,
460 TTI.getCmpSelInstrCost(Instruction::ICmp, IntTy,
466std::pair<InstructionCost, bool>
473 RdxOpcode, VectorTy, std::nullopt, CostKind);
476 return {std::min(RdxCost, BitcastCost), BitcastCost < RdxCost};
479 "Expected add reduction of zexted i1 values");
487 TTI.getCastInstrCost(Instruction::BitCast, IntTy, VectorTy, Ctx,
489 TTI.getIntrinsicInstrCost(
491 if (IntTy != ScalarTy)
492 ExplicitCost +=
TTI.getCastInstrCost(IntTy->getBitWidth() <
495 : Instruction::Trunc,
496 ScalarTy, IntTy, Ctx, CostKind);
498 TTI.getExtendedReductionCost(RdxOpcode,
true, ScalarTy,
499 VectorTy, std::nullopt, CostKind),
504 TTI.getCastInstrCost(Instruction::ZExt, ExtTy, VectorTy, Ctx, CostKind) +
505 TTI.getArithmeticReductionCost(RdxOpcode, ExtTy, std::nullopt, CostKind);
506 return {std::min(ExtRdxCost, CtpopCost), CtpopCost <= ExtRdxCost};
516 unsigned BitWidth = SrcTy->getScalarSizeInBits();
517 unsigned NumElts = SrcTy->getNumElements();
524 [](uint64_t
A) { return A == 0 || isPowerOf2_64(A); })
533 "The byte-multiple field width divides the result bit width.");
536 unsigned MinShiftWidth = 8;
537 while (MinShiftWidth < MaxAmt + Info.FieldWidth)
545 for (
unsigned W2 = MinShiftWidth; W2 <=
BitWidth; W2 *= 2) {
548 unsigned BytesPerLane = W2 / 8;
549 unsigned InBytes = NumElts * BytesPerLane;
553 PackTy, CCH, CostKind);
557 if (Info.FieldWidth < W2)
558 C +=
TTI.getCastInstrCost(Instruction::Trunc, FieldTy, ShiftTy,
560 if (IsReversed && Info.FieldWidth == 8) {
563 C +=
TTI.getIntrinsicInstrCost(CostAttrs, CostKind);
564 }
else if (IsReversed) {
574 C +=
TTI.getShuffleCost(
579 WideMask, 0,
nullptr, {}, CtxI);
580 if (InBytes > OutBytes)
582 PackTy, SrcByteTy, CostKind, {},
583 0, PackTy, {}, CtxI);
585 if (W2 !=
BitWidth && W2 != ZExtSrcWidth)
586 C +=
TTI.getCastInstrCost(Instruction::Trunc, ShiftTy, SrcTy, CCH,
588 if (Info.needsShift())
589 C +=
TTI.getArithmeticInstrCost(Instruction::LShr, ShiftTy, CostKind,
592 if (
C.isValid() && (!NewCost.
isValid() ||
C < NewCost)) {
602 Type *WideTy,
unsigned VF,
613 Cost +=
TTI.getArithmeticInstrCost(
614 Instruction::And, NarrowVecTy, CostKind,
621 Cost +=
TTI.getCmpSelInstrCost(
627 Instruction::BitCast, MaskTy, CmpTy,
629 if (MaskTy != WideTy)
631 TTI.getCastInstrCost(Instruction::ZExt, WideTy, MaskTy, CCH, CostKind);
641 if (
any_of(NarrowedLeafShifts,
642 [](
const auto &
P) {
return P.second.Shift != 0; }))
643 Cost +=
TTI.getArithmeticInstrCost(
644 Instruction::Shl, WideVecTy, CostKind, {TTI::OK_AnyValue, TTI::OP_None},
645 {TTI::OK_NonUniformConstantValue, TTI::OP_None}, {}, CtxI);
646 if (
any_of(NarrowedLeafShifts,
647 [](
const auto &
P) {
return !
P.second.Mask.isAllOnes(); }))
648 Cost +=
TTI.getArithmeticInstrCost(
649 Instruction::And, NarrowVecTy, CostKind,
650 {TTI::OK_AnyValue, TTI::OP_None},
651 {TTI::OK_NonUniformConstantValue, TTI::OP_None}, {}, CtxI);
657 const unsigned VF,
unsigned MinBW,
677std::pair<InstructionCost, InstructionCost>
689 LibCost =
TTI.getCallInstrCost(
nullptr, VecTy, ArgTys, CostKind);
696 FMF = FPCI->getFastMathFlags();
700 LibCost.isValid() ? LibCost : ScalarLimit);
702 if (LibCost.isValid()) {
717 if (ID == Intrinsic::sincos &&
722 2 *
TTI.getCallInstrCost(
nullptr, ArgTys.
front(), ArgTys, CostKind);
734 "getVectorOpCost expects an arithmetic op or a vectorizable call.");
739 auto [IntrCost, LibCost] =
741 return std::min(IntrCost, LibCost);
744 return TTI.getArithmeticInstrCost(
753 return (
static_cast<unsigned>(Ty->getTypeID()) << 16) |
754 Ty->getScalarSizeInBits();
762 unsigned MaxVecRegSize) {
765 Type *Ty =
I->getType();
766 if ((Ty->isVectorTy() && !ReVec) || Ty->isAggregateType() ||
769 auto Analyze = [&]() {
773 constexpr unsigned MinVF = 2;
778 unsigned TyBits = Ty->getPrimitiveSizeInBits().getFixedValue();
780 return MaxVF > MinVF &&
793 return !isValidElementType(Arg->getType(), ReVec);
798 if (!CI->use_empty() && !CI->hasNUsesOrMore(
UsesLimit) &&
801 U, m_Select(m_Unless(m_Specific(CI)), m_Value(), m_Value()));
806 return CheckCached(Cache.CheapIntrinsics.contains(
Key),
807 [&] { Cache.CheapIntrinsics.insert(Key); });
812 const Function *Callee = CI->getCalledFunction();
815 return CheckCached(Cache.CheapCallees.contains(Callee),
816 [&] { Cache.CheapCallees.insert(Callee); });
819 return CheckCached(Cache.CheapOpcodes.contains(
Key),
820 [&] { Cache.CheapOpcodes.insert(Key); });
829 if (
FMul->getParent() ==
I->getParent())
832 return TTI.isProfitableToSinkOperands(
I, OpsToSink) &&
833 any_of(OpsToSink, [&](
const Use *U) {
return U->get() ==
FMul; });
840 const unsigned NumRegs =
TTI.getNumberOfRegisters(
841 TTI.getRegisterClassForType(
false, Ty));
842 auto IsLiveCandidate = [&](
const Value *V) {
852 if (Live.
size() > NumRegs)
863 std::tuple<const void *, FixedVectorType *, unsigned>>(
Value *)>
864 GetVectorizedSource) {
865 struct SourceVector {
873 for (
auto [Idx, VL] :
enumerate(GatheredScalars)) {
874 std::optional<std::tuple<Value *, unsigned, SmallVector<int>>> Fields =
878 auto &[Src, FieldWidth, Mask] = *Fields;
879 Type *SrcTy = Src->getType();
881 if (FieldWidth != 8 || NumFields % 2 != 0 ||
889 FieldVecTy, CostKind, Mask);
890 std::optional<std::tuple<const void *, FixedVectorType *, unsigned>>
891 Source = GetVectorizedSource(Src);
895 Source = std::make_tuple(
896 EE->getVectorOperand(),
900 if (BSwapCost <= PermuteCost)
901 BSwapGathers.
set(Idx);
904 auto &[Vec, VecTy, Lane] = *Source;
911 I += Lane * NumFields;
914 VecBytesTy, CostKind, {},
915 Lane * NumFields, FieldVecTy),
918 auto [It, Inserted] = SourceVectors.
try_emplace(Vec);
919 SourceVector &Info = It->second;
924 Info.DemandedElts.setBit(Lane);
925 Info.Cost += BSwapCost - PermuteCost;
926 Info.Gathers.push_back(Idx);
930 TTI, ReVec, Info.VecTy->getElementType(), Info.VecTy, Info.DemandedElts,
931 false,
true, CostKind);
932 if (Info.Cost + ExtractCost <= 0)
933 for (
unsigned Idx : Info.Gathers)
934 BSwapGathers.
set(Idx);
const TargetLowering & TLI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements a class to represent arbitrary precision integral constant values and operations...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
Provides some synthesis utilities to produce sequences of values.
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
Class for arbitrary precision integers.
unsigned getBitWidth() const
Return the number of bits in the APInt.
static APInt getZero(unsigned numBits)
Get the '0' value for the specified bit-width.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
const T & front() const
Get the first element.
LLVM Basic Block Representation.
bool isNoBuiltin() const
Return true if the call should not be treated as a call to a builtin.
Value * getArgOperand(unsigned i) const
FunctionType * getFunctionType() const
iterator_range< User::op_iterator > args()
Iteration adapter for range-for loops.
This class represents a function call, abstracting a target machine's calling convention.
static Type * makeCmpResultType(Type *opnd_type)
Create a result type for fcmp/icmp.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
This is the shared class of boolean and integer constants.
const APInt & getValue() const
Return the constant as an APInt value reference.
This is an important base class in LLVM.
static LLVM_ABI Constant * getAllOnesValue(Type *Ty)
static LLVM_ABI Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
A parsed version of the target data layout string in and methods for querying it.
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
static constexpr ElementCount getFixed(ScalarTy MinVal)
Convenience struct for specifying and reasoning about fast-math flags.
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)
LLVM_ABI const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
An instruction for reading from memory.
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
Value * getPointerOperand()
Align getAlign() const
Return the alignment of the access that is being performed.
Information for memory intrinsic cost model.
static LLVM_ABI unsigned getOpcode(RecurKind Kind)
Returns the opcode corresponding to the RecurrenceKind.
unsigned getOpcode() const
static LLVM_ABI bool isIdentityMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask chooses elements from exactly one source vector without lane crossin...
static LLVM_ABI bool isReverseMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask swaps the order of elements from exactly one source vector.
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.
This is a 'bitvector' (really, a variable-sized bit array), optimized for the case when the array is ...
bool erase(PtrType Ptr)
Remove pointer from the set.
void insert_range(Range &&R)
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Provides information about what library functions are available for the current target.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM_ABI unsigned getIntegerBitWidth() const
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
static LLVM_ABI IntegerType * getInt8Ty(LLVMContext &C)
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
LLVM_ABI Type * getWithNewBitWidth(unsigned NewBitWidth) const
Given an integer or vector type, change the lane bitwidth to NewBitwidth, whilst keeping the old numb...
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
bool isIntegerTy() const
True if this is an instance of IntegerType.
A Use represents the edge between a Value definition and its users.
The Vector Function Database.
static SmallVector< VFInfo, 8 > getMappings(const CallInst &CI)
Retrieve all the VFInfo instances associated to the CallInst CI.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
user_iterator user_begin()
bool hasOneUse() const
Return true if there is exactly one use of this value.
LLVMContext & getContext() const
All values hold a context through their type.
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...
static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
Type * getElementType() const
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
An efficient, type-erasing, non-owning reference to a callable.
Function * getVectorizedFunction(const VFShape &Shape) const
OneUse_match< SubPat > m_OneUse(const SubPat &SP)
BinaryOp_match< LHS, RHS, Instruction::FMul > m_FMul(const LHS &L, const RHS &R)
bool match(Val *V, const Pattern &P)
match_bind< Instruction > m_Instruction(Instruction *&I)
Match an instruction, capturing it if we match.
auto m_Value()
Match an arbitrary value and ignore it.
auto m_Intrinsic(const Ts &...Ops)
Match intrinsic calls like this: m_Intrinsic<Intrinsic::fabs>(m_Value(X))
AllowFmf_match< T, FastMathFlags::AllowContract > m_AllowContract(const T &SubPattern)
A private "module" namespace for types and utilities used by this pass.
std::pair< InstructionCost, bool > getI1ReductionCost(RecurKind Kind, const TargetTransformInfo &TTI, FixedVectorType *VectorTy, Type *ScalarTy, TTI::CastContextHint Ctx, TTI::TargetCostKind CostKind)
i1 reductions can be emitted as the plain target reduction or in the bitcast-based form (bitcast to a...
std::pair< InstructionCost, InstructionCost > getVectorCallCosts(CallInst *CI, Type *VecTy, const TargetTransformInfo &TTI, const TargetLibraryInfo &TLI, ArrayRef< Type * > ArgTys, const TTI::TargetCostKind CostKind)
Calculates the costs of vectorized intrinsic (if possible) and vectorized function (if possible) call...
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, TTI::VectorInstrContext VIC)
Returns the cost of the shuffle instructions with the given Kind, vector type Tp and optional Mask.
std::optional< unsigned > getElementIndex(const Value *Inst, unsigned Offset)
InstructionCost getNarrowedLeafOpsCost(const TargetTransformInfo &TTI, const SmallDenseMap< Value *, NarrowedLeafInfo > &NarrowedLeafShifts, VectorType *NarrowVecTy, VectorType *WideVecTy, const Instruction *CtxI, const TTI::TargetCostKind CostKind)
Returns the cost of the per-lane operations on the narrowed leaves NarrowedLeafShifts: the shl in the...
std::optional< std::tuple< Value *, unsigned, SmallVector< int > > > matchGatheredExtractedFields(ArrayRef< Value * > VL, const DataLayout &DL)
Checks if the values in VL are zero-extended sub-fields of the same wider integer scalar.
InstructionCost getBoolReduxBitcastCmpCost(const TargetTransformInfo &TTI, RecurKind RdxKind, FixedVectorType *VecTy, const Value *Root, ArrayRef< Instruction * > ChainInsts, const TTI::TargetCostKind CostKind)
Returns the cost of the booleanized logical and/or reduction of a vector of type VecTy with the i1 ro...
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)
SmallVector< int > getBitPackMask(const BitPackInfo &Info, unsigned NumBytes, unsigned NumElts, unsigned BytesPerLane)
Returns the byte shuffle mask packing the per-lane fields of the shifted lanes (BytesPerLane bytes ea...
SmallVector< Type * > buildIntrinsicArgTypes(const CallInst *CI, const Intrinsic::ID ID, const unsigned VF, unsigned MinBW, const TargetTransformInfo &TTI)
Builds the arguments types vector for the given call instruction with the given ID for the specified ...
unsigned getNumElements(Type *Ty)
Type * getWidenedType(Type *ScalarTy, unsigned VF)
static unsigned getPoorThroughputTypeKey(Type *Ty)
Packs a type's kind and scalar width into one key, so an opcode/intrinsic id reused across scalar wid...
bool isPoorThroughputOp(bool ReVec, Instruction *I, const TargetTransformInfo &TTI, const TargetLibraryInfo &TLI, PoorThroughputOpCache &Cache, const TTI::TargetCostKind CostKind, unsigned MaxVecRegSize)
Returns true if I is an expensive scalar op whose vector form is cheaper per lane (e....
ConstantInt * getStrideBytesForConstant(ConstantInt *Stride, Type *ScalarTy, const DataLayout &DL, bool IsReverse)
Returns Stride scaled by the allocation size of ScalarTy, negated if IsReverse is set.
static TTI::CastContextHint getBoolReduxResultCCH(const Value *Root)
Returns the cast context hint for the trunc of the booleanized reduction result, which inherits the u...
void transformScalarShuffleIndiciesToVector(unsigned VecTyNumElements, SmallVectorImpl< int > &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 getBoolBitmaskCost(const TargetTransformInfo &TTI, bool NeedMask, Type *NarrowScalarTy, Type *WideTy, unsigned VF, ArrayRef< int > PermMask, const Value *Root, const TTI::TargetCostKind CostKind)
Returns the cost of the boolean bitmask reduction of a vector of boolean leaves of type NarrowScalarT...
InstructionCost getDemotedTypeCastCost(const TargetTransformInfo &TTI, VectorType *VecTy, const std::pair< uint64_t, bool > &MinBW, TTI::CastContextHint CCH, TTI::TargetCostKind CostKind)
Returns the cost of casting a vector of the demoted type to VecTy.
bool isFusableFMulOperand(Value *Op, Instruction *I, const TargetTransformInfo &TTI)
InstructionCost getBoolReduxWideRdxCost(const TargetTransformInfo &TTI, RecurKind RdxKind, FixedVectorType *VecTy, const Value *Root, FastMathFlags FMF, const TTI::TargetCostKind CostKind)
Returns the cost of the booleanized logical and/or reduction of a vector of type VecTy with the i1 ro...
InstructionCost getCompressedLoadCost(const TargetTransformInfo &TTI, const LoadInst *LI0, const CompressedLoadInfo &Info, TargetTransformInfo::TargetCostKind CostKind)
Return the cost of a compressed load and accompanying shuffle.
InstructionCost getWidenedStridedCastCost(const TargetTransformInfo &TTI, Type *SrcTy, Type *DstTy, const DataLayout &DL, TTI::CastContextHint CCH, TTI::TargetCostKind CostKind)
Returns the cost of the cast between the widened strided access type and the entry vector type.
bool isValidElementType(Type *Ty, bool ReVec)
Predicate for the element types that the SLP vectorizer supports.
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 getStridedLoadCost(const TargetTransformInfo &TTI, const DataLayout &DL, Value *StrideVal, Type *StridedLoadTy, Type *VecTy, Type *ScalarTy, Value *Ptr, Align CommonAlignment, TargetTransformInfo::CastContextHint Ctx, TargetTransformInfo::TargetCostKind CostKind, bool IsReverse)
Return the cost of a strided load and accompanying bitcast.
bool hasHighRegisterPressure(unsigned ScheduleBudget, const BasicBlock &BB, Type *Ty, const TargetTransformInfo &TTI)
SmallBitVector selectBSwapGathers(ArrayRef< SmallVector< Value * > > GatheredScalars, const DataLayout &DL, const TargetTransformInfo &TTI, bool ReVec, TargetTransformInfo::TargetCostKind CostKind, function_ref< std::optional< std::tuple< const void *, FixedVectorType *, unsigned > >(Value *)> GetVectorizedSource)
Selects the gathers of GatheredScalars, which fully reverse the bytes of a scalar and are emitted as ...
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,...
static InstructionCost getVectorOpCost(Instruction *I, unsigned VF, const TargetTransformInfo &TTI, const TargetLibraryInfo &TLI, const TTI::TargetCostKind CostKind)
static InstructionCost getBoolLogicRdxBitcastCost(RecurKind Kind, const TargetTransformInfo &TTI, FixedVectorType *VectorTy, TTI::CastContextHint Ctx, TTI::TargetCostKind CostKind)
constexpr int UsesLimit
Limit of the number of uses for potentially transformed instructions/values, used in checks to avoid ...
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, TTI::VectorInstrContext VIC)
This is similar to TargetTransformInfo::getVectorInstrCost, but if ScalarTy 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...
InstructionCost getBitPackCost(const TargetTransformInfo &TTI, FixedVectorType *SrcTy, Type *ResultTy, const BitPackInfo &Info, unsigned ZExtSrcWidth, TTI::CastContextHint CCH, TTI::TargetCostKind CostKind, const TargetLibraryInfo *TLI, const Instruction *CtxI, unsigned &ShiftWidth)
Returns the cost of the bitfield packing of SrcTy into ResultTy, picking the cheapest shift width.
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.
LLVM_ABI Intrinsic::ID getVectorIntrinsicIDForCall(const CallInst *CI, const TargetLibraryInfo *TLI)
Returns intrinsic ID for call.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
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.
auto dyn_cast_if_present(const Y &Val)
dyn_cast_if_present<X> - Functionally identical to dyn_cast, except that a null (or none in the case ...
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...
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
auto map_range(ContainerTy &&C, FuncTy F)
Return a range that applies F to the elements of C.
bool hasNItemsOrMore(IterTy &&Begin, IterTy &&End, unsigned N, Pred &&ShouldBeCounted=[](const decltype(*std::declval< IterTy >()) &) { return true;}, std::enable_if_t< !std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< std::remove_reference_t< decltype(Begin)> >::iterator_category >::value, void > *=nullptr)
Return true if the sequence [Begin, End) has N or more items.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
auto reverse(ContainerTy &&C)
bool isPointerTy(const Type *T)
iterator_range< filter_iterator< detail::IterOfRange< RangeT >, PredicateT > > make_filter_range(RangeT &&Range, PredicateT Pred)
Convenience function that takes a range of elements and a predicate, and return a new filter_iterator...
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...
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
constexpr int PoisonMaskElem
RecurKind
These are the kinds of recurrences that we support.
@ Or
Bitwise or logical OR of integers.
@ And
Bitwise or logical AND of integers.
LLVM_ABI bool isVectorIntrinsicWithScalarOpAtArg(Intrinsic::ID ID, unsigned ScalarOpdIdx, const TargetTransformInfo *TTI)
Identifies if the vector form of the intrinsic has a scalar operand.
DWARFExpression::Operation Op
auto max_element(R &&Range)
Provide wrappers to std::max_element which take ranges instead of having to pass begin/end explicitly...
auto make_second_range(ContainerTy &&c)
Given a container of pairs, return a range over the second elements.
constexpr unsigned BitWidth
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.
LLVM_ABI bool shouldSplitVectorSinCos(const TargetLibraryInfo &TLI, Type *ScalarTy, ElementCount EC, Module *M)
Returns true if the vector llvm.sincos with ScalarTy elements and EC element count has no vector libr...
constexpr auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
bool all_equal(std::initializer_list< T > Values)
Returns true if all Values in the initializer lists are equal or the list.
bool equal(L &&LRange, R &&RRange)
Wrapper function around std::equal to detect if pair-wise elements between two ranges are the same.
T bit_floor(T Value)
Returns the largest integral power of two no greater than Value if Value is nonzero.
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.
static VFShape get(const FunctionType *FTy, ElementCount EC, bool HasGlobalPred)
Retrieve the basic vectorization shape of the function, where all parameters are mapped to VFParamKin...
Description of a bitfield packing of vector lanes into a scalar value: every lane contributes a disjo...
static constexpr unsigned NoLane
Describe a single compressed load for costing and generating the vector instruction.
Memoizes opcode / intrinsic / callee kinds already ruled out as seeds.