LLVM 22.0.0git
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
llvm::TargetTransformInfo Class Reference

This pass provides access to the codegen interfaces that are needed for IR-level transformations. More...

#include "llvm/Analysis/TargetTransformInfo.h"

Classes

struct  LSRCost
 
struct  MemCmpExpansionOptions
 Returns options for expansion of memcmp. IsZeroCmp is. More...
 
struct  OperandValueInfo
 
struct  PeelingPreferences
 
struct  PointersChainInfo
 Describe known properties for a set of pointers. More...
 
struct  UnrollingPreferences
 Parameters that control the generic loop unrolling transformation. More...
 
struct  VPLegalization
 

Public Types

enum  PartialReductionExtendKind { PR_None , PR_SignExtend , PR_ZeroExtend }
 

Public Member Functions

LLVM_ABI TargetTransformInfo (std::unique_ptr< const TargetTransformInfoImplBase > Impl)
 Construct a TTI object using a type implementing the Concept API below.
 
LLVM_ABI TargetTransformInfo (const DataLayout &DL)
 Construct a baseline TTI object using a minimal implementation of the Concept API below.
 
LLVM_ABI TargetTransformInfo (TargetTransformInfo &&Arg)
 
LLVM_ABI TargetTransformInfooperator= (TargetTransformInfo &&RHS)
 
LLVM_ABI ~TargetTransformInfo ()
 
bool invalidate (Function &, const PreservedAnalyses &, FunctionAnalysisManager::Invalidator &)
 Handle the invalidation of this information.
 
LLVM_ABI bool hasArmWideBranch (bool Thumb) const
 
LLVM_ABI APInt getFeatureMask (const Function &F) const
 Returns a bitmask constructed from the target-features or fmv-features metadata of a function.
 
LLVM_ABI bool isMultiversionedFunction (const Function &F) const
 Returns true if this is an instance of a function with multiple versions.
 
LLVM_ABI unsigned getMaxNumArgs () const
 
LLVM_ABI unsigned getNumBytesToPadGlobalArray (unsigned Size, Type *ArrayType) const
 
LLVM_ABI void collectKernelLaunchBounds (const Function &F, SmallVectorImpl< std::pair< StringRef, int64_t > > &LB) const
 Collect kernel launch bounds for F into LB.
 
LLVM_ABI bool allowVectorElementIndexingUsingGEP () const
 Returns true if GEP should not be used to index into vectors for this target.
 
Vector Predication Information

Whether the target supports the evl parameter of VP intrinsic efficiently in hardware.

(see LLVM Language Reference - "Vector Predication Intrinsics"). Use of evl is discouraged when that is not the case.

LLVM_ABI bool hasActiveVectorLength () const
 
LLVM_ABI bool isProfitableToSinkOperands (Instruction *I, SmallVectorImpl< Use * > &Ops) const
 Return true if sinking I's operands to the same basic block as I is profitable, e.g.
 
LLVM_ABI bool isVectorShiftByScalarCheap (Type *Ty) const
 Return true if it's significantly cheaper to shift a vector by a uniform scalar than by an amount which will vary across each lane.
 
LLVM_ABI VPLegalization getVPLegalizationStrategy (const VPIntrinsic &PI) const
 

Static Public Member Functions

static LLVM_ABI PartialReductionExtendKind getPartialReductionExtendKind (Instruction *I)
 Get the kind of extension that an instruction represents.
 

Generic Target Information

enum  TargetCostKind { TCK_RecipThroughput , TCK_Latency , TCK_CodeSize , TCK_SizeAndLatency }
 The kind of cost model. More...
 
enum  TargetCostConstants { TCC_Free = 0 , TCC_Basic = 1 , TCC_Expensive = 4 }
 Underlying constants for 'cost' values in this interface. More...
 
LLVM_ABI InstructionCost getGEPCost (Type *PointeeType, const Value *Ptr, ArrayRef< const Value * > Operands, Type *AccessType=nullptr, TargetCostKind CostKind=TCK_SizeAndLatency) const
 Estimate the cost of a GEP operation when lowered.
 
LLVM_ABI InstructionCost getPointersChainCost (ArrayRef< const Value * > Ptrs, const Value *Base, const PointersChainInfo &Info, Type *AccessTy, TargetCostKind CostKind=TTI::TCK_RecipThroughput) const
 Estimate the cost of a chain of pointers (typically pointer operands of a chain of loads or stores within same block) operations set when lowered.
 
LLVM_ABI unsigned getInliningThresholdMultiplier () const
 
LLVM_ABI unsigned getInliningCostBenefitAnalysisSavingsMultiplier () const
 
LLVM_ABI unsigned getInliningCostBenefitAnalysisProfitableMultiplier () const
 
LLVM_ABI int getInliningLastCallToStaticBonus () const
 
LLVM_ABI unsigned adjustInliningThreshold (const CallBase *CB) const
 
LLVM_ABI unsigned getCallerAllocaCost (const CallBase *CB, const AllocaInst *AI) const
 
LLVM_ABI int getInlinerVectorBonusPercent () const
 
LLVM_ABI InstructionCost getMemcpyCost (const Instruction *I) const
 
LLVM_ABI uint64_t getMaxMemIntrinsicInlineSizeThreshold () const
 Returns the maximum memset / memcpy size in bytes that still makes it profitable to inline the call.
 
LLVM_ABI unsigned getEstimatedNumberOfCaseClusters (const SwitchInst &SI, unsigned &JTSize, ProfileSummaryInfo *PSI, BlockFrequencyInfo *BFI) const
 
LLVM_ABI InstructionCost getInstructionCost (const User *U, ArrayRef< const Value * > Operands, TargetCostKind CostKind) const
 Estimate the cost of a given IR user when lowered.
 
InstructionCost getInstructionCost (const User *U, TargetCostKind CostKind) const
 This is a helper function which calls the three-argument getInstructionCost with Operands which are the current operands U has.
 
LLVM_ABI BranchProbability getPredictableBranchThreshold () const
 If a branch or a select condition is skewed in one direction by more than this factor, it is very likely to be predicted correctly.
 
LLVM_ABI InstructionCost getBranchMispredictPenalty () const
 Returns estimated penalty of a branch misprediction in latency.
 
LLVM_ABI bool hasBranchDivergence (const Function *F=nullptr) const
 Return true if branch divergence exists.
 
LLVM_ABI bool isSourceOfDivergence (const Value *V) const
 Returns whether V is a source of divergence.
 
LLVM_ABI bool isAlwaysUniform (const Value *V) const
 
LLVM_ABI bool isValidAddrSpaceCast (unsigned FromAS, unsigned ToAS) const
 Query the target whether the specified address space cast from FromAS to ToAS is valid.
 
LLVM_ABI bool addrspacesMayAlias (unsigned AS0, unsigned AS1) const
 Return false if a AS0 address cannot possibly alias a AS1 address.
 
LLVM_ABI unsigned getFlatAddressSpace () const
 Returns the address space ID for a target's 'flat' address space.
 
LLVM_ABI bool collectFlatAddressOperands (SmallVectorImpl< int > &OpIndexes, Intrinsic::ID IID) const
 Return any intrinsic address operand indexes which may be rewritten if they use a flat address space pointer.
 
LLVM_ABI bool isNoopAddrSpaceCast (unsigned FromAS, unsigned ToAS) const
 
LLVM_ABI bool canHaveNonUndefGlobalInitializerInAddressSpace (unsigned AS) const
 Return true if globals in this address space can have initializers other than undef.
 
LLVM_ABI unsigned getAssumedAddrSpace (const Value *V) const
 
LLVM_ABI bool isSingleThreaded () const
 
LLVM_ABI std::pair< const Value *, unsignedgetPredicatedAddrSpace (const Value *V) const
 
LLVM_ABI ValuerewriteIntrinsicWithAddressSpace (IntrinsicInst *II, Value *OldV, Value *NewV) const
 Rewrite intrinsic call II such that OldV will be replaced with NewV, which has a different address space.
 
LLVM_ABI bool isLoweredToCall (const Function *F) const
 Test whether calls to a function lower to actual program function calls.
 
LLVM_ABI void getUnrollingPreferences (Loop *L, ScalarEvolution &, UnrollingPreferences &UP, OptimizationRemarkEmitter *ORE) const
 Get target-customized preferences for the generic loop unrolling transformation.
 
LLVM_ABI bool isHardwareLoopProfitable (Loop *L, ScalarEvolution &SE, AssumptionCache &AC, TargetLibraryInfo *LibInfo, HardwareLoopInfo &HWLoopInfo) const
 Query the target whether it would be profitable to convert the given loop into a hardware loop.
 
LLVM_ABI unsigned getEpilogueVectorizationMinVF () const
 
LLVM_ABI bool preferPredicateOverEpilogue (TailFoldingInfo *TFI) const
 Query the target whether it would be prefered to create a predicated vector loop, which can avoid the need to emit a scalar epilogue loop.
 
LLVM_ABI TailFoldingStyle getPreferredTailFoldingStyle (bool IVUpdateMayOverflow=true) const
 Query the target what the preferred style of tail folding is.
 
LLVM_ABI void getPeelingPreferences (Loop *L, ScalarEvolution &SE, PeelingPreferences &PP) const
 Get target-customized preferences for the generic loop peeling transformation.
 
LLVM_ABI std::optional< Instruction * > instCombineIntrinsic (InstCombiner &IC, IntrinsicInst &II) const
 Targets can implement their own combinations for target-specific intrinsics.
 
LLVM_ABI std::optional< Value * > simplifyDemandedUseBitsIntrinsic (InstCombiner &IC, IntrinsicInst &II, APInt DemandedMask, KnownBits &Known, bool &KnownBitsComputed) const
 Can be used to implement target-specific instruction combining.
 
LLVM_ABI std::optional< Value * > simplifyDemandedVectorEltsIntrinsic (InstCombiner &IC, IntrinsicInst &II, APInt DemandedElts, APInt &UndefElts, APInt &UndefElts2, APInt &UndefElts3, std::function< void(Instruction *, unsigned, APInt, APInt &)> SimplifyAndSetOp) const
 Can be used to implement target-specific instruction combining.
 

Scalar Target Information

enum  PopcntSupportKind { PSK_Software , PSK_SlowHardware , PSK_FastHardware }
 Flags indicating the kind of support for population count. More...
 
enum  AddressingModeKind { AMK_PreIndexed , AMK_PostIndexed , AMK_None }
 
LLVM_ABI bool isLegalAddImmediate (int64_t Imm) const
 Return true if the specified immediate is legal add immediate, that is the target has add instructions which can add a register with the immediate without having to materialize the immediate into a register.
 
LLVM_ABI bool isLegalAddScalableImmediate (int64_t Imm) const
 Return true if adding the specified scalable immediate is legal, that is the target has add instructions which can add a register with the immediate (multiplied by vscale) without having to materialize the immediate into a register.
 
LLVM_ABI bool isLegalICmpImmediate (int64_t Imm) const
 Return true if the specified immediate is legal icmp immediate, that is the target has icmp instructions which can compare a register against the immediate without having to materialize the immediate into a register.
 
LLVM_ABI bool isLegalAddressingMode (Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset, bool HasBaseReg, int64_t Scale, unsigned AddrSpace=0, Instruction *I=nullptr, int64_t ScalableOffset=0) const
 Return true if the addressing mode represented by AM is legal for this target, for a load/store of the specified type.
 
LLVM_ABI bool isLSRCostLess (const TargetTransformInfo::LSRCost &C1, const TargetTransformInfo::LSRCost &C2) const
 Return true if LSR cost of C1 is lower than C2.
 
LLVM_ABI bool isNumRegsMajorCostOfLSR () const
 Return true if LSR major cost is number of registers.
 
LLVM_ABI bool shouldDropLSRSolutionIfLessProfitable () const
 Return true if LSR should drop a found solution if it's calculated to be less profitable than the baseline.
 
LLVM_ABI bool isProfitableLSRChainElement (Instruction *I) const
 
LLVM_ABI bool canMacroFuseCmp () const
 Return true if the target can fuse a compare and branch.
 
LLVM_ABI bool canSaveCmp (Loop *L, BranchInst **BI, ScalarEvolution *SE, LoopInfo *LI, DominatorTree *DT, AssumptionCache *AC, TargetLibraryInfo *LibInfo) const
 Return true if the target can save a compare for loop count, for example hardware loop saves a compare.
 
LLVM_ABI AddressingModeKind getPreferredAddressingMode (const Loop *L, ScalarEvolution *SE) const
 Return the preferred addressing mode LSR should make efforts to generate.
 
LLVM_ABI bool isLegalMaskedStore (Type *DataType, Align Alignment, unsigned AddressSpace) const
 Return true if the target supports masked store.
 
LLVM_ABI bool isLegalMaskedLoad (Type *DataType, Align Alignment, unsigned AddressSpace) const
 Return true if the target supports masked load.
 
LLVM_ABI bool isLegalNTStore (Type *DataType, Align Alignment) const
 Return true if the target supports nontemporal store.
 
LLVM_ABI bool isLegalNTLoad (Type *DataType, Align Alignment) const
 Return true if the target supports nontemporal load.
 
LLVM_ABI bool isLegalBroadcastLoad (Type *ElementTy, ElementCount NumElements) const
 \Returns true if the target supports broadcasting a load to a vector of type <NumElements x ElementTy>.
 
LLVM_ABI bool isLegalMaskedScatter (Type *DataType, Align Alignment) const
 Return true if the target supports masked scatter.
 
LLVM_ABI bool isLegalMaskedGather (Type *DataType, Align Alignment) const
 Return true if the target supports masked gather.
 
LLVM_ABI bool forceScalarizeMaskedGather (VectorType *Type, Align Alignment) const
 Return true if the target forces scalarizing of llvm.masked.gather intrinsics.
 
LLVM_ABI bool forceScalarizeMaskedScatter (VectorType *Type, Align Alignment) const
 Return true if the target forces scalarizing of llvm.masked.scatter intrinsics.
 
LLVM_ABI bool isLegalMaskedCompressStore (Type *DataType, Align Alignment) const
 Return true if the target supports masked compress store.
 
LLVM_ABI bool isLegalMaskedExpandLoad (Type *DataType, Align Alignment) const
 Return true if the target supports masked expand load.
 
LLVM_ABI bool isLegalStridedLoadStore (Type *DataType, Align Alignment) const
 Return true if the target supports strided load.
 
LLVM_ABI bool isLegalInterleavedAccessType (VectorType *VTy, unsigned Factor, Align Alignment, unsigned AddrSpace) const
 Return true is the target supports interleaved access for the given vector type VTy, interleave factor Factor, alignment Alignment and address space AddrSpace.
 
LLVM_ABI bool isLegalMaskedVectorHistogram (Type *AddrType, Type *DataType) const
 
LLVM_ABI bool isLegalAltInstr (VectorType *VecTy, unsigned Opcode0, unsigned Opcode1, const SmallBitVector &OpcodeMask) const
 Return true if this is an alternating opcode pattern that can be lowered to a single instruction on the target.
 
LLVM_ABI bool enableOrderedReductions () const
 Return true if we should be enabling ordered reductions for the target.
 
LLVM_ABI bool hasDivRemOp (Type *DataType, bool IsSigned) const
 Return true if the target has a unified operation to calculate division and remainder.
 
LLVM_ABI bool hasVolatileVariant (Instruction *I, unsigned AddrSpace) const
 Return true if the given instruction (assumed to be a memory access instruction) has a volatile variant.
 
LLVM_ABI bool prefersVectorizedAddressing () const
 Return true if target doesn't mind addresses in vectors.
 
LLVM_ABI InstructionCost getScalingFactorCost (Type *Ty, GlobalValue *BaseGV, StackOffset BaseOffset, bool HasBaseReg, int64_t Scale, unsigned AddrSpace=0) const
 Return the cost of the scaling factor used in the addressing mode represented by AM for this target, for a load/store of the specified type.
 
LLVM_ABI bool LSRWithInstrQueries () const
 Return true if the loop strength reduce pass should make Instruction* based TTI queries to isLegalAddressingMode().
 
LLVM_ABI bool isTruncateFree (Type *Ty1, Type *Ty2) const
 Return true if it's free to truncate a value of type Ty1 to type Ty2.
 
LLVM_ABI bool isProfitableToHoist (Instruction *I) const
 Return true if it is profitable to hoist instruction in the then/else to before if.
 
LLVM_ABI bool useAA () const
 
LLVM_ABI bool isTypeLegal (Type *Ty) const
 Return true if this type is legal.
 
LLVM_ABI unsigned getRegUsageForType (Type *Ty) const
 Returns the estimated number of registers required to represent Ty.
 
LLVM_ABI bool shouldBuildLookupTables () const
 Return true if switches should be turned into lookup tables for the target.
 
LLVM_ABI bool shouldBuildLookupTablesForConstant (Constant *C) const
 Return true if switches should be turned into lookup tables containing this constant value for the target.
 
LLVM_ABI bool shouldBuildRelLookupTables () const
 Return true if lookup tables should be turned into relative lookup tables.
 
LLVM_ABI bool useColdCCForColdCall (Function &F) const
 Return true if the input function which is cold at all call sites, should use coldcc calling convention.
 
LLVM_ABI bool isTargetIntrinsicTriviallyScalarizable (Intrinsic::ID ID) const
 
LLVM_ABI bool isTargetIntrinsicWithScalarOpAtArg (Intrinsic::ID ID, unsigned ScalarOpdIdx) const
 Identifies if the vector form of the intrinsic has a scalar operand.
 
LLVM_ABI bool isTargetIntrinsicWithOverloadTypeAtArg (Intrinsic::ID ID, int OpdIdx) const
 Identifies if the vector form of the intrinsic is overloaded on the type of the operand at index OpdIdx, or on the return type if OpdIdx is -1.
 
LLVM_ABI bool isTargetIntrinsicWithStructReturnOverloadAtField (Intrinsic::ID ID, int RetIdx) const
 Identifies if the vector form of the intrinsic that returns a struct is overloaded at the struct element index RetIdx.
 
LLVM_ABI InstructionCost getScalarizationOverhead (VectorType *Ty, const APInt &DemandedElts, bool Insert, bool Extract, TTI::TargetCostKind CostKind, bool ForPoisonSrc=true, ArrayRef< Value * > VL={}) const
 Estimate the overhead of scalarizing an instruction.
 
LLVM_ABI InstructionCost getOperandsScalarizationOverhead (ArrayRef< Type * > Tys, TTI::TargetCostKind CostKind) const
 Estimate the overhead of scalarizing operands with the given types.
 
LLVM_ABI bool supportsEfficientVectorElementLoadStore () const
 If target has efficient vector element load/store instructions, it can return true here so that insertion/extraction costs are not added to the scalarization cost of a load/store.
 
LLVM_ABI bool supportsTailCalls () const
 If the target supports tail calls.
 
LLVM_ABI bool supportsTailCallFor (const CallBase *CB) const
 If target supports tail call on CB.
 
LLVM_ABI bool enableAggressiveInterleaving (bool LoopHasReductions) const
 Don't restrict interleaved unrolling to small loops.
 
LLVM_ABI MemCmpExpansionOptions enableMemCmpExpansion (bool OptSize, bool IsZeroCmp) const
 
LLVM_ABI bool enableSelectOptimize () const
 Should the Select Optimization pass be enabled and ran.
 
LLVM_ABI bool shouldTreatInstructionLikeSelect (const Instruction *I) const
 Should the Select Optimization pass treat the given instruction like a select, potentially converting it to a conditional branch.
 
LLVM_ABI bool enableInterleavedAccessVectorization () const
 Enable matching of interleaved access groups.
 
LLVM_ABI bool enableMaskedInterleavedAccessVectorization () const
 Enable matching of interleaved access groups that contain predicated accesses or gaps and therefore vectorized using masked vector loads/stores.
 
LLVM_ABI bool isFPVectorizationPotentiallyUnsafe () const
 Indicate that it is potentially unsafe to automatically vectorize floating-point operations because the semantics of vector and scalar floating-point semantics may differ.
 
LLVM_ABI bool allowsMisalignedMemoryAccesses (LLVMContext &Context, unsigned BitWidth, unsigned AddressSpace=0, Align Alignment=Align(1), unsigned *Fast=nullptr) const
 Determine if the target supports unaligned memory accesses.
 
LLVM_ABI PopcntSupportKind getPopcntSupport (unsigned IntTyWidthInBit) const
 Return hardware support for population count.
 
LLVM_ABI bool haveFastSqrt (Type *Ty) const
 Return true if the hardware has a fast square-root instruction.
 
LLVM_ABI bool isExpensiveToSpeculativelyExecute (const Instruction *I) const
 Return true if the cost of the instruction is too high to speculatively execute and should be kept behind a branch.
 
LLVM_ABI bool isFCmpOrdCheaperThanFCmpZero (Type *Ty) const
 Return true if it is faster to check if a floating-point value is NaN (or not-NaN) versus a comparison against a constant FP zero value.
 
LLVM_ABI InstructionCost getFPOpCost (Type *Ty) const
 Return the expected cost of supporting the floating point operation of the specified type.
 
LLVM_ABI InstructionCost getIntImmCost (const APInt &Imm, Type *Ty, TargetCostKind CostKind) const
 Return the expected cost of materializing for the given integer immediate of the specified type.
 
LLVM_ABI InstructionCost getIntImmCostInst (unsigned Opc, unsigned Idx, const APInt &Imm, Type *Ty, TargetCostKind CostKind, Instruction *Inst=nullptr) const
 Return the expected cost of materialization for the given integer immediate of the specified type for a given instruction.
 
LLVM_ABI InstructionCost getIntImmCostIntrin (Intrinsic::ID IID, unsigned Idx, const APInt &Imm, Type *Ty, TargetCostKind CostKind) const
 
LLVM_ABI InstructionCost getIntImmCodeSizeCost (unsigned Opc, unsigned Idx, const APInt &Imm, Type *Ty) const
 Return the expected cost for the given integer when optimising for size.
 
LLVM_ABI bool preferToKeepConstantsAttached (const Instruction &Inst, const Function &Fn) const
 It can be advantageous to detach complex constants from their uses to make their generation cheaper.
 

Vector Target Information

enum  ShuffleKind {
  SK_Broadcast , SK_Reverse , SK_Select , SK_Transpose ,
  SK_InsertSubvector , SK_ExtractSubvector , SK_PermuteTwoSrc , SK_PermuteSingleSrc ,
  SK_Splice
}
 The various kinds of shuffle patterns for vector queries. More...
 
enum  OperandValueKind { OK_AnyValue , OK_UniformValue , OK_UniformConstantValue , OK_NonUniformConstantValue }
 Additional information about an operand's possible values. More...
 
enum  OperandValueProperties { OP_None = 0 , OP_PowerOf2 = 1 , OP_NegatedPowerOf2 = 2 }
 Additional properties of an operand's values. More...
 
enum  RegisterKind { RGK_Scalar , RGK_FixedWidthVector , RGK_ScalableVector }
 
enum class  CacheLevel { L1D , L2D }
 The possible cache levels. More...
 
enum class  CastContextHint : uint8_t {
  None , Normal , Masked , GatherScatter ,
  Interleave , Reversed
}
 Represents a hint about the context in which a cast is used. More...
 
enum  MemIndexedMode {
  MIM_Unindexed , MIM_PreInc , MIM_PreDec , MIM_PostInc ,
  MIM_PostDec
}
 The type of load/store indexing. More...
 
enum struct  ReductionShuffle { SplitHalf , Pairwise }
 
static LLVM_ABI OperandValueInfo getOperandInfo (const Value *V)
 Collect properties of V used in cost analysis, e.g. OP_PowerOf2.
 
static LLVM_ABI CastContextHint getCastContextHint (const Instruction *I)
 Calculates a CastContextHint from I.
 
static bool requiresOrderedReduction (std::optional< FastMathFlags > FMF)
 A helper function to determine the type of reduction algorithm used for a given Opcode and set of FastMathFlags FMF.
 
LLVM_ABI unsigned getNumberOfRegisters (unsigned ClassID) const
 
LLVM_ABI bool hasConditionalLoadStoreForType (Type *Ty, bool IsStore) const
 
LLVM_ABI unsigned getRegisterClassForType (bool Vector, Type *Ty=nullptr) const
 
LLVM_ABI const chargetRegisterClassName (unsigned ClassID) const
 
LLVM_ABI TypeSize getRegisterBitWidth (RegisterKind K) const
 
LLVM_ABI unsigned getMinVectorRegisterBitWidth () const
 
LLVM_ABI std::optional< unsignedgetMaxVScale () const
 
LLVM_ABI std::optional< unsignedgetVScaleForTuning () const
 
LLVM_ABI bool isVScaleKnownToBeAPowerOfTwo () const
 
LLVM_ABI bool shouldMaximizeVectorBandwidth (TargetTransformInfo::RegisterKind K) const
 
LLVM_ABI ElementCount getMinimumVF (unsigned ElemWidth, bool IsScalable) const
 
LLVM_ABI unsigned getMaximumVF (unsigned ElemWidth, unsigned Opcode) const
 
LLVM_ABI unsigned getStoreMinimumVF (unsigned VF, Type *ScalarMemTy, Type *ScalarValTy) const
 
LLVM_ABI bool shouldConsiderAddressTypePromotion (const Instruction &I, bool &AllowPromotionWithoutCommonHeader) const
 
LLVM_ABI unsigned getCacheLineSize () const
 
LLVM_ABI std::optional< unsignedgetCacheSize (CacheLevel Level) const
 
LLVM_ABI std::optional< unsignedgetCacheAssociativity (CacheLevel Level) const
 
LLVM_ABI std::optional< unsignedgetMinPageSize () const
 
LLVM_ABI unsigned getPrefetchDistance () const
 
LLVM_ABI unsigned getMinPrefetchStride (unsigned NumMemAccesses, unsigned NumStridedMemAccesses, unsigned NumPrefetches, bool HasCall) const
 Some HW prefetchers can handle accesses up to a certain constant stride.
 
LLVM_ABI unsigned getMaxPrefetchIterationsAhead () const
 
LLVM_ABI bool enableWritePrefetching () const
 
LLVM_ABI bool shouldPrefetchAddressSpace (unsigned AS) const
 
LLVM_ABI InstructionCost getPartialReductionCost (unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType, ElementCount VF, PartialReductionExtendKind OpAExtend, PartialReductionExtendKind OpBExtend, std::optional< unsigned > BinOp, TTI::TargetCostKind CostKind) const
 
LLVM_ABI unsigned getMaxInterleaveFactor (ElementCount VF) const
 
LLVM_ABI InstructionCost getArithmeticInstrCost (unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind=TTI::TCK_RecipThroughput, TTI::OperandValueInfo Opd1Info={TTI::OK_AnyValue, TTI::OP_None}, TTI::OperandValueInfo Opd2Info={TTI::OK_AnyValue, TTI::OP_None}, ArrayRef< const Value * > Args={}, const Instruction *CxtI=nullptr, const TargetLibraryInfo *TLibInfo=nullptr) const
 This is an approximation of reciprocal throughput of a math/logic op.
 
LLVM_ABI InstructionCost getAltInstrCost (VectorType *VecTy, unsigned Opcode0, unsigned Opcode1, const SmallBitVector &OpcodeMask, TTI::TargetCostKind CostKind=TTI::TCK_RecipThroughput) const
 Returns the cost estimation for alternating opcode pattern that can be lowered to a single instruction on the target.
 
LLVM_ABI InstructionCost getShuffleCost (ShuffleKind Kind, VectorType *DstTy, VectorType *SrcTy, ArrayRef< int > Mask={}, TTI::TargetCostKind CostKind=TTI::TCK_RecipThroughput, int Index=0, VectorType *SubTp=nullptr, ArrayRef< const Value * > Args={}, const Instruction *CxtI=nullptr) const
 
LLVM_ABI InstructionCost getCastInstrCost (unsigned Opcode, Type *Dst, Type *Src, TTI::CastContextHint CCH, TTI::TargetCostKind CostKind=TTI::TCK_SizeAndLatency, const Instruction *I=nullptr) const
 
LLVM_ABI InstructionCost getExtractWithExtendCost (unsigned Opcode, Type *Dst, VectorType *VecTy, unsigned Index, TTI::TargetCostKind CostKind) const
 
LLVM_ABI InstructionCost getCFInstrCost (unsigned Opcode, TTI::TargetCostKind CostKind=TTI::TCK_SizeAndLatency, const Instruction *I=nullptr) const
 
LLVM_ABI InstructionCost getCmpSelInstrCost (unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred, TTI::TargetCostKind CostKind=TTI::TCK_RecipThroughput, OperandValueInfo Op1Info={OK_AnyValue, OP_None}, OperandValueInfo Op2Info={OK_AnyValue, OP_None}, const Instruction *I=nullptr) const
 
LLVM_ABI InstructionCost getVectorInstrCost (unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index=-1, const Value *Op0=nullptr, const Value *Op1=nullptr) const
 
LLVM_ABI InstructionCost getVectorInstrCost (unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, Value *Scalar, ArrayRef< std::tuple< Value *, User *, int > > ScalarUserAndIdx) const
 
LLVM_ABI InstructionCost getVectorInstrCost (const Instruction &I, Type *Val, TTI::TargetCostKind CostKind, unsigned Index=-1) const
 
LLVM_ABI InstructionCost getIndexedVectorInstrCostFromEnd (unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index) const
 
LLVM_ABI InstructionCost getInsertExtractValueCost (unsigned Opcode, TTI::TargetCostKind CostKind) const
 
LLVM_ABI InstructionCost getReplicationShuffleCost (Type *EltTy, int ReplicationFactor, int VF, const APInt &DemandedDstElts, TTI::TargetCostKind CostKind) const
 
LLVM_ABI InstructionCost getMemoryOpCost (unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind=TTI::TCK_RecipThroughput, OperandValueInfo OpdInfo={OK_AnyValue, OP_None}, const Instruction *I=nullptr) const
 
LLVM_ABI InstructionCost getVPMemoryOpCost (unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind=TTI::TCK_RecipThroughput, const Instruction *I=nullptr) const
 
LLVM_ABI InstructionCost getMaskedMemoryOpCost (unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind=TTI::TCK_RecipThroughput) const
 
LLVM_ABI InstructionCost getGatherScatterOpCost (unsigned Opcode, Type *DataTy, const Value *Ptr, bool VariableMask, Align Alignment, TTI::TargetCostKind CostKind=TTI::TCK_RecipThroughput, const Instruction *I=nullptr) const
 
LLVM_ABI InstructionCost getExpandCompressMemoryOpCost (unsigned Opcode, Type *DataTy, bool VariableMask, Align Alignment, TTI::TargetCostKind CostKind=TTI::TCK_RecipThroughput, const Instruction *I=nullptr) const
 
LLVM_ABI InstructionCost getStridedMemoryOpCost (unsigned Opcode, Type *DataTy, const Value *Ptr, bool VariableMask, Align Alignment, TTI::TargetCostKind CostKind=TTI::TCK_RecipThroughput, const Instruction *I=nullptr) const
 
LLVM_ABI InstructionCost getInterleavedMemoryOpCost (unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind=TTI::TCK_RecipThroughput, bool UseMaskForCond=false, bool UseMaskForGaps=false) const
 
LLVM_ABI InstructionCost getArithmeticReductionCost (unsigned Opcode, VectorType *Ty, std::optional< FastMathFlags > FMF, TTI::TargetCostKind CostKind=TTI::TCK_RecipThroughput) const
 Calculate the cost of vector reduction intrinsics.
 
LLVM_ABI InstructionCost getMinMaxReductionCost (Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF=FastMathFlags(), TTI::TargetCostKind CostKind=TTI::TCK_RecipThroughput) const
 
LLVM_ABI InstructionCost getMulAccReductionCost (bool IsUnsigned, unsigned RedOpcode, Type *ResTy, VectorType *Ty, TTI::TargetCostKind CostKind=TTI::TCK_RecipThroughput) const
 Calculate the cost of an extended reduction pattern, similar to getArithmeticReductionCost of an Add/Sub reduction with multiply and optional extensions.
 
LLVM_ABI InstructionCost getExtendedReductionCost (unsigned Opcode, bool IsUnsigned, Type *ResTy, VectorType *Ty, std::optional< FastMathFlags > FMF, TTI::TargetCostKind CostKind=TTI::TCK_RecipThroughput) const
 Calculate the cost of an extended reduction pattern, similar to getArithmeticReductionCost of a reduction with an extension.
 
LLVM_ABI InstructionCost getIntrinsicInstrCost (const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind) const
 
LLVM_ABI InstructionCost getCallInstrCost (Function *F, Type *RetTy, ArrayRef< Type * > Tys, TTI::TargetCostKind CostKind=TTI::TCK_SizeAndLatency) const
 
LLVM_ABI unsigned getNumberOfParts (Type *Tp) const
 
LLVM_ABI InstructionCost getAddressComputationCost (Type *PtrTy, ScalarEvolution *SE, const SCEV *Ptr, TTI::TargetCostKind CostKind) const
 
LLVM_ABI InstructionCost getCostOfKeepingLiveOverCall (ArrayRef< Type * > Tys) const
 
LLVM_ABI bool getTgtMemIntrinsic (IntrinsicInst *Inst, MemIntrinsicInfo &Info) const
 
LLVM_ABI unsigned getAtomicMemIntrinsicMaxElementSize () const
 
LLVM_ABI ValuegetOrCreateResultFromMemIntrinsic (IntrinsicInst *Inst, Type *ExpectedType, bool CanCreate=true) const
 
LLVM_ABI TypegetMemcpyLoopLoweringType (LLVMContext &Context, Value *Length, unsigned SrcAddrSpace, unsigned DestAddrSpace, Align SrcAlign, Align DestAlign, std::optional< uint32_t > AtomicElementSize=std::nullopt) const
 
LLVM_ABI void getMemcpyLoopResidualLoweringType (SmallVectorImpl< Type * > &OpsOut, LLVMContext &Context, unsigned RemainingBytes, unsigned SrcAddrSpace, unsigned DestAddrSpace, Align SrcAlign, Align DestAlign, std::optional< uint32_t > AtomicCpySize=std::nullopt) const
 
LLVM_ABI bool areInlineCompatible (const Function *Caller, const Function *Callee) const
 
LLVM_ABI unsigned getInlineCallPenalty (const Function *F, const CallBase &Call, unsigned DefaultCallPenalty) const
 Returns a penalty for invoking call Call in F.
 
LLVM_ABI bool areTypesABICompatible (const Function *Caller, const Function *Callee, const ArrayRef< Type * > &Types) const
 
LLVM_ABI bool isIndexedLoadLegal (enum MemIndexedMode Mode, Type *Ty) const
 
LLVM_ABI bool isIndexedStoreLegal (enum MemIndexedMode Mode, Type *Ty) const
 
LLVM_ABI unsigned getLoadStoreVecRegBitWidth (unsigned AddrSpace) const
 
LLVM_ABI bool isLegalToVectorizeLoad (LoadInst *LI) const
 
LLVM_ABI bool isLegalToVectorizeStore (StoreInst *SI) const
 
LLVM_ABI bool isLegalToVectorizeLoadChain (unsigned ChainSizeInBytes, Align Alignment, unsigned AddrSpace) const
 
LLVM_ABI bool isLegalToVectorizeStoreChain (unsigned ChainSizeInBytes, Align Alignment, unsigned AddrSpace) const
 
LLVM_ABI bool isLegalToVectorizeReduction (const RecurrenceDescriptor &RdxDesc, ElementCount VF) const
 
LLVM_ABI bool isElementTypeLegalForScalableVector (Type *Ty) const
 
LLVM_ABI unsigned getLoadVectorFactor (unsigned VF, unsigned LoadSize, unsigned ChainSizeInBytes, VectorType *VecTy) const
 
LLVM_ABI unsigned getStoreVectorFactor (unsigned VF, unsigned StoreSize, unsigned ChainSizeInBytes, VectorType *VecTy) const
 
LLVM_ABI bool preferFixedOverScalableIfEqualCost () const
 
LLVM_ABI bool preferAlternateOpcodeVectorization () const
 
LLVM_ABI bool preferInLoopReduction (RecurKind Kind, Type *Ty) const
 
LLVM_ABI bool preferPredicatedReductionSelect () const
 
LLVM_ABI bool preferEpilogueVectorization () const
 Return true if the loop vectorizer should consider vectorizing an otherwise scalar epilogue loop.
 
LLVM_ABI bool shouldExpandReduction (const IntrinsicInst *II) const
 
LLVM_ABI ReductionShuffle getPreferredExpandedReductionShuffle (const IntrinsicInst *II) const
 
LLVM_ABI unsigned getGISelRematGlobalCost () const
 
LLVM_ABI unsigned getMinTripCountTailFoldingThreshold () const
 
LLVM_ABI bool supportsScalableVectors () const
 
LLVM_ABI bool enableScalableVectorization () const
 

Detailed Description

This pass provides access to the codegen interfaces that are needed for IR-level transformations.

Definition at line 219 of file TargetTransformInfo.h.

Member Enumeration Documentation

◆ AddressingModeKind

Enumerator
AMK_PreIndexed 
AMK_PostIndexed 
AMK_None 

Definition at line 797 of file TargetTransformInfo.h.

◆ CacheLevel

The possible cache levels.

Enumerator
L1D 
L2D 

Definition at line 1266 of file TargetTransformInfo.h.

◆ CastContextHint

Represents a hint about the context in which a cast is used.

For zext/sext, the context of the cast is the operand, which must be a load of some kind. For trunc, the context is of the cast is the single user of the instruction, which must be a store of some kind.

This enum allows the vectorizer to give getCastInstrCost an idea of the type of cast it's dealing with, as not every cast is equal. For instance, the zext of a load may be free, but the zext of an interleaving load can be (very) expensive!

See getCastContextHint to compute a CastContextHint from a cast Instruction*. Callers can use it if they don't need to override the context and just want it to be calculated from the instruction.

FIXME: This handles the types of load/store that the vectorizer can produce, which are the cases where the context instruction is most likely to be incorrect. There are other situations where that can happen too, which might be handled here but in the long run a more general solution of costing multiple instructions at the same times may be better.

Enumerator
None 

The cast is not used with a load/store of any kind.

Normal 

The cast is used with a normal load/store.

Masked 

The cast is used with a masked load/store.

GatherScatter 

The cast is used with a gather/scatter.

Interleave 

The cast is used with an interleaved load/store.

Reversed 

The cast is used with a reversed load/store.

Definition at line 1428 of file TargetTransformInfo.h.

◆ MemIndexedMode

The type of load/store indexing.

Enumerator
MIM_Unindexed 

No indexing.

MIM_PreInc 

Pre-incrementing.

MIM_PreDec 

Pre-decrementing.

MIM_PostInc 

Post-incrementing.

MIM_PostDec 

Post-decrementing.

Definition at line 1762 of file TargetTransformInfo.h.

◆ OperandValueKind

Additional information about an operand's possible values.

Enumerator
OK_AnyValue 
OK_UniformValue 
OK_UniformConstantValue 
OK_NonUniformConstantValue 

Definition at line 1143 of file TargetTransformInfo.h.

◆ OperandValueProperties

Additional properties of an operand's values.

Enumerator
OP_None 
OP_PowerOf2 
OP_NegatedPowerOf2 

Definition at line 1151 of file TargetTransformInfo.h.

◆ PartialReductionExtendKind

Enumerator
PR_None 
PR_SignExtend 
PR_ZeroExtend 

Definition at line 221 of file TargetTransformInfo.h.

◆ PopcntSupportKind

Flags indicating the kind of support for population count.

Compared to the SW implementation, HW support is supposed to significantly boost the performance when the population is dense, and it may or may not degrade performance if the population is sparse. A HW support is considered as "Fast" if it can outperform, or is on a par with, SW implementation when the population is sparse; otherwise, it is considered as "Slow".

Enumerator
PSK_Software 
PSK_SlowHardware 
PSK_FastHardware 

Definition at line 735 of file TargetTransformInfo.h.

◆ ReductionShuffle

Enumerator
SplitHalf 
Pairwise 

Definition at line 1849 of file TargetTransformInfo.h.

◆ RegisterKind

Enumerator
RGK_Scalar 
RGK_FixedWidthVector 
RGK_ScalableVector 

Definition at line 1206 of file TargetTransformInfo.h.

◆ ShuffleKind

The various kinds of shuffle patterns for vector queries.

Enumerator
SK_Broadcast 

Broadcast element 0 to all other elements.

SK_Reverse 

Reverse the order of the vector.

SK_Select 

Selects elements from the corresponding lane of either source operand.

This is equivalent to a vector select with a constant condition operand.

SK_Transpose 

Transpose two vectors.

SK_InsertSubvector 

InsertSubvector. Index indicates start offset.

SK_ExtractSubvector 

ExtractSubvector Index indicates start offset.

SK_PermuteTwoSrc 

Merge elements from two source vectors into one with any shuffle mask.

SK_PermuteSingleSrc 

Shuffle elements of single source vector with any shuffle mask.

SK_Splice 

Concatenates elements from the first input vector with elements of the second input vector.

Returning a vector of the same type as the input vectors. Index indicates start offset in first input vector.

Definition at line 1123 of file TargetTransformInfo.h.

◆ TargetCostConstants

Underlying constants for 'cost' values in this interface.

Many APIs in this interface return a cost. This enum defines the fundamental values that should be used to interpret (and produce) those costs. The costs are returned as an int rather than a member of this enumeration because it is expected that the cost of one IR instruction may have a multiplicative factor to it or otherwise won't fit directly into the enum. Moreover, it is common to sum or average costs which works better as simple integral values. Thus this enum only provides constants. Also note that the returned costs are signed integers to make it natural to add, subtract, and test with zero (a common boundary condition). It is not expected that 2^32 is a realistic cost to be modeling at any point.

Note that these costs should usually reflect the intersection of code-size cost and execution cost. A free instruction is typically one that folds into another instruction. For example, reg-to-reg moves can often be skipped by renaming the registers in the CPU, but they still are encoded and thus wouldn't be considered 'free' here.

Enumerator
TCC_Free 

Expected to fold away in lowering.

TCC_Basic 

The cost of a typical 'add' instruction.

TCC_Expensive 

The cost of a 'div' instruction on x86.

Definition at line 296 of file TargetTransformInfo.h.

◆ TargetCostKind

The kind of cost model.

There are several different cost models that can be customized by the target. The normalization of each cost model may be target specific. e.g. TCK_SizeAndLatency should be comparable to target thresholds such as those derived from MCSchedModel::LoopMicroOpBufferSize etc.

Enumerator
TCK_RecipThroughput 

Reciprocal throughput.

TCK_Latency 

The latency of instruction.

TCK_CodeSize 

Instruction code size.

TCK_SizeAndLatency 

The weighted sum of size and latency.

Definition at line 271 of file TargetTransformInfo.h.

Constructor & Destructor Documentation

◆ TargetTransformInfo() [1/3]

TargetTransformInfo::TargetTransformInfo ( std::unique_ptr< const TargetTransformInfoImplBase Impl)
explicit

Construct a TTI object using a type implementing the Concept API below.

This is used by targets to construct a TTI wrapping their target-specific implementation that encodes appropriate costs for their target.

Definition at line 60 of file TargetTransformInfo.cpp.

◆ TargetTransformInfo() [2/3]

TargetTransformInfo::TargetTransformInfo ( const DataLayout DL)
explicit

Construct a baseline TTI object using a minimal implementation of the Concept API below.

The TTI implementation will reflect the information in the DataLayout provided if non-null.

Definition at line 205 of file TargetTransformInfo.cpp.

◆ TargetTransformInfo() [3/3]

TargetTransformInfo::TargetTransformInfo ( TargetTransformInfo &&  Arg)

Definition at line 210 of file TargetTransformInfo.cpp.

◆ ~TargetTransformInfo()

TargetTransformInfo::~TargetTransformInfo ( )
default

Member Function Documentation

◆ addrspacesMayAlias()

bool llvm::TargetTransformInfo::addrspacesMayAlias ( unsigned  AS0,
unsigned  AS1 
) const

Return false if a AS0 address cannot possibly alias a AS1 address.

Definition at line 313 of file TargetTransformInfo.cpp.

Referenced by llvm::expandMemMoveAsLoop().

◆ adjustInliningThreshold()

unsigned TargetTransformInfo::adjustInliningThreshold ( const CallBase CB) const
Returns
A value to be added to the inlining threshold.

Definition at line 238 of file TargetTransformInfo.cpp.

◆ allowsMisalignedMemoryAccesses()

bool TargetTransformInfo::allowsMisalignedMemoryAccesses ( LLVMContext Context,
unsigned  BitWidth,
unsigned  AddressSpace = 0,
Align  Alignment = Align(1),
unsigned Fast = nullptr 
) const

Determine if the target supports unaligned memory accesses.

Definition at line 688 of file TargetTransformInfo.cpp.

References llvm::BitWidth, Context, and llvm::CallingConv::Fast.

Referenced by foldConsecutiveLoads(), and mergeConsecutivePartStores().

◆ allowVectorElementIndexingUsingGEP()

bool TargetTransformInfo::allowVectorElementIndexingUsingGEP ( ) const

Returns true if GEP should not be used to index into vectors for this target.

Definition at line 1499 of file TargetTransformInfo.cpp.

◆ areInlineCompatible()

bool TargetTransformInfo::areInlineCompatible ( const Function Caller,
const Function Callee 
) const
Returns
True if the two functions have compatible attributes for inlining purposes.

Definition at line 1331 of file TargetTransformInfo.cpp.

Referenced by functionsHaveCompatibleAttributes().

◆ areTypesABICompatible()

bool TargetTransformInfo::areTypesABICompatible ( const Function Caller,
const Function Callee,
const ArrayRef< Type * > &  Types 
) const
Returns
True if the caller and callee agree on how Types will be passed to or returned from the callee. to the callee.
Parameters
TypesList of types to check.

Definition at line 1343 of file TargetTransformInfo.cpp.

◆ canHaveNonUndefGlobalInitializerInAddressSpace()

bool TargetTransformInfo::canHaveNonUndefGlobalInitializerInAddressSpace ( unsigned  AS) const

Return true if globals in this address space can have initializers other than undef.

Definition at line 332 of file TargetTransformInfo.cpp.

◆ canMacroFuseCmp()

bool TargetTransformInfo::canMacroFuseCmp ( ) const

Return true if the target can fuse a compare and branch.

Loop-strength-reduction (LSR) uses that knowledge to adjust its cost calculation for the instructions in a loop.

Definition at line 452 of file TargetTransformInfo.cpp.

◆ canSaveCmp()

bool TargetTransformInfo::canSaveCmp ( Loop L,
BranchInst **  BI,
ScalarEvolution SE,
LoopInfo LI,
DominatorTree DT,
AssumptionCache AC,
TargetLibraryInfo LibInfo 
) const

Return true if the target can save a compare for loop count, for example hardware loop saves a compare.

Definition at line 456 of file TargetTransformInfo.cpp.

◆ collectFlatAddressOperands()

bool TargetTransformInfo::collectFlatAddressOperands ( SmallVectorImpl< int > &  OpIndexes,
Intrinsic::ID  IID 
) const

Return any intrinsic address operand indexes which may be rewritten if they use a flat address space pointer.

Returns
true if the intrinsic was handled.

Definition at line 322 of file TargetTransformInfo.cpp.

◆ collectKernelLaunchBounds()

void TargetTransformInfo::collectKernelLaunchBounds ( const Function F,
SmallVectorImpl< std::pair< StringRef, int64_t > > &  LB 
) const

Collect kernel launch bounds for F into LB.

Definition at line 1493 of file TargetTransformInfo.cpp.

References F.

◆ enableAggressiveInterleaving()

bool TargetTransformInfo::enableAggressiveInterleaving ( bool  LoopHasReductions) const

Don't restrict interleaved unrolling to small loops.

Definition at line 656 of file TargetTransformInfo.cpp.

Referenced by llvm::LoopVectorizationPlanner::selectInterleaveCount().

◆ enableInterleavedAccessVectorization()

bool TargetTransformInfo::enableInterleavedAccessVectorization ( ) const

Enable matching of interleaved access groups.

Definition at line 675 of file TargetTransformInfo.cpp.

Referenced by llvm::LoopVectorizePass::processLoop().

◆ enableMaskedInterleavedAccessVectorization()

bool TargetTransformInfo::enableMaskedInterleavedAccessVectorization ( ) const

Enable matching of interleaved access groups that contain predicated accesses or gaps and therefore vectorized using masked vector loads/stores.

Definition at line 679 of file TargetTransformInfo.cpp.

Referenced by useMaskedInterleavedAccesses().

◆ enableMemCmpExpansion()

TargetTransformInfo::MemCmpExpansionOptions TargetTransformInfo::enableMemCmpExpansion ( bool  OptSize,
bool  IsZeroCmp 
) const

Definition at line 662 of file TargetTransformInfo.cpp.

◆ enableOrderedReductions()

bool TargetTransformInfo::enableOrderedReductions ( ) const

Return true if we should be enabling ordered reductions for the target.

Definition at line 546 of file TargetTransformInfo.cpp.

Referenced by llvm::LoopVectorizePass::processLoop().

◆ enableScalableVectorization()

bool TargetTransformInfo::enableScalableVectorization ( ) const
Returns
true when scalable vectorization is preferred.

Definition at line 1470 of file TargetTransformInfo.cpp.

Referenced by determineVPlanVF(), llvm::LoopAccessInfo::LoopAccessInfo(), and llvm::LoopVectorizeHints::LoopVectorizeHints().

◆ enableSelectOptimize()

bool TargetTransformInfo::enableSelectOptimize ( ) const

Should the Select Optimization pass be enabled and ran.

Definition at line 666 of file TargetTransformInfo.cpp.

◆ enableWritePrefetching()

bool TargetTransformInfo::enableWritePrefetching ( ) const
Returns
True if prefetching should also be done for writes.

Definition at line 862 of file TargetTransformInfo.cpp.

◆ forceScalarizeMaskedGather()

bool TargetTransformInfo::forceScalarizeMaskedGather ( VectorType Type,
Align  Alignment 
) const

Return true if the target forces scalarizing of llvm.masked.gather intrinsics.

Definition at line 509 of file TargetTransformInfo.cpp.

Referenced by llvm::slpvectorizer::BoUpSLP::canVectorizeLoads(), and optimizeCallInst().

◆ forceScalarizeMaskedScatter()

bool TargetTransformInfo::forceScalarizeMaskedScatter ( VectorType Type,
Align  Alignment 
) const

Return true if the target forces scalarizing of llvm.masked.scatter intrinsics.

Definition at line 514 of file TargetTransformInfo.cpp.

Referenced by optimizeCallInst().

◆ getAddressComputationCost()

InstructionCost TargetTransformInfo::getAddressComputationCost ( Type PtrTy,
ScalarEvolution SE,
const SCEV Ptr,
TTI::TargetCostKind  CostKind 
) const
Returns
The cost of the address computation. For most targets this can be merged into the instruction indexing mode. Some targets might want to distinguish between address computation for memory operations with vector pointer types and scalar pointer types. Such targets should override this function. SE holds the pointer for the scalar evolution object which was used in order to get the Ptr step value. Ptr holds the SCEV of the access pointer.

Definition at line 1241 of file TargetTransformInfo.cpp.

References assert(), CostKind, and Ptr.

Referenced by chainToBasePointerCost(), and llvm::VPWidenMemoryRecipe::computeCost().

◆ getAltInstrCost()

InstructionCost TargetTransformInfo::getAltInstrCost ( VectorType VecTy,
unsigned  Opcode0,
unsigned  Opcode1,
const SmallBitVector OpcodeMask,
TTI::TargetCostKind  CostKind = TTI::TCK_RecipThroughput 
) const

Returns the cost estimation for alternating opcode pattern that can be lowered to a single instruction on the target.

In X86 this is for the addsub instruction which corrsponds to a Shuffle + Fadd + FSub pattern in IR. This function expects two opcodes: Opcode1 and Opcode2 being selected by OpcodeMask. The mask contains one bit per lane and is a 0 when Opcode0 is selected and 1 when Opcode1 is selected. VecTy is the vector type of the instruction to be generated.

Definition at line 977 of file TargetTransformInfo.cpp.

References assert(), and CostKind.

◆ getArithmeticInstrCost()

InstructionCost TargetTransformInfo::getArithmeticInstrCost ( unsigned  Opcode,
Type Ty,
TTI::TargetCostKind  CostKind = TTI::TCK_RecipThroughput,
TTI::OperandValueInfo  Opd1Info = {TTI::OK_AnyValueTTI::OP_None},
TTI::OperandValueInfo  Opd2Info = {TTI::OK_AnyValueTTI::OP_None},
ArrayRef< const Value * >  Args = {},
const Instruction CxtI = nullptr,
const TargetLibraryInfo TLibInfo = nullptr 
) const

This is an approximation of reciprocal throughput of a math/logic op.

A higher cost indicates less expected throughput. From Agner Fog's guides, reciprocal throughput is "the average number of clock cycles per instruction when the instructions are not part of a limiting dependency chain." Therefore, costs should be scaled to account for multiple execution units on the target that can process this type of instruction. For example, if there are 5 scalar integer units and 2 vector integer units that can calculate an 'add' in a single cycle, this model should indicate that the cost of the vector add instruction is 2.5 times the cost of the scalar add instruction. Args is an optional argument which holds the instruction operands values so the TTI can analyze those values searching for special cases or optimizations based on those values. CxtI is the optional original context instruction, if one exists, to provide even more information. TLibInfo is used to search for platform specific vector library functions for instructions that might be converted to calls (e.g. frem).

Definition at line 950 of file TargetTransformInfo.cpp.

References assert(), CostKind, getCallInstrCost(), llvm::VectorType::getElementCount(), llvm::TargetLibraryInfo::getLibFunc(), llvm::TargetLibraryInfo::getName(), llvm::Type::getScalarType(), and llvm::TargetLibraryInfo::isFunctionVectorizable().

Referenced by analyzeCostOfVecReduction(), llvm::VPHistogramRecipe::computeCost(), llvm::VPWidenSelectRecipe::computeCost(), costAndCollectOperands(), llvm::foldBranchToCommonDest(), llvm::VPRecipeWithIRFlags::getCostForRecipeWithOpcode(), llvm::LoopVectorizationCostModel::getDivRemSpeculationCost(), llvm::LoopVectorizationCostModel::getInstructionCost(), llvm::LoopVectorizationCostModel::getReductionPatternCost(), tryNarrowMathIfNoOverflow(), and visitIVCast().

◆ getArithmeticReductionCost()

InstructionCost TargetTransformInfo::getArithmeticReductionCost ( unsigned  Opcode,
VectorType Ty,
std::optional< FastMathFlags FMF,
TTI::TargetCostKind  CostKind = TTI::TCK_RecipThroughput 
) const

Calculate the cost of vector reduction intrinsics.

This is the cost of reducing the vector value of type Ty to a scalar value using the operation denoted by Opcode. The FastMathFlags parameter FMF indicates what type of reduction we are performing:

  1. Tree-wise. This is the typical 'fast' reduction performed that involves successively splitting a vector into half and doing the operation on the pair of halves until you have a scalar value. For example: (v0, v1, v2, v3) ((v0+v2), (v1+v3), undef, undef) ((v0+v2+v1+v3), undef, undef, undef) This is the default behaviour for integer operations, whereas for floating point we only do this if FMF indicates that reassociation is allowed.
  2. Ordered. For a vector with N elements this involves performing N operations in lane order, starting with an initial scalar value, i.e. result = InitVal + v0 result = result + v1 result = result + v2 result = result + v3 This is only the case for FP operations and when reassociation is not allowed.

Definition at line 1260 of file TargetTransformInfo.cpp.

References assert(), and CostKind.

Referenced by analyzeCostOfVecReduction(), llvm::VPInstruction::computeCost(), llvm::VPReductionRecipe::computeCost(), and llvm::LoopVectorizationCostModel::getReductionPatternCost().

◆ getAssumedAddrSpace()

unsigned TargetTransformInfo::getAssumedAddrSpace ( const Value V) const

Definition at line 337 of file TargetTransformInfo.cpp.

Referenced by isAddressExpression().

◆ getAtomicMemIntrinsicMaxElementSize()

unsigned TargetTransformInfo::getAtomicMemIntrinsicMaxElementSize ( ) const
Returns
The maximum element size, in bytes, for an element unordered-atomic memory intrinsic.

Definition at line 1302 of file TargetTransformInfo.cpp.

◆ getBranchMispredictPenalty()

InstructionCost TargetTransformInfo::getBranchMispredictPenalty ( ) const

Returns estimated penalty of a branch misprediction in latency.

Indicates how aggressive the target wants for eliminating unpredictable branches. A zero return value means extra optimization applied to them should be minimal.

Definition at line 288 of file TargetTransformInfo.cpp.

Referenced by foldTwoEntryPHINode().

◆ getCacheAssociativity()

std::optional< unsigned > TargetTransformInfo::getCacheAssociativity ( CacheLevel  Level) const
Returns
The associativity of the cache level, if available.

Definition at line 838 of file TargetTransformInfo.cpp.

◆ getCacheLineSize()

unsigned TargetTransformInfo::getCacheLineSize ( ) const
Returns
The size of a cache line in bytes.

Definition at line 827 of file TargetTransformInfo.cpp.

References CacheLineSize.

◆ getCacheSize()

std::optional< unsigned > TargetTransformInfo::getCacheSize ( CacheLevel  Level) const
Returns
The size of the cache level in bytes, if available.

Definition at line 833 of file TargetTransformInfo.cpp.

◆ getCallerAllocaCost()

unsigned TargetTransformInfo::getCallerAllocaCost ( const CallBase CB,
const AllocaInst AI 
) const
Returns
The cost of having an Alloca in the caller if not inlined, to be added to the threshold

Definition at line 242 of file TargetTransformInfo.cpp.

◆ getCallInstrCost()

InstructionCost TargetTransformInfo::getCallInstrCost ( Function F,
Type RetTy,
ArrayRef< Type * >  Tys,
TTI::TargetCostKind  CostKind = TTI::TCK_SizeAndLatency 
) const

◆ getCastContextHint()

TTI::CastContextHint TargetTransformInfo::getCastContextHint ( const Instruction I)
static

Calculates a CastContextHint from I.

This should be used by callers of getCastInstrCost if they wish to determine the context from some instruction.

Returns
the CastContextHint for ZExt/SExt/Trunc, None if I is nullptr, or if it's another type of cast.

Definition at line 1011 of file TargetTransformInfo.cpp.

References GatherScatter, I, II, Masked, None, and Normal.

Referenced by chainToBasePointerCost(), llvm::TargetTransformInfoImplCRTPBase< T >::getInstructionCost(), llvm::AArch64TargetLowering::optimizeExtendOrTruncateConversion(), and tryNarrowMathIfNoOverflow().

◆ getCastInstrCost()

InstructionCost TargetTransformInfo::getCastInstrCost ( unsigned  Opcode,
Type Dst,
Type Src,
TTI::CastContextHint  CCH,
TTI::TargetCostKind  CostKind = TTI::TCK_SizeAndLatency,
const Instruction I = nullptr 
) const

◆ getCFInstrCost()

InstructionCost TargetTransformInfo::getCFInstrCost ( unsigned  Opcode,
TTI::TargetCostKind  CostKind = TTI::TCK_SizeAndLatency,
const Instruction I = nullptr 
) const

◆ getCmpSelInstrCost()

InstructionCost TargetTransformInfo::getCmpSelInstrCost ( unsigned  Opcode,
Type ValTy,
Type CondTy,
CmpInst::Predicate  VecPred,
TTI::TargetCostKind  CostKind = TTI::TCK_RecipThroughput,
OperandValueInfo  Op1Info = {OK_AnyValueOP_None},
OperandValueInfo  Op2Info = {OK_AnyValueOP_None},
const Instruction I = nullptr 
) const
Returns
The expected cost of compare and select instructions. If there is an existing instruction that holds Opcode, it may be passed in the 'I' parameter. The VecPred parameter can be used to indicate the select is using a compare with the specified predicate as condition. When vector types are passed, VecPred must be used for all lanes. For a comparison, the two operands are the natural values. For a select, the two operands are the value operands, not the condition operand.

Definition at line 1083 of file TargetTransformInfo.cpp.

References assert(), CostKind, and I.

Referenced by llvm::VPInstruction::computeCost(), llvm::VPWidenSelectRecipe::computeCost(), llvm::VPBlendRecipe::computeCost(), costAndCollectOperands(), findCostForOutputBlocks(), llvm::VPRecipeWithIRFlags::getCostForRecipeWithOpcode(), llvm::LoopVectorizationCostModel::getDivRemSpeculationCost(), llvm::LoopVectorizationCostModel::getInstructionCost(), and validateAndCostRequiredSelects().

◆ getCostOfKeepingLiveOverCall()

InstructionCost TargetTransformInfo::getCostOfKeepingLiveOverCall ( ArrayRef< Type * >  Tys) const
Returns
The cost, if any, of keeping values of the given types alive over a callsite.

Some types may require the use of register classes that do not have any callee-saved registers, so would require a spill and fill.

Definition at line 1293 of file TargetTransformInfo.cpp.

Referenced by llvm::slpvectorizer::BoUpSLP::getSpillCost().

◆ getEpilogueVectorizationMinVF()

unsigned TargetTransformInfo::getEpilogueVectorizationMinVF ( ) const

◆ getEstimatedNumberOfCaseClusters()

unsigned TargetTransformInfo::getEstimatedNumberOfCaseClusters ( const SwitchInst SI,
unsigned JTSize,
ProfileSummaryInfo PSI,
BlockFrequencyInfo BFI 
) const
Returns
The estimated number of case clusters when lowering 'SI'. JTSize Set a jump table size only when SI is suitable for a jump table.

Definition at line 266 of file TargetTransformInfo.cpp.

◆ getExpandCompressMemoryOpCost()

InstructionCost TargetTransformInfo::getExpandCompressMemoryOpCost ( unsigned  Opcode,
Type DataTy,
bool  VariableMask,
Align  Alignment,
TTI::TargetCostKind  CostKind = TTI::TCK_RecipThroughput,
const Instruction I = nullptr 
) const
Returns
The cost of Expand Load or Compress Store operation Opcode - is a type of memory access Load or Store Src - a vector type of the data to be loaded or stored VariableMask - true when the memory access is predicated with a mask that is not a compile-time constant Alignment - alignment of single element I - the optional original context instruction, if one exists, e.g. the load/store to transform or the call to the gather/scatter intrinsic

Definition at line 1191 of file TargetTransformInfo.cpp.

References assert(), CostKind, and I.

◆ getExtendedReductionCost()

InstructionCost TargetTransformInfo::getExtendedReductionCost ( unsigned  Opcode,
bool  IsUnsigned,
Type ResTy,
VectorType Ty,
std::optional< FastMathFlags FMF,
TTI::TargetCostKind  CostKind = TTI::TCK_RecipThroughput 
) const

Calculate the cost of an extended reduction pattern, similar to getArithmeticReductionCost of a reduction with an extension.

This is the cost of as: ResTy vecreduce.opcode(ext(Ty A)).

Definition at line 1278 of file TargetTransformInfo.cpp.

References CostKind.

Referenced by analyzeCostOfVecReduction(), llvm::VPExpressionRecipe::computeCost(), llvm::LoopVectorizationCostModel::getReductionPatternCost(), and tryToMatchAndCreateExtendedReduction().

◆ getExtractWithExtendCost()

InstructionCost TargetTransformInfo::getExtractWithExtendCost ( unsigned  Opcode,
Type Dst,
VectorType VecTy,
unsigned  Index,
TTI::TargetCostKind  CostKind 
) const
Returns
The expected cost of a sign- or zero-extended vector extract. Use Index = -1 to indicate that there is no information about the index value.

Definition at line 1065 of file TargetTransformInfo.cpp.

References assert(), and CostKind.

Referenced by getExtractWithExtendCost().

◆ getFeatureMask()

APInt TargetTransformInfo::getFeatureMask ( const Function F) const

Returns a bitmask constructed from the target-features or fmv-features metadata of a function.

Definition at line 1436 of file TargetTransformInfo.cpp.

References F.

Referenced by OptimizeNonTrivialIFuncs().

◆ getFlatAddressSpace()

unsigned TargetTransformInfo::getFlatAddressSpace ( ) const

Returns the address space ID for a target's 'flat' address space.

Note this is not necessarily the same as addrspace(0), which LLVM sometimes refers to as the generic address space. The flat address space is a generic address space that can be used access multiple segments of memory with different address spaces. Access of a memory location through a pointer with this address space is expected to be legal but slower compared to the same memory location accessed through a pointer with a different address space. This is for targets with different pointer representations which can be converted with the addrspacecast instruction. If a pointer is converted to this address space, optimizations should attempt to replace the access with the source address space.

Returns
~0u if the target does not have such a flat address space to optimize away.

Definition at line 318 of file TargetTransformInfo.cpp.

◆ getFPOpCost()

InstructionCost TargetTransformInfo::getFPOpCost ( Type Ty) const

Return the expected cost of supporting the floating point operation of the specified type.

Definition at line 715 of file TargetTransformInfo.cpp.

References assert().

◆ getGatherScatterOpCost()

InstructionCost TargetTransformInfo::getGatherScatterOpCost ( unsigned  Opcode,
Type DataTy,
const Value Ptr,
bool  VariableMask,
Align  Alignment,
TTI::TargetCostKind  CostKind = TTI::TCK_RecipThroughput,
const Instruction I = nullptr 
) const
Returns
The cost of Gather or Scatter operation Opcode - is a type of memory access Load or Store DataTy - a vector type of the data to be loaded or stored Ptr - pointer [or vector of pointers] - address[es] in memory VariableMask - true when the memory access is predicated with a mask that is not a compile-time constant Alignment - alignment of single element I - the optional original context instruction, if one exists, e.g. the load/store to transform or the call to the gather/scatter intrinsic

Definition at line 1181 of file TargetTransformInfo.cpp.

References assert(), CostKind, I, llvm::InstructionCost::isValid(), and Ptr.

Referenced by llvm::slpvectorizer::BoUpSLP::canVectorizeLoads(), and llvm::VPWidenMemoryRecipe::computeCost().

◆ getGEPCost()

InstructionCost TargetTransformInfo::getGEPCost ( Type PointeeType,
const Value Ptr,
ArrayRef< const Value * >  Operands,
Type AccessType = nullptr,
TTI::TargetCostKind  CostKind = TCK_SizeAndLatency 
) const

Estimate the cost of a GEP operation when lowered.

PointeeType is the source element type of the GEP. Ptr is the base pointer operand. Operands is the list of indices following the base pointer.

AccessType is a hint as to what type of memory might be accessed by users of the GEP. getGEPCost will use it to determine if the GEP can be folded into the addressing mode of a load/store. If AccessType is null, then the resulting target type based off of PointeeType will be used as an approximation.

Definition at line 251 of file TargetTransformInfo.cpp.

References CostKind, Operands, and Ptr.

Referenced by getGEPCosts(), and isGEPFoldable().

◆ getGISelRematGlobalCost()

unsigned TargetTransformInfo::getGISelRematGlobalCost ( ) const
Returns
the size cost of rematerializing a GlobalValue address relative to a stack reload.

Definition at line 1458 of file TargetTransformInfo.cpp.

Referenced by llvm::TargetLoweringBase::shouldLocalize().

◆ getIndexedVectorInstrCostFromEnd()

InstructionCost TargetTransformInfo::getIndexedVectorInstrCostFromEnd ( unsigned  Opcode,
Type Val,
TTI::TargetCostKind  CostKind,
unsigned  Index 
) const
Returns
The expected cost of inserting or extracting a lane that is Index elements from the end of a vector, i.e. the mathematical expression for the lane is (VF - 1 - Index). This is required for scalable vectors where the exact lane index is unknown at compile time.

Definition at line 1132 of file TargetTransformInfo.cpp.

References assert(), and CostKind.

Referenced by llvm::VPInstruction::computeCost().

◆ getInlineCallPenalty()

unsigned TargetTransformInfo::getInlineCallPenalty ( const Function F,
const CallBase Call,
unsigned  DefaultCallPenalty 
) const

Returns a penalty for invoking call Call in F.

For example, if a function F calls a function G, which in turn calls function H, then getInlineCallPenalty(F, H()) would return the penalty of calling H from F, e.g. after inlining G into F. DefaultCallPenalty is passed to give a default penalty that the target can amend or override.

Definition at line 1337 of file TargetTransformInfo.cpp.

References F.

Referenced by llvm::getCallsiteCost().

◆ getInlinerVectorBonusPercent()

int TargetTransformInfo::getInlinerVectorBonusPercent ( ) const
Returns
Vector bonus in percent.

Vector bonuses: We want to more aggressively inline vector-dense kernels and apply this bonus based on the percentage of vector instructions. A bonus is applied if the vector instructions exceed 50% and half that amount is applied if it exceeds 10%. Note that these bonuses are some what arbitrary and evolved over time by accident as much as because they are principled bonuses. FIXME: It would be nice to base the bonus values on something more scientific. A target may has no bonus on vector instructions.

Definition at line 247 of file TargetTransformInfo.cpp.

◆ getInliningCostBenefitAnalysisProfitableMultiplier()

unsigned TargetTransformInfo::getInliningCostBenefitAnalysisProfitableMultiplier ( ) const

Definition at line 228 of file TargetTransformInfo.cpp.

◆ getInliningCostBenefitAnalysisSavingsMultiplier()

unsigned TargetTransformInfo::getInliningCostBenefitAnalysisSavingsMultiplier ( ) const

Definition at line 223 of file TargetTransformInfo.cpp.

◆ getInliningLastCallToStaticBonus()

int TargetTransformInfo::getInliningLastCallToStaticBonus ( ) const
Returns
The bonus of inlining the last call to a static function.

Definition at line 233 of file TargetTransformInfo.cpp.

Referenced by shouldBeDeferred().

◆ getInliningThresholdMultiplier()

unsigned TargetTransformInfo::getInliningThresholdMultiplier ( ) const
Returns
A value by which our inlining threshold should be multiplied. This is primarily used to bump up the inlining threshold wholesale on targets where calls are unusually expensive.

TODO: This is a rather blunt instrument. Perhaps altering the costs of individual classes of instructions would be better.

Definition at line 218 of file TargetTransformInfo.cpp.

◆ getInsertExtractValueCost()

InstructionCost TargetTransformInfo::getInsertExtractValueCost ( unsigned  Opcode,
TTI::TargetCostKind  CostKind 
) const
Returns
The expected cost of aggregate inserts and extracts. This is used when the instruction is not available; a typical use case is to provision the cost of vectorization/scalarization in vectorizer passes.

Definition at line 1141 of file TargetTransformInfo.cpp.

References assert(), and CostKind.

Referenced by llvm::VPRecipeWithIRFlags::getCostForRecipeWithOpcode().

◆ getInstructionCost() [1/2]

InstructionCost TargetTransformInfo::getInstructionCost ( const User U,
ArrayRef< const Value * >  Operands,
TargetCostKind  CostKind 
) const

Estimate the cost of a given IR user when lowered.

This can estimate the cost of either a ConstantExpr or Instruction when lowered.

Operands is a list of operands which can be a result of transformations of the current operands. The number of the operands on the list must equal to the number of the current operands the IR user has. Their order on the list must be the same as the order of the current operands the IR user has.

The returned cost is defined in terms of TargetCostConstants, see its comments for a detailed explanation of the cost values.

Definition at line 273 of file TargetTransformInfo.cpp.

References assert(), CostKind, Operands, and TCK_RecipThroughput.

Referenced by llvm::CodeMetrics::analyzeBasicBlock(), analyzeLoopUnrollCost(), canConvertToFMA(), canSplitCallSite(), llvm::slpvectorizer::BoUpSLP::canVectorizeLoads(), checkOuterLoopInsts(), llvm::ComputeSpeculationCost(), computeSpeculationCost(), findBestNonTrivialUnswitchCandidate(), llvm::foldBranchToCommonDest(), llvm::OutlinableRegion::getBenefit(), getCost(), getInstructionCost(), llvm::LoopVectorizationCostModel::getInstructionCost(), getJumpThreadDuplicationCost(), llvm::InstCostVisitor::getLatencySavingsForKnownConstants(), getOutliningBenefit(), llvm::slpvectorizer::BoUpSLP::getTreeCost(), isFoldableInLoop(), isHoistableInstruction(), isLoopSizeWithinBudget(), isMaskedLoadCompress(), mergeConditionalStoreToAddress(), and llvm::SelectionDAGBuilder::shouldKeepJumpConditionsTogether().

◆ getInstructionCost() [2/2]

InstructionCost llvm::TargetTransformInfo::getInstructionCost ( const User U,
TargetCostKind  CostKind 
) const
inline

This is a helper function which calls the three-argument getInstructionCost with Operands which are the current operands U has.

Definition at line 426 of file TargetTransformInfo.h.

References CostKind, getInstructionCost(), and Operands.

◆ getInterleavedMemoryOpCost()

InstructionCost TargetTransformInfo::getInterleavedMemoryOpCost ( unsigned  Opcode,
Type VecTy,
unsigned  Factor,
ArrayRef< unsigned Indices,
Align  Alignment,
unsigned  AddressSpace,
TTI::TargetCostKind  CostKind = TTI::TCK_RecipThroughput,
bool  UseMaskForCond = false,
bool  UseMaskForGaps = false 
) const
Returns
The cost of the interleaved memory operation. Opcode is the memory operation code VecTy is the vector type of the interleaved access. Factor is the interleave factor Indices is the indices for interleaved load members (as interleaved load allows gaps) Alignment is the alignment of the memory operation AddressSpace is address space of the pointer. UseMaskForCond indicates if the memory access is predicated. UseMaskForGaps indicates if gaps should be masked.

Definition at line 1209 of file TargetTransformInfo.cpp.

References assert(), and CostKind.

Referenced by llvm::VPInterleaveBase::computeCost(), and isMaskedLoadCompress().

◆ getIntImmCodeSizeCost()

InstructionCost TargetTransformInfo::getIntImmCodeSizeCost ( unsigned  Opc,
unsigned  Idx,
const APInt Imm,
Type Ty 
) const

Return the expected cost for the given integer when optimising for size.

This is different than the other integer immediate cost functions in that it is subtarget agnostic. This is useful when you e.g. target one ISA such as Aarch32 but smaller encodings could be possible with another such as Thumb. This return value is used as a penalty when the total costs for a constant is calculated (the bigger the cost, the more beneficial constant hoisting is).

Definition at line 721 of file TargetTransformInfo.cpp.

References assert(), and Idx.

◆ getIntImmCost()

InstructionCost TargetTransformInfo::getIntImmCost ( const APInt Imm,
Type Ty,
TTI::TargetCostKind  CostKind 
) const

Return the expected cost of materializing for the given integer immediate of the specified type.

Definition at line 731 of file TargetTransformInfo.cpp.

References assert(), and CostKind.

Referenced by tryUnmergingGEPsAcrossIndirectBr().

◆ getIntImmCostInst()

InstructionCost TargetTransformInfo::getIntImmCostInst ( unsigned  Opc,
unsigned  Idx,
const APInt Imm,
Type Ty,
TTI::TargetCostKind  CostKind,
Instruction Inst = nullptr 
) const

Return the expected cost of materialization for the given integer immediate of the specified type for a given instruction.

The cost can be zero if the immediate can be folded into the specified instruction.

Definition at line 738 of file TargetTransformInfo.cpp.

References assert(), CostKind, and Idx.

◆ getIntImmCostIntrin()

InstructionCost TargetTransformInfo::getIntImmCostIntrin ( Intrinsic::ID  IID,
unsigned  Idx,
const APInt Imm,
Type Ty,
TTI::TargetCostKind  CostKind 
) const

Definition at line 748 of file TargetTransformInfo.cpp.

References assert(), CostKind, and Idx.

◆ getIntrinsicInstrCost()

InstructionCost TargetTransformInfo::getIntrinsicInstrCost ( const IntrinsicCostAttributes ICA,
TTI::TargetCostKind  CostKind 
) const
Returns
The cost of Intrinsic instructions. Analyses the real arguments. Three cases are handled: 1. scalar instruction 2. vector instruction
  1. scalar instruction which is to be vectorized.

Definition at line 1221 of file TargetTransformInfo.cpp.

References assert(), and CostKind.

Referenced by canConvertToFMA(), llvm::VPInstruction::computeCost(), llvm::VPHistogramRecipe::computeCost(), getCost(), getCostForIntrinsics(), llvm::LoopVectorizationCostModel::getInstructionCost(), llvm::slpvectorizer::BoUpSLP::getSpillCost(), getVectorCallCosts(), llvm::LoopVectorizationCostModel::getVectorIntrinsicCost(), simplifySwitchOfPowersOfTwo(), and tryToFPToSat().

◆ getLoadStoreVecRegBitWidth()

unsigned TargetTransformInfo::getLoadStoreVecRegBitWidth ( unsigned  AddrSpace) const
Returns
The bitwidth of the largest vector type that should be used to load/store in the given address space.

Definition at line 1359 of file TargetTransformInfo.cpp.

◆ getLoadVectorFactor()

unsigned TargetTransformInfo::getLoadVectorFactor ( unsigned  VF,
unsigned  LoadSize,
unsigned  ChainSizeInBytes,
VectorType VecTy 
) const
Returns
The new vector factor value if the target doesn't support SizeInBytes loads or has a better vector factor.

Definition at line 1392 of file TargetTransformInfo.cpp.

◆ getMaskedMemoryOpCost()

InstructionCost TargetTransformInfo::getMaskedMemoryOpCost ( unsigned  Opcode,
Type Src,
Align  Alignment,
unsigned  AddressSpace,
TTI::TargetCostKind  CostKind = TTI::TCK_RecipThroughput 
) const

◆ getMaximumVF()

unsigned TargetTransformInfo::getMaximumVF ( unsigned  ElemWidth,
unsigned  Opcode 
) const
Returns
The maximum vectorization factor for types of given element bit width and opcode, or 0 if there is no maximum VF. Currently only used by the SLP vectorizer.

Definition at line 811 of file TargetTransformInfo.cpp.

Referenced by llvm::slpvectorizer::BoUpSLP::getMaximumVF().

◆ getMaxInterleaveFactor()

unsigned TargetTransformInfo::getMaxInterleaveFactor ( ElementCount  VF) const
Returns
The maximum interleave factor that any transform should try to perform for this target. This number depends on the level of parallelism and the number of execution units in the CPU.

Definition at line 880 of file TargetTransformInfo.cpp.

Referenced by llvm::LoopVectorizationCostModel::isEpilogueVectorizationProfitable(), llvm::LoopVectorizePass::runImpl(), and llvm::LoopVectorizationPlanner::selectInterleaveCount().

◆ getMaxMemIntrinsicInlineSizeThreshold()

uint64_t TargetTransformInfo::getMaxMemIntrinsicInlineSizeThreshold ( ) const

Returns the maximum memset / memcpy size in bytes that still makes it profitable to inline the call.

Definition at line 1256 of file TargetTransformInfo.cpp.

◆ getMaxNumArgs()

unsigned TargetTransformInfo::getMaxNumArgs ( ) const
Returns
The maximum number of function arguments the target supports.

Definition at line 1444 of file TargetTransformInfo.cpp.

Referenced by promoteArguments().

◆ getMaxPrefetchIterationsAhead()

unsigned TargetTransformInfo::getMaxPrefetchIterationsAhead ( ) const
Returns
The maximum number of iterations to prefetch ahead. If the required number of iterations is more than this number, no prefetching is performed.

Definition at line 858 of file TargetTransformInfo.cpp.

◆ getMaxVScale()

std::optional< unsigned > TargetTransformInfo::getMaxVScale ( ) const
Returns
The maximum value of vscale if the target specifies an architectural maximum vector length, and std::nullopt otherwise.

Definition at line 789 of file TargetTransformInfo.cpp.

Referenced by getMaxVScale().

◆ getMemcpyCost()

InstructionCost TargetTransformInfo::getMemcpyCost ( const Instruction I) const
Returns
the expected cost of a memcpy, which could e.g. depend on the source/destination type and alignment and the number of bytes copied.

Definition at line 1250 of file TargetTransformInfo.cpp.

References assert(), and I.

◆ getMemcpyLoopLoweringType()

Type * TargetTransformInfo::getMemcpyLoopLoweringType ( LLVMContext Context,
Value Length,
unsigned  SrcAddrSpace,
unsigned  DestAddrSpace,
Align  SrcAlign,
Align  DestAlign,
std::optional< uint32_t AtomicElementSize = std::nullopt 
) const
Returns
The type to use in a loop expansion of a memcpy call.

Definition at line 1312 of file TargetTransformInfo.cpp.

References Context, and llvm::Length.

Referenced by llvm::createMemCpyLoopKnownSize(), createMemMoveLoopKnownSize(), and createMemMoveLoopUnknownSize().

◆ getMemcpyLoopResidualLoweringType()

void TargetTransformInfo::getMemcpyLoopResidualLoweringType ( SmallVectorImpl< Type * > &  OpsOut,
LLVMContext Context,
unsigned  RemainingBytes,
unsigned  SrcAddrSpace,
unsigned  DestAddrSpace,
Align  SrcAlign,
Align  DestAlign,
std::optional< uint32_t AtomicCpySize = std::nullopt 
) const
Parameters
[out]OpsOutThe operand types to copy RemainingBytes of memory.
RemainingBytesThe number of bytes to copy.

Calculates the operand types to use when copying RemainingBytes of memory, where source and destination alignments are SrcAlign and DestAlign respectively.

Definition at line 1321 of file TargetTransformInfo.cpp.

References Context.

Referenced by llvm::createMemCpyLoopKnownSize(), and createMemMoveLoopKnownSize().

◆ getMemoryOpCost()

InstructionCost TargetTransformInfo::getMemoryOpCost ( unsigned  Opcode,
Type Src,
Align  Alignment,
unsigned  AddressSpace,
TTI::TargetCostKind  CostKind = TTI::TCK_RecipThroughput,
TTI::OperandValueInfo  OpInfo = {OK_AnyValueOP_None},
const Instruction I = nullptr 
) const
Returns
The cost of Load and Store instructions.

Definition at line 1160 of file TargetTransformInfo.cpp.

References assert(), CostKind, and I.

Referenced by llvm::slpvectorizer::BoUpSLP::canVectorizeLoads(), llvm::VPWidenMemoryRecipe::computeCost(), findCostForOutputBlocks(), and isMaskedLoadCompress().

◆ getMinimumVF()

ElementCount TargetTransformInfo::getMinimumVF ( unsigned  ElemWidth,
bool  IsScalable 
) const
Returns
The minimum vectorization factor for types of given element bit width, or 0 if there is no minimum VF. The returned value only applies when shouldMaximizeVectorBandwidth returns true. If IsScalable is true, the returned ElementCount must be a scalable VF.

Definition at line 806 of file TargetTransformInfo.cpp.

◆ getMinMaxReductionCost()

InstructionCost TargetTransformInfo::getMinMaxReductionCost ( Intrinsic::ID  IID,
VectorType Ty,
FastMathFlags  FMF = FastMathFlags(),
TTI::TargetCostKind  CostKind = TTI::TCK_RecipThroughput 
) const

◆ getMinPageSize()

std::optional< unsigned > TargetTransformInfo::getMinPageSize ( ) const
Returns
The minimum architectural page size for the target.

Definition at line 842 of file TargetTransformInfo.cpp.

References MinPageSize.

◆ getMinPrefetchStride()

unsigned TargetTransformInfo::getMinPrefetchStride ( unsigned  NumMemAccesses,
unsigned  NumStridedMemAccesses,
unsigned  NumPrefetches,
bool  HasCall 
) const

Some HW prefetchers can handle accesses up to a certain constant stride.

Sometimes prefetching is beneficial even below the HW prefetcher limit, and the arguments provided are meant to serve as a basis for deciding this for a particular loop.

Parameters
NumMemAccessesNumber of memory accesses in the loop.
NumStridedMemAccessesNumber of the memory accesses that ScalarEvolution could find a known stride for.
NumPrefetchesNumber of software prefetches that will be emitted as determined by the addresses involved and the cache line size.
HasCallTrue if the loop contains a call.
Returns
This is the minimum stride in bytes where it makes sense to start adding SW prefetches. The default is 1, i.e. prefetch with any stride.

Definition at line 851 of file TargetTransformInfo.cpp.

◆ getMinTripCountTailFoldingThreshold()

unsigned TargetTransformInfo::getMinTripCountTailFoldingThreshold ( ) const
Returns
the lower bound of a trip count to decide on vectorization while tail-folding.

Definition at line 1462 of file TargetTransformInfo.cpp.

Referenced by llvm::LoopVectorizationCostModel::computeMaxVF().

◆ getMinVectorRegisterBitWidth()

unsigned TargetTransformInfo::getMinVectorRegisterBitWidth ( ) const
Returns
The width of the smallest vector register type.

Definition at line 785 of file TargetTransformInfo.cpp.

Referenced by llvm::slpvectorizer::BoUpSLP::BoUpSLP(), and canWidenLoad().

◆ getMulAccReductionCost()

InstructionCost TargetTransformInfo::getMulAccReductionCost ( bool  IsUnsigned,
unsigned  RedOpcode,
Type ResTy,
VectorType Ty,
TTI::TargetCostKind  CostKind = TTI::TCK_RecipThroughput 
) const

Calculate the cost of an extended reduction pattern, similar to getArithmeticReductionCost of an Add/Sub reduction with multiply and optional extensions.

This is the cost of as:

  • ResTy vecreduce.add/sub(mul (A, B)) or,
  • ResTy vecreduce.add/sub(mul(ext(Ty A), ext(Ty B)).

Definition at line 1285 of file TargetTransformInfo.cpp.

References CostKind.

Referenced by analyzeCostOfVecReduction(), llvm::VPExpressionRecipe::computeCost(), llvm::LoopVectorizationCostModel::getReductionPatternCost(), and tryToMatchAndCreateMulAccumulateReduction().

◆ getNumberOfParts()

unsigned TargetTransformInfo::getNumberOfParts ( Type Tp) const
Returns
The number of pieces into which the provided type must be split during legalization. Zero is returned when the answer is unknown.

Definition at line 1237 of file TargetTransformInfo.cpp.

Referenced by getFloorFullVectorNumberOfElements(), getFullVectorNumberOfElements(), llvm::LoopVectorizationCostModel::getInstructionCost(), llvm::getNumberOfParts(), llvm::hasFullVectorsOrPowerOf2(), and willGenerateVectors().

◆ getNumberOfRegisters()

unsigned TargetTransformInfo::getNumberOfRegisters ( unsigned  ClassID) const

◆ getNumBytesToPadGlobalArray()

unsigned TargetTransformInfo::getNumBytesToPadGlobalArray ( unsigned  Size,
Type ArrayType 
) const
Returns
For an array of given Size, return alignment boundary to pad to. Default is no padding.

Definition at line 1488 of file TargetTransformInfo.cpp.

References Size.

◆ getOperandInfo()

TargetTransformInfo::OperandValueInfo TargetTransformInfo::getOperandInfo ( const Value V)
static

◆ getOperandsScalarizationOverhead()

InstructionCost TargetTransformInfo::getOperandsScalarizationOverhead ( ArrayRef< Type * >  Tys,
TTI::TargetCostKind  CostKind 
) const

Estimate the overhead of scalarizing operands with the given types.

The (potentially vector) types to use for each of argument are passes via Tys.

Definition at line 639 of file TargetTransformInfo.cpp.

References CostKind.

Referenced by llvm::VPReplicateRecipe::computeCost().

◆ getOrCreateResultFromMemIntrinsic()

Value * TargetTransformInfo::getOrCreateResultFromMemIntrinsic ( IntrinsicInst Inst,
Type ExpectedType,
bool  CanCreate = true 
) const
Returns
A value which is the result of the given memory intrinsic. If CanCreate is true, new instructions may be created to extract the result from the given intrinsic memory operation. Returns nullptr if the target cannot create a result from the given intrinsic.

Definition at line 1306 of file TargetTransformInfo.cpp.

◆ getPartialReductionCost()

InstructionCost TargetTransformInfo::getPartialReductionCost ( unsigned  Opcode,
Type InputTypeA,
Type InputTypeB,
Type AccumType,
ElementCount  VF,
PartialReductionExtendKind  OpAExtend,
PartialReductionExtendKind  OpBExtend,
std::optional< unsigned BinOp,
TTI::TargetCostKind  CostKind 
) const
Returns
The cost of a partial reduction, which is a reduction from a vector to another vector with fewer elements of larger size. They are represented by the llvm.experimental.partial.reduce.add intrinsic, which takes an accumulator of type AccumType and a second vector operand to be accumulated, whose element count is specified by VF. The type of reduction is specified by Opcode. The second operand passed to the intrinsic could be the result of an extend, such as sext or zext. In this case BinOp is nullopt, InputTypeA represents the type being extended and OpAExtend the operation, i.e. sign- or zero-extend. Also, InputTypeB should be nullptr and OpBExtend should be None. Alternatively, the second operand could be the result of a binary operation performed on two extends, i.e. mul(zext i8 a -> i32, zext i8 b -> i32). In this case BinOp may specify the opcode of the binary operation, InputTypeA and InputTypeB the types being extended, and OpAExtend, OpBExtend the form of extensions. An example of an operation that uses a partial reduction is a dot product, which reduces two vectors in binary mul operation to another of 4 times fewer and 4 times larger elements.

Definition at line 870 of file TargetTransformInfo.cpp.

References CostKind.

Referenced by llvm::VPPartialReductionRecipe::computeCost().

◆ getPartialReductionExtendKind()

TargetTransformInfo::PartialReductionExtendKind TargetTransformInfo::getPartialReductionExtendKind ( Instruction I)
static

Get the kind of extension that an instruction represents.

Definition at line 1002 of file TargetTransformInfo.cpp.

References I, PR_None, PR_SignExtend, and PR_ZeroExtend.

◆ getPeelingPreferences()

void TargetTransformInfo::getPeelingPreferences ( Loop L,
ScalarEvolution SE,
PeelingPreferences PP 
) const

Get target-customized preferences for the generic loop peeling transformation.

The caller will initialize PP with the current target-independent defaults with information from L and SE.

Definition at line 408 of file TargetTransformInfo.cpp.

Referenced by llvm::gatherPeelingPreferences().

◆ getPointersChainCost()

InstructionCost TargetTransformInfo::getPointersChainCost ( ArrayRef< const Value * >  Ptrs,
const Value Base,
const PointersChainInfo Info,
Type AccessTy,
TTI::TargetCostKind  CostKind = TTI::TCK_RecipThroughput 
) const

Estimate the cost of a chain of pointers (typically pointer operands of a chain of loads or stores within same block) operations set when lowered.

AccessTy is the type of the loads/stores that will ultimately use the Ptrs.

Definition at line 257 of file TargetTransformInfo.cpp.

References assert(), llvm::sampleprof::Base, CostKind, and Info.

Referenced by getGEPCosts().

◆ getPopcntSupport()

TargetTransformInfo::PopcntSupportKind TargetTransformInfo::getPopcntSupport ( unsigned  IntTyWidthInBit) const

Return hardware support for population count.

Definition at line 698 of file TargetTransformInfo.cpp.

◆ getPredicatedAddrSpace()

std::pair< const Value *, unsigned > TargetTransformInfo::getPredicatedAddrSpace ( const Value V) const

Definition at line 346 of file TargetTransformInfo.cpp.

Referenced by findAffectedValues().

◆ getPredictableBranchThreshold()

BranchProbability TargetTransformInfo::getPredictableBranchThreshold ( ) const

If a branch or a select condition is skewed in one direction by more than this factor, it is very likely to be predicted correctly.

Definition at line 282 of file TargetTransformInfo.cpp.

References PredictableBranchThreshold.

Referenced by foldTwoEntryPHINode(), isFormingBranchFromSelectProfitable(), isProfitableToSpeculate(), shouldFoldCondBranchesToCommonDestination(), and SimplifyCondBranchToCondBranch().

◆ getPreferredAddressingMode()

TTI::AddressingModeKind TargetTransformInfo::getPreferredAddressingMode ( const Loop L,
ScalarEvolution SE 
) const

Return the preferred addressing mode LSR should make efforts to generate.

Definition at line 464 of file TargetTransformInfo.cpp.

◆ getPreferredExpandedReductionShuffle()

TargetTransformInfo::ReductionShuffle TargetTransformInfo::getPreferredExpandedReductionShuffle ( const IntrinsicInst II) const
Returns
The shuffle sequence pattern used to expand the given reduction intrinsic.

Definition at line 1453 of file TargetTransformInfo.cpp.

References II.

◆ getPreferredTailFoldingStyle()

TailFoldingStyle TargetTransformInfo::getPreferredTailFoldingStyle ( bool  IVUpdateMayOverflow = true) const

Query the target what the preferred style of tail folding is.

Parameters
IVUpdateMayOverflowTells whether it is known if the IV update may (or will never) overflow for the suggested VF/UF in the given loop. Targets can use this information to select a more optimal tail folding style. The value conservatively defaults to true, such that no assumptions are made on overflow.

Definition at line 374 of file TargetTransformInfo.cpp.

Referenced by llvm::LoopVectorizationCostModel::setTailFoldingStyles().

◆ getPrefetchDistance()

unsigned TargetTransformInfo::getPrefetchDistance ( ) const
Returns
How much before a load we should place the prefetch instruction. This is currently measured in number of instructions.

Definition at line 847 of file TargetTransformInfo.cpp.

◆ getRegisterBitWidth()

TypeSize TargetTransformInfo::getRegisterBitWidth ( TargetTransformInfo::RegisterKind  K) const

◆ getRegisterClassForType()

unsigned TargetTransformInfo::getRegisterClassForType ( bool  Vector,
Type Ty = nullptr 
) const
Returns
the target-provided register class ID for the provided type, accounting for type promotion and other type-legalization techniques that the target might apply. However, it specifically does not account for the scalarization or splitting of vector types. Should a vector type require scalarization or splitting into multiple underlying vector registers, that type should be mapped to a register class containing no registers. Specifically, this is designed to provide a simple, high-level view of the register allocation later performed by the backend. These register classes don't necessarily map onto the register classes used by the backend. FIXME: It's not currently possible to determine how many registers are used by the provided type.

Definition at line 771 of file TargetTransformInfo.cpp.

References llvm::Vector.

Referenced by llvm::calculateRegisterUsageForPlan(), llvm::LoopVectorizePass::runImpl(), and llvm::SLPVectorizerPass::runImpl().

◆ getRegisterClassName()

const char * TargetTransformInfo::getRegisterClassName ( unsigned  ClassID) const
Returns
the target-provided register class name

Definition at line 776 of file TargetTransformInfo.cpp.

Referenced by llvm::calculateRegisterUsageForPlan(), and llvm::LoopVectorizationPlanner::selectInterleaveCount().

◆ getRegUsageForType()

unsigned TargetTransformInfo::getRegUsageForType ( Type Ty) const

Returns the estimated number of registers required to represent Ty.

Definition at line 590 of file TargetTransformInfo.cpp.

Referenced by llvm::calculateRegisterUsageForPlan().

◆ getReplicationShuffleCost()

InstructionCost TargetTransformInfo::getReplicationShuffleCost ( Type EltTy,
int  ReplicationFactor,
int  VF,
const APInt DemandedDstElts,
TTI::TargetCostKind  CostKind 
) const
Returns
The cost of replication shuffle of VF elements typed EltTy ReplicationFactor times.

For example, the mask for ReplicationFactor=3 and VF=4 is: <0,0,0,1,1,1,2,2,2,3,3,3>

Definition at line 1151 of file TargetTransformInfo.cpp.

References assert(), and CostKind.

◆ getScalarizationOverhead()

InstructionCost TargetTransformInfo::getScalarizationOverhead ( VectorType Ty,
const APInt DemandedElts,
bool  Insert,
bool  Extract,
TTI::TargetCostKind  CostKind,
bool  ForPoisonSrc = true,
ArrayRef< Value * >  VL = {} 
) const

Estimate the overhead of scalarizing an instruction.

Insert and Extract are set if the demanded result elements need to be inserted and/or extracted from vectors. The involved values may be passed in VL if Insert is true.

Definition at line 631 of file TargetTransformInfo.cpp.

References CostKind.

Referenced by llvm::VPReplicateRecipe::computeCost(), llvm::LoopVectorizationCostModel::getInstructionCost(), llvm::slpvectorizer::BoUpSLP::getTreeCost(), and llvm::slpvectorizer::BoUpSLP::isTreeTinyAndNotFullyVectorizable().

◆ getScalingFactorCost()

InstructionCost TargetTransformInfo::getScalingFactorCost ( Type Ty,
GlobalValue BaseGV,
StackOffset  BaseOffset,
bool  HasBaseReg,
int64_t  Scale,
unsigned  AddrSpace = 0 
) const

Return the cost of the scaling factor used in the addressing mode represented by AM for this target, for a load/store of the specified type.

If the AM is supported, the return value must be >= 0. If the AM is not supported, it returns a negative value. TODO: Handle pre/postinc as well.

Definition at line 563 of file TargetTransformInfo.cpp.

References assert().

Referenced by getScalingFactorCost().

◆ getShuffleCost()

InstructionCost TargetTransformInfo::getShuffleCost ( ShuffleKind  Kind,
VectorType DstTy,
VectorType SrcTy,
ArrayRef< int >  Mask = {},
TTI::TargetCostKind  CostKind = TTI::TCK_RecipThroughput,
int  Index = 0,
VectorType SubTp = nullptr,
ArrayRef< const Value * >  Args = {},
const Instruction CxtI = nullptr 
) const
Returns
The cost of a shuffle instruction of kind Kind with inputs of type SrcTy, producing a vector of type DstTy. The exact mask may be passed as Mask, or else the array will be empty. The Index and SubTp parameters are used by the subvector insertions shuffle kinds to show the insert point and the type of the subvector being inserted. The operands of the shuffle can be passed through Args, which helps improve the cost estimation in some cases, like in broadcast loads.

Definition at line 986 of file TargetTransformInfo.cpp.

References assert(), CostKind, llvm::VectorType::getElementCount(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getKnownMinValue(), llvm::Type::getScalarType(), and llvm::Type::isScalableTy().

Referenced by llvm::VPInstruction::computeCost(), llvm::VPInterleaveBase::computeCost(), llvm::VPWidenMemoryRecipe::computeCost(), llvm::VPWidenLoadEVLRecipe::computeCost(), llvm::VPWidenStoreEVLRecipe::computeCost(), costShuffleViaSplitting(), costShuffleViaVRegSplitting(), llvm::LoopVectorizationCostModel::getInstructionCost(), and isFreeConcat().

◆ getStoreMinimumVF()

unsigned TargetTransformInfo::getStoreMinimumVF ( unsigned  VF,
Type ScalarMemTy,
Type ScalarValTy 
) const
Returns
The minimum vectorization factor for the store instruction. Given the initial estimation of the minimum vector factor and store value type, it tries to find possible lowest VF, which still might be profitable for the vectorization.
Parameters
VFInitial estimation of the minimum vector factor.
ScalarMemTyScalar memory type of the store operation.
ScalarValTyScalar type of the stored value. Currently only used by the SLP vectorizer.

Definition at line 816 of file TargetTransformInfo.cpp.

◆ getStoreVectorFactor()

unsigned TargetTransformInfo::getStoreVectorFactor ( unsigned  VF,
unsigned  StoreSize,
unsigned  ChainSizeInBytes,
VectorType VecTy 
) const
Returns
The new vector factor value if the target doesn't support SizeInBytes stores or has a better vector factor.

Definition at line 1399 of file TargetTransformInfo.cpp.

◆ getStridedMemoryOpCost()

InstructionCost TargetTransformInfo::getStridedMemoryOpCost ( unsigned  Opcode,
Type DataTy,
const Value Ptr,
bool  VariableMask,
Align  Alignment,
TTI::TargetCostKind  CostKind = TTI::TCK_RecipThroughput,
const Instruction I = nullptr 
) const
Returns
The cost of strided memory operations. Opcode - is a type of memory access Load or Store DataTy - a vector type of the data to be loaded or stored Ptr - pointer [or vector of pointers] - address[es] in memory VariableMask - true when the memory access is predicated with a mask that is not a compile-time constant Alignment - alignment of single element I - the optional original context instruction, if one exists, e.g. the load/store to transform or the call to the gather/scatter intrinsic

Definition at line 1200 of file TargetTransformInfo.cpp.

References assert(), CostKind, I, and Ptr.

Referenced by llvm::slpvectorizer::BoUpSLP::canVectorizeLoads().

◆ getTgtMemIntrinsic()

bool TargetTransformInfo::getTgtMemIntrinsic ( IntrinsicInst Inst,
MemIntrinsicInfo Info 
) const
Returns
True if the intrinsic is a supported memory intrinsic. Info will contain additional information - whether the intrinsic may write or read to memory, volatility and the pointer. Info is undefined if false is returned.

Definition at line 1297 of file TargetTransformInfo.cpp.

References Info.

Referenced by getAccessType(), and isAddressUse().

◆ getUnrollingPreferences()

void TargetTransformInfo::getUnrollingPreferences ( Loop L,
ScalarEvolution SE,
UnrollingPreferences UP,
OptimizationRemarkEmitter ORE 
) const

Get target-customized preferences for the generic loop unrolling transformation.

The caller will initialize UP with the current target-independent defaults.

Definition at line 402 of file TargetTransformInfo.cpp.

Referenced by llvm::LoopVectorizationPlanner::executePlan(), and llvm::gatherUnrollingPreferences().

◆ getVectorInstrCost() [1/3]

InstructionCost TargetTransformInfo::getVectorInstrCost ( const Instruction I,
Type Val,
TTI::TargetCostKind  CostKind,
unsigned  Index = -1 
) const
Returns
The expected cost of vector Insert and Extract. This is used when instruction is available, and implementation asserts 'I' is not nullptr.

A typical suitable use case is cost estimation when vector instruction exists (e.g., from basic blocks during transformation).

Definition at line 1121 of file TargetTransformInfo.cpp.

References assert(), CostKind, and I.

◆ getVectorInstrCost() [2/3]

InstructionCost TargetTransformInfo::getVectorInstrCost ( unsigned  Opcode,
Type Val,
TTI::TargetCostKind  CostKind,
unsigned  Index,
Value Scalar,
ArrayRef< std::tuple< Value *, User *, int > >  ScalarUserAndIdx 
) const
Returns
The expected cost of vector Insert and Extract. Use -1 to indicate that there is no information on the index value. This is used when the instruction is not available; a typical use case is to provision the cost of vectorization/scalarization in vectorizer passes.
Parameters
ScalarUserAndIdxencodes the information about extracts from a vector with 'Scalar' being the value being extracted,'User' being the user of the extract(nullptr if user is not known before vectorization) and 'Idx' being the extract lane.

Definition at line 1107 of file TargetTransformInfo.cpp.

References assert(), and CostKind.

◆ getVectorInstrCost() [3/3]

InstructionCost TargetTransformInfo::getVectorInstrCost ( unsigned  Opcode,
Type Val,
TTI::TargetCostKind  CostKind,
unsigned  Index = -1,
const Value Op0 = nullptr,
const Value Op1 = nullptr 
) const
Returns
The expected cost of vector Insert and Extract. Use -1 to indicate that there is no information on the index value. This is used when the instruction is not available; a typical use case is to provision the cost of vectorization/scalarization in vectorizer passes.

Definition at line 1095 of file TargetTransformInfo.cpp.

References assert(), and CostKind.

Referenced by llvm::VPInstruction::computeCost(), llvm::slpvectorizer::BoUpSLP::getReorderingData(), getVectorInstrCost(), and isMaskedLoadCompress().

◆ getVPLegalizationStrategy()

TargetTransformInfo::VPLegalization TargetTransformInfo::getVPLegalizationStrategy ( const VPIntrinsic PI) const
Returns
How the target needs this vector-predicated operation to be transformed.

Definition at line 1428 of file TargetTransformInfo.cpp.

◆ getVPMemoryOpCost()

LLVM_ABI InstructionCost llvm::TargetTransformInfo::getVPMemoryOpCost ( unsigned  Opcode,
Type Src,
Align  Alignment,
unsigned  AddressSpace,
TTI::TargetCostKind  CostKind = TTI::TCK_RecipThroughput,
const Instruction I = nullptr 
) const
Returns
The cost of VP Load and Store instructions.

◆ getVScaleForTuning()

std::optional< unsigned > TargetTransformInfo::getVScaleForTuning ( ) const
Returns
the value of vscale to tune the cost model for.

Definition at line 793 of file TargetTransformInfo.cpp.

◆ hasActiveVectorLength()

bool TargetTransformInfo::hasActiveVectorLength ( ) const

◆ hasArmWideBranch()

bool TargetTransformInfo::hasArmWideBranch ( bool  Thumb) const
Returns
Whether a 32-bit branch instruction is available in Arm or Thumb state.

Used by the LowerTypeTests pass, which constructs an IR inline assembler node containing a jump table in a format suitable for the target, so it needs to know what format of jump table it can legally use.

For non-Arm targets, this function isn't used. It defaults to returning false, but it shouldn't matter what it returns anyway.

Definition at line 1432 of file TargetTransformInfo.cpp.

◆ hasBranchDivergence()

bool TargetTransformInfo::hasBranchDivergence ( const Function F = nullptr) const

Return true if branch divergence exists.

Branch divergence has a significantly negative impact on GPU performance when threads in the same wavefront take different paths due to conditional branches.

If F is passed, provides a context function. If F is known to only execute in a single threaded environment, the target may choose to skip uniformity analysis and assume all values are uniform.

Definition at line 292 of file TargetTransformInfo.cpp.

References F.

Referenced by llvm::LoopVectorizationCostModel::computeMaxVF(), llvm::UniformityInfoAnalysis::run(), llvm::JumpThreadingPass::run(), llvm::MachineUniformityAnalysis::run(), runImpl(), llvm::SpeculativeExecutionPass::runImpl(), and unswitchLoop().

◆ hasConditionalLoadStoreForType()

bool TargetTransformInfo::hasConditionalLoadStoreForType ( Type Ty,
bool  IsStore 
) const
Returns
true if the target supports load/store that enables fault suppression of memory operands when the source condition is false.

Definition at line 766 of file TargetTransformInfo.cpp.

Referenced by isSafeCheapLoadStore().

◆ hasDivRemOp()

bool TargetTransformInfo::hasDivRemOp ( Type DataType,
bool  IsSigned 
) const

Return true if the target has a unified operation to calculate division and remainder.

If so, the additional implicit multiplication and subtraction required to calculate a remainder from division are free. This can enable more aggressive transformations for division and remainder than would typically be allowed using throughput or size cost models.

Definition at line 550 of file TargetTransformInfo.cpp.

Referenced by optimizeDivRem().

◆ hasVolatileVariant()

bool TargetTransformInfo::hasVolatileVariant ( Instruction I,
unsigned  AddrSpace 
) const

Return true if the given instruction (assumed to be a memory access instruction) has a volatile variant.

If that's the case then we can avoid addrspacecast to generic AS for volatile loads/stores. Default implementation returns false, which prevents address space inference for volatile loads/stores.

Definition at line 554 of file TargetTransformInfo.cpp.

References I.

Referenced by replaceSimplePointerUse().

◆ haveFastSqrt()

bool TargetTransformInfo::haveFastSqrt ( Type Ty) const

Return true if the hardware has a fast square-root instruction.

Definition at line 702 of file TargetTransformInfo.cpp.

Referenced by foldSqrt(), and runPartiallyInlineLibCalls().

◆ instCombineIntrinsic()

std::optional< Instruction * > TargetTransformInfo::instCombineIntrinsic ( InstCombiner IC,
IntrinsicInst II 
) const

Targets can implement their own combinations for target-specific intrinsics.

This function will be called from the InstCombine pass every time a target-specific intrinsic is encountered.

Returns
std::nullopt to not do anything target specific or a value that will be returned from the InstCombiner. It is possible to return null and stop further processing of the intrinsic by returning nullptr.

Definition at line 380 of file TargetTransformInfo.cpp.

References II.

Referenced by llvm::InstCombiner::targetInstCombineIntrinsic().

◆ invalidate()

bool llvm::TargetTransformInfo::invalidate ( Function ,
const PreservedAnalyses ,
FunctionAnalysisManager::Invalidator  
)
inline

Handle the invalidation of this information.

When used as a result of TargetIRAnalysis this method will be called when the function this was computed for changes. When it returns false, the information is preserved across those changes.

Definition at line 255 of file TargetTransformInfo.h.

◆ isAlwaysUniform()

bool llvm::TargetTransformInfo::isAlwaysUniform ( const Value V) const

◆ isElementTypeLegalForScalableVector()

bool TargetTransformInfo::isElementTypeLegalForScalableVector ( Type Ty) const
Returns
True if the given type is supported for scalable vectors

Definition at line 1388 of file TargetTransformInfo.cpp.

◆ isExpensiveToSpeculativelyExecute()

bool TargetTransformInfo::isExpensiveToSpeculativelyExecute ( const Instruction I) const

Return true if the cost of the instruction is too high to speculatively execute and should be kept behind a branch.

This normally just wraps around a getInstructionCost() call, but some targets might report a low TCK_SizeAndLatency value that is incompatible with the fixed TCC_Expensive value. NOTE: This assumes the instruction passes isSafeToSpeculativelyExecute().

Definition at line 706 of file TargetTransformInfo.cpp.

References I.

Referenced by sinkSelectOperand().

◆ isFCmpOrdCheaperThanFCmpZero()

bool TargetTransformInfo::isFCmpOrdCheaperThanFCmpZero ( Type Ty) const

Return true if it is faster to check if a floating-point value is NaN (or not-NaN) versus a comparison against a constant FP zero value.

Targets should override this if materializing a 0.0 for comparison is generally as cheap as checking for ordered/unordered.

Definition at line 711 of file TargetTransformInfo.cpp.

Referenced by optimizeSQRT().

◆ isFPVectorizationPotentiallyUnsafe()

bool TargetTransformInfo::isFPVectorizationPotentiallyUnsafe ( ) const

Indicate that it is potentially unsafe to automatically vectorize floating-point operations because the semantics of vector and scalar floating-point semantics may differ.

For example, ARM NEON v7 SIMD math does not support IEEE-754 denormal numbers, while depending on the platform, scalar floating-point math does. This applies to floating-point math operations and calls, not memory operations, shuffles, or casts.

Definition at line 683 of file TargetTransformInfo.cpp.

Referenced by llvm::LoopVectorizePass::processLoop().

◆ isHardwareLoopProfitable()

bool TargetTransformInfo::isHardwareLoopProfitable ( Loop L,
ScalarEvolution SE,
AssumptionCache AC,
TargetLibraryInfo LibInfo,
HardwareLoopInfo HWLoopInfo 
) const

Query the target whether it would be profitable to convert the given loop into a hardware loop.

Definition at line 359 of file TargetTransformInfo.cpp.

◆ isIndexedLoadLegal()

bool TargetTransformInfo::isIndexedLoadLegal ( enum MemIndexedMode  Mode,
Type Ty 
) const
Returns
True if the specified indexed load for the given type is legal.

Definition at line 1349 of file TargetTransformInfo.cpp.

Referenced by canHoistIVInc(), and mayUsePostIncMode().

◆ isIndexedStoreLegal()

bool TargetTransformInfo::isIndexedStoreLegal ( enum MemIndexedMode  Mode,
Type Ty 
) const
Returns
True if the specified indexed store for the given type is legal.

Definition at line 1354 of file TargetTransformInfo.cpp.

Referenced by canHoistIVInc(), and mayUsePostIncMode().

◆ isLegalAddImmediate()

bool TargetTransformInfo::isLegalAddImmediate ( int64_t  Imm) const

Return true if the specified immediate is legal add immediate, that is the target has add instructions which can add a register with the immediate without having to materialize the immediate into a register.

Definition at line 413 of file TargetTransformInfo.cpp.

Referenced by isLegalAddImmediate().

◆ isLegalAddressingMode()

bool TargetTransformInfo::isLegalAddressingMode ( Type Ty,
GlobalValue BaseGV,
int64_t  BaseOffset,
bool  HasBaseReg,
int64_t  Scale,
unsigned  AddrSpace = 0,
Instruction I = nullptr,
int64_t  ScalableOffset = 0 
) const

Return true if the addressing mode represented by AM is legal for this target, for a load/store of the specified type.

The type may be VoidTy, in which case only return true if the addressing mode is legal for a load/store of any legal type. If target returns true in LSRWithInstrQueries(), I may be valid.

Parameters
ScalableOffsetrepresents a quantity of bytes multiplied by vscale, an invariant value known only at runtime. Most targets should not accept a scalable offset.

TODO: Handle pre/postinc as well.

Definition at line 425 of file TargetTransformInfo.cpp.

References I.

Referenced by isAddFoldable(), isAMCompletelyFolded(), and IsSimplerBaseSCEVForTarget().

◆ isLegalAddScalableImmediate()

bool TargetTransformInfo::isLegalAddScalableImmediate ( int64_t  Imm) const

Return true if adding the specified scalable immediate is legal, that is the target has add instructions which can add a register with the immediate (multiplied by vscale) without having to materialize the immediate into a register.

Definition at line 417 of file TargetTransformInfo.cpp.

Referenced by isLegalAddImmediate().

◆ isLegalAltInstr()

bool TargetTransformInfo::isLegalAltInstr ( VectorType VecTy,
unsigned  Opcode0,
unsigned  Opcode1,
const SmallBitVector OpcodeMask 
) const

Return true if this is an alternating opcode pattern that can be lowered to a single instruction on the target.

In X86 this is for the addsub instruction which corrsponds to a Shuffle + Fadd + FSub pattern in IR. This function expectes two opcodes: Opcode1 and Opcode2 being selected by OpcodeMask. The mask contains one bit per lane and is a 0 when Opcode0 is selected and 1 when Opcode1 is selected. VecTy is the vector type of the instruction to be generated.

Definition at line 498 of file TargetTransformInfo.cpp.

◆ isLegalBroadcastLoad()

bool TargetTransformInfo::isLegalBroadcastLoad ( Type ElementTy,
ElementCount  NumElements 
) const

\Returns true if the target supports broadcasting a load to a vector of type <NumElements x ElementTy>.

Definition at line 488 of file TargetTransformInfo.cpp.

◆ isLegalICmpImmediate()

bool TargetTransformInfo::isLegalICmpImmediate ( int64_t  Imm) const

Return true if the specified immediate is legal icmp immediate, that is the target has icmp instructions which can compare a register against the immediate without having to materialize the immediate into a register.

Definition at line 421 of file TargetTransformInfo.cpp.

Referenced by isAMCompletelyFolded().

◆ isLegalInterleavedAccessType()

bool TargetTransformInfo::isLegalInterleavedAccessType ( VectorType VTy,
unsigned  Factor,
Align  Alignment,
unsigned  AddrSpace 
) const

Return true is the target supports interleaved access for the given vector type VTy, interleave factor Factor, alignment Alignment and address space AddrSpace.

Definition at line 534 of file TargetTransformInfo.cpp.

Referenced by isMaskedLoadCompress().

◆ isLegalMaskedCompressStore()

bool TargetTransformInfo::isLegalMaskedCompressStore ( Type DataType,
Align  Alignment 
) const

Return true if the target supports masked compress store.

Definition at line 519 of file TargetTransformInfo.cpp.

Referenced by optimizeCallInst().

◆ isLegalMaskedExpandLoad()

bool TargetTransformInfo::isLegalMaskedExpandLoad ( Type DataType,
Align  Alignment 
) const

Return true if the target supports masked expand load.

Definition at line 524 of file TargetTransformInfo.cpp.

Referenced by optimizeCallInst().

◆ isLegalMaskedGather()

bool TargetTransformInfo::isLegalMaskedGather ( Type DataType,
Align  Alignment 
) const

◆ isLegalMaskedLoad()

bool TargetTransformInfo::isLegalMaskedLoad ( Type DataType,
Align  Alignment,
unsigned  AddressSpace 
) const

◆ isLegalMaskedScatter()

bool TargetTransformInfo::isLegalMaskedScatter ( Type DataType,
Align  Alignment 
) const

◆ isLegalMaskedStore()

bool TargetTransformInfo::isLegalMaskedStore ( Type DataType,
Align  Alignment,
unsigned  AddressSpace 
) const

◆ isLegalMaskedVectorHistogram()

bool TargetTransformInfo::isLegalMaskedVectorHistogram ( Type AddrType,
Type DataType 
) const

Definition at line 541 of file TargetTransformInfo.cpp.

Referenced by optimizeCallInst().

◆ isLegalNTLoad()

bool TargetTransformInfo::isLegalNTLoad ( Type DataType,
Align  Alignment 
) const

Return true if the target supports nontemporal load.

Definition at line 484 of file TargetTransformInfo.cpp.

◆ isLegalNTStore()

bool TargetTransformInfo::isLegalNTStore ( Type DataType,
Align  Alignment 
) const

Return true if the target supports nontemporal store.

Definition at line 479 of file TargetTransformInfo.cpp.

◆ isLegalStridedLoadStore()

bool TargetTransformInfo::isLegalStridedLoadStore ( Type DataType,
Align  Alignment 
) const

Return true if the target supports strided load.

Definition at line 529 of file TargetTransformInfo.cpp.

Referenced by llvm::slpvectorizer::BoUpSLP::canVectorizeLoads(), and isStridedLoad().

◆ isLegalToVectorizeLoad()

bool TargetTransformInfo::isLegalToVectorizeLoad ( LoadInst LI) const
Returns
True if the load instruction is legal to vectorize.

Definition at line 1363 of file TargetTransformInfo.cpp.

◆ isLegalToVectorizeLoadChain()

bool TargetTransformInfo::isLegalToVectorizeLoadChain ( unsigned  ChainSizeInBytes,
Align  Alignment,
unsigned  AddrSpace 
) const
Returns
True if it is legal to vectorize the given load chain.

Definition at line 1371 of file TargetTransformInfo.cpp.

◆ isLegalToVectorizeReduction()

bool TargetTransformInfo::isLegalToVectorizeReduction ( const RecurrenceDescriptor RdxDesc,
ElementCount  VF 
) const
Returns
True if it is legal to vectorize the given reduction kind.

Definition at line 1383 of file TargetTransformInfo.cpp.

◆ isLegalToVectorizeStore()

bool TargetTransformInfo::isLegalToVectorizeStore ( StoreInst SI) const
Returns
True if the store instruction is legal to vectorize.

Definition at line 1367 of file TargetTransformInfo.cpp.

◆ isLegalToVectorizeStoreChain()

bool TargetTransformInfo::isLegalToVectorizeStoreChain ( unsigned  ChainSizeInBytes,
Align  Alignment,
unsigned  AddrSpace 
) const
Returns
True if it is legal to vectorize the given store chain.

Definition at line 1377 of file TargetTransformInfo.cpp.

◆ isLoweredToCall()

bool TargetTransformInfo::isLoweredToCall ( const Function F) const

Test whether calls to a function lower to actual program function calls.

The idea is to test whether the program is likely to require a 'call' instruction or equivalent in order to call the given function.

FIXME: It's not clear that this is a good or useful query API. Client's should probably move to simpler cost metrics using the above. Alternatively, we could split the cost interface into distinct code-size and execution-speed costs. This would allow modelling the core of this query more accurately as a call is a single small instruction, but incurs significant execution cost.

Definition at line 355 of file TargetTransformInfo.cpp.

References F.

Referenced by llvm::CodeMetrics::analyzeBasicBlock(), analyzeLoopUnrollCost(), and runCGProfilePass().

◆ isLSRCostLess()

bool TargetTransformInfo::isLSRCostLess ( const TargetTransformInfo::LSRCost C1,
const TargetTransformInfo::LSRCost C2 
) const

Return true if LSR cost of C1 is lower than C2.

Definition at line 435 of file TargetTransformInfo.cpp.

◆ isMultiversionedFunction()

bool TargetTransformInfo::isMultiversionedFunction ( const Function F) const

Returns true if this is an instance of a function with multiple versions.

Definition at line 1440 of file TargetTransformInfo.cpp.

References F.

Referenced by collectVersions(), and OptimizeNonTrivialIFuncs().

◆ isNoopAddrSpaceCast()

bool TargetTransformInfo::isNoopAddrSpaceCast ( unsigned  FromAS,
unsigned  ToAS 
) const

Definition at line 327 of file TargetTransformInfo.cpp.

Referenced by isNoopPtrIntCastPair().

◆ isNumRegsMajorCostOfLSR()

bool TargetTransformInfo::isNumRegsMajorCostOfLSR ( ) const

Return true if LSR major cost is number of registers.

Targets which implement their own isLSRCostLess and unset number of registers as major cost should return false, otherwise return true.

Definition at line 440 of file TargetTransformInfo.cpp.

◆ isProfitableLSRChainElement()

bool TargetTransformInfo::isProfitableLSRChainElement ( Instruction I) const
Returns
true if LSR should not optimize a chain that includes I.

Definition at line 448 of file TargetTransformInfo.cpp.

References I.

Referenced by isProfitableChain().

◆ isProfitableToHoist()

bool TargetTransformInfo::isProfitableToHoist ( Instruction I) const

Return true if it is profitable to hoist instruction in the then/else to before if.

Definition at line 580 of file TargetTransformInfo.cpp.

References I.

Referenced by shouldHoistCommonInstructions().

◆ isProfitableToSinkOperands()

bool TargetTransformInfo::isProfitableToSinkOperands ( Instruction I,
SmallVectorImpl< Use * > &  Ops 
) const

Return true if sinking I's operands to the same basic block as I is profitable, e.g.

because the operands can be folded into a target instruction during instruction selection. After calling the function Ops contains the Uses to sink ordered by dominance (dominating users come first).

Definition at line 1478 of file TargetTransformInfo.cpp.

References I.

◆ isSingleThreaded()

bool TargetTransformInfo::isSingleThreaded ( ) const

Definition at line 341 of file TargetTransformInfo.cpp.

◆ isSourceOfDivergence()

bool TargetTransformInfo::isSourceOfDivergence ( const Value V) const

Returns whether V is a source of divergence.

This function provides the target-dependent information for the target-independent UniformityAnalysis.

Definition at line 296 of file TargetTransformInfo.cpp.

Referenced by llvm::GenericUniformityAnalysisImpl< ContextT >::initialize().

◆ isTargetIntrinsicTriviallyScalarizable()

bool TargetTransformInfo::isTargetIntrinsicTriviallyScalarizable ( Intrinsic::ID  ID) const

Definition at line 611 of file TargetTransformInfo.cpp.

Referenced by llvm::isTriviallyScalarizable().

◆ isTargetIntrinsicWithOverloadTypeAtArg()

bool TargetTransformInfo::isTargetIntrinsicWithOverloadTypeAtArg ( Intrinsic::ID  ID,
int  OpdIdx 
) const

Identifies if the vector form of the intrinsic is overloaded on the type of the operand at index OpdIdx, or on the return type if OpdIdx is -1.

Definition at line 621 of file TargetTransformInfo.cpp.

Referenced by llvm::isVectorIntrinsicWithOverloadTypeAtArg().

◆ isTargetIntrinsicWithScalarOpAtArg()

bool TargetTransformInfo::isTargetIntrinsicWithScalarOpAtArg ( Intrinsic::ID  ID,
unsigned  ScalarOpdIdx 
) const

Identifies if the vector form of the intrinsic has a scalar operand.

Definition at line 616 of file TargetTransformInfo.cpp.

Referenced by llvm::isVectorIntrinsicWithScalarOpAtArg().

◆ isTargetIntrinsicWithStructReturnOverloadAtField()

bool TargetTransformInfo::isTargetIntrinsicWithStructReturnOverloadAtField ( Intrinsic::ID  ID,
int  RetIdx 
) const

Identifies if the vector form of the intrinsic that returns a struct is overloaded at the struct element index RetIdx.

Definition at line 626 of file TargetTransformInfo.cpp.

Referenced by llvm::isVectorIntrinsicWithStructReturnOverloadAtField().

◆ isTruncateFree()

bool TargetTransformInfo::isTruncateFree ( Type Ty1,
Type Ty2 
) const

Return true if it's free to truncate a value of type Ty1 to type Ty2.

e.g. On x86 it's free to truncate a i32 value in register EAX to i16 by referencing its sub-register AX.

Definition at line 576 of file TargetTransformInfo.cpp.

Referenced by llvm::LoopVectorizationCostModel::isOptimizableIVTruncate(), and llvm::SCEVExpander::replaceCongruentIVs().

◆ isTypeLegal()

bool TargetTransformInfo::isTypeLegal ( Type Ty) const

◆ isValidAddrSpaceCast()

bool llvm::TargetTransformInfo::isValidAddrSpaceCast ( unsigned  FromAS,
unsigned  ToAS 
) const

Query the target whether the specified address space cast from FromAS to ToAS is valid.

Definition at line 308 of file TargetTransformInfo.cpp.

Referenced by llvm::expandMemMoveAsLoop(), llvm::InstCombiner::isValidAddrSpaceCast(), and tryInsertCastToCommonAddrSpace().

◆ isVectorShiftByScalarCheap()

bool TargetTransformInfo::isVectorShiftByScalarCheap ( Type Ty) const

Return true if it's significantly cheaper to shift a vector by a uniform scalar than by an amount which will vary across each lane.

On x86 before AVX2 for example, there is a "psllw" instruction for the former case, but no simple instruction for a general "a << b" operation on vectors. This should also apply to lowering for vector funnel shifts (rotates).

Definition at line 1483 of file TargetTransformInfo.cpp.

◆ isVScaleKnownToBeAPowerOfTwo()

bool TargetTransformInfo::isVScaleKnownToBeAPowerOfTwo ( ) const

◆ LSRWithInstrQueries()

bool TargetTransformInfo::LSRWithInstrQueries ( ) const

Return true if the loop strength reduce pass should make Instruction* based TTI queries to isLegalAddressingMode().

This is needed on SystemZ, where e.g. a memcpy can only have a 12 bit unsigned immediate offset and no index register.

Definition at line 572 of file TargetTransformInfo.cpp.

Referenced by isAMCompletelyFolded().

◆ operator=()

TargetTransformInfo & TargetTransformInfo::operator= ( TargetTransformInfo &&  RHS)

Definition at line 213 of file TargetTransformInfo.cpp.

References RHS.

◆ preferAlternateOpcodeVectorization()

bool TargetTransformInfo::preferAlternateOpcodeVectorization ( ) const
Returns
True if target prefers SLP vectorizer with altermate opcode vectorization, false - otherwise.

Definition at line 1415 of file TargetTransformInfo.cpp.

◆ preferEpilogueVectorization()

bool TargetTransformInfo::preferEpilogueVectorization ( ) const

Return true if the loop vectorizer should consider vectorizing an otherwise scalar epilogue loop.

Definition at line 1423 of file TargetTransformInfo.cpp.

Referenced by llvm::LoopVectorizationCostModel::isEpilogueVectorizationProfitable().

◆ preferFixedOverScalableIfEqualCost()

bool TargetTransformInfo::preferFixedOverScalableIfEqualCost ( ) const
Returns
True if the targets prefers fixed width vectorization if the loop vectorizer's cost-model assigns an equal cost to the fixed and scalable version of the vectorized loop.

Definition at line 1406 of file TargetTransformInfo.cpp.

◆ preferInLoopReduction()

bool TargetTransformInfo::preferInLoopReduction ( RecurKind  Kind,
Type Ty 
) const
Returns
True if the target prefers reductions of Kind to be performed in the loop.

Definition at line 1410 of file TargetTransformInfo.cpp.

Referenced by llvm::LoopVectorizationCostModel::collectElementTypesForWidening(), and llvm::LoopVectorizationCostModel::collectInLoopReductions().

◆ preferPredicatedReductionSelect()

bool TargetTransformInfo::preferPredicatedReductionSelect ( ) const
Returns
True if the target prefers reductions select kept in the loop when tail folding. i.e. loop: p = phi (0, s) a = add (p, x) s = select (mask, a, p) vecreduce.add(s)

As opposed to the normal scheme of p = phi (0, a) which allows the select to be pulled out of the loop. If the select(.., add, ..) can be predicated by the target, this can lead to cleaner code generation.

Definition at line 1419 of file TargetTransformInfo.cpp.

Referenced by llvm::LoopVectorizationCostModel::usePredicatedReductionSelect().

◆ preferPredicateOverEpilogue()

bool TargetTransformInfo::preferPredicateOverEpilogue ( TailFoldingInfo TFI) const

Query the target whether it would be prefered to create a predicated vector loop, which can avoid the need to emit a scalar epilogue loop.

Definition at line 369 of file TargetTransformInfo.cpp.

Referenced by getScalarEpilogueLowering().

◆ prefersVectorizedAddressing()

bool TargetTransformInfo::prefersVectorizedAddressing ( ) const

Return true if target doesn't mind addresses in vectors.

Definition at line 559 of file TargetTransformInfo.cpp.

Referenced by llvm::LoopVectorizationCostModel::setCostBasedWideningDecision().

◆ preferToKeepConstantsAttached()

bool TargetTransformInfo::preferToKeepConstantsAttached ( const Instruction Inst,
const Function Fn 
) const

It can be advantageous to detach complex constants from their uses to make their generation cheaper.

This hook allows targets to report when such transformations might negatively effect the code generation of the underlying operation. The motivating example is divides whereby hoisting constants prevents the code generator's ability to transform them into combinations of simpler operations.

Definition at line 757 of file TargetTransformInfo.cpp.

◆ requiresOrderedReduction()

static bool llvm::TargetTransformInfo::requiresOrderedReduction ( std::optional< FastMathFlags FMF)
inlinestatic

◆ rewriteIntrinsicWithAddressSpace()

Value * TargetTransformInfo::rewriteIntrinsicWithAddressSpace ( IntrinsicInst II,
Value OldV,
Value NewV 
) const

Rewrite intrinsic call II such that OldV will be replaced with NewV, which has a different address space.

This should happen for every operand index that collectFlatAddressOperands returned for the intrinsic.

Returns
nullptr if the intrinsic was not handled. Otherwise, returns the new value (which may be the original II with modified operands).

Definition at line 350 of file TargetTransformInfo.cpp.

References II.

◆ shouldBuildLookupTables()

bool TargetTransformInfo::shouldBuildLookupTables ( ) const

Return true if switches should be turned into lookup tables for the target.

Definition at line 594 of file TargetTransformInfo.cpp.

Referenced by simplifySwitchLookup().

◆ shouldBuildLookupTablesForConstant()

bool TargetTransformInfo::shouldBuildLookupTablesForConstant ( Constant C) const

Return true if switches should be turned into lookup tables containing this constant value for the target.

Definition at line 598 of file TargetTransformInfo.cpp.

References llvm::CallingConv::C.

Referenced by validLookupTableConstant().

◆ shouldBuildRelLookupTables()

bool TargetTransformInfo::shouldBuildRelLookupTables ( ) const

Return true if lookup tables should be turned into relative lookup tables.

Definition at line 603 of file TargetTransformInfo.cpp.

◆ shouldConsiderAddressTypePromotion()

bool TargetTransformInfo::shouldConsiderAddressTypePromotion ( const Instruction I,
bool AllowPromotionWithoutCommonHeader 
) const
Returns
True if it should be considered for address type promotion. AllowPromotionWithoutCommonHeader Set true if promoting I is profitable without finding other extensions fed by the same input.

Definition at line 821 of file TargetTransformInfo.cpp.

References I.

◆ shouldDropLSRSolutionIfLessProfitable()

bool TargetTransformInfo::shouldDropLSRSolutionIfLessProfitable ( ) const

Return true if LSR should drop a found solution if it's calculated to be less profitable than the baseline.

Definition at line 444 of file TargetTransformInfo.cpp.

◆ shouldExpandReduction()

bool TargetTransformInfo::shouldExpandReduction ( const IntrinsicInst II) const
Returns
True if the target wants to expand the given reduction intrinsic into a shuffle sequence.

Definition at line 1448 of file TargetTransformInfo.cpp.

References II.

◆ shouldMaximizeVectorBandwidth()

bool TargetTransformInfo::shouldMaximizeVectorBandwidth ( TargetTransformInfo::RegisterKind  K) const
Returns
True if the vectorization factor should be chosen to make the vector of the smallest element type match the size of a vector register. For wider element types, this could result in creating vectors that span multiple vector registers. If false, the vectorization factor will be chosen based on the size of the widest element type. K Register Kind for vectorization.

Definition at line 801 of file TargetTransformInfo.cpp.

Referenced by llvm::LoopVectorizationCostModel::useMaxBandwidth().

◆ shouldPrefetchAddressSpace()

bool TargetTransformInfo::shouldPrefetchAddressSpace ( unsigned  AS) const
Returns
if target want to issue a prefetch in address space AS.

Definition at line 866 of file TargetTransformInfo.cpp.

◆ shouldTreatInstructionLikeSelect()

bool TargetTransformInfo::shouldTreatInstructionLikeSelect ( const Instruction I) const

Should the Select Optimization pass treat the given instruction like a select, potentially converting it to a conditional branch.

This can include select-like instructions like or(zext(c), x) that can be converted to selects.

Definition at line 670 of file TargetTransformInfo.cpp.

References I.

◆ simplifyDemandedUseBitsIntrinsic()

std::optional< Value * > TargetTransformInfo::simplifyDemandedUseBitsIntrinsic ( InstCombiner IC,
IntrinsicInst II,
APInt  DemandedMask,
KnownBits Known,
bool KnownBitsComputed 
) const

Can be used to implement target-specific instruction combining.

See also
instCombineIntrinsic

Definition at line 385 of file TargetTransformInfo.cpp.

References II.

Referenced by llvm::InstCombiner::targetSimplifyDemandedUseBitsIntrinsic().

◆ simplifyDemandedVectorEltsIntrinsic()

std::optional< Value * > TargetTransformInfo::simplifyDemandedVectorEltsIntrinsic ( InstCombiner IC,
IntrinsicInst II,
APInt  DemandedElts,
APInt UndefElts,
APInt UndefElts2,
APInt UndefElts3,
std::function< void(Instruction *, unsigned, APInt, APInt &)>  SimplifyAndSetOp 
) const

Can be used to implement target-specific instruction combining.

See also
instCombineIntrinsic

Definition at line 392 of file TargetTransformInfo.cpp.

References II.

Referenced by llvm::InstCombiner::targetSimplifyDemandedVectorEltsIntrinsic().

◆ supportsEfficientVectorElementLoadStore()

bool TargetTransformInfo::supportsEfficientVectorElementLoadStore ( ) const

If target has efficient vector element load/store instructions, it can return true here so that insertion/extraction costs are not added to the scalarization cost of a load/store.

Definition at line 644 of file TargetTransformInfo.cpp.

◆ supportsScalableVectors()

bool TargetTransformInfo::supportsScalableVectors ( ) const
Returns
True if the target supports scalable vectors.

Definition at line 1466 of file TargetTransformInfo.cpp.

Referenced by llvm::LoopVectorizationCostModel::LoopVectorizationCostModel(), and llvm::LoopVectorizationPlanner::planInVPlanNativePath().

◆ supportsTailCallFor()

bool TargetTransformInfo::supportsTailCallFor ( const CallBase CB) const

If target supports tail call on CB.

Definition at line 652 of file TargetTransformInfo.cpp.

Referenced by llvm::coro::BaseCloner::create(), and llvm::coro::createMustTailCall().

◆ supportsTailCalls()

bool TargetTransformInfo::supportsTailCalls ( ) const

If the target supports tail calls.

Definition at line 648 of file TargetTransformInfo.cpp.

◆ useAA()

bool TargetTransformInfo::useAA ( ) const

Definition at line 584 of file TargetTransformInfo.cpp.

◆ useColdCCForColdCall()

bool TargetTransformInfo::useColdCCForColdCall ( Function F) const

Return true if the input function which is cold at all call sites, should use coldcc calling convention.

Definition at line 607 of file TargetTransformInfo.cpp.

References F.

Referenced by OptimizeFunctions().


The documentation for this class was generated from the following files: