LLVM  6.0.0svn
Classes | 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

class  Concept
 
struct  LSRCost
 
struct  MemCmpExpansionOptions
 If not nullptr, enable inline expansion of memcmp. More...
 
struct  ReductionFlags
 Flags describing the kind of vector reduction. More...
 
struct  UnrollingPreferences
 Parameters that control the generic loop unrolling transformation. More...
 

Public Member Functions

template<typename T >
 TargetTransformInfo (T Impl)
 Construct a TTI object using a type implementing the Concept API below. More...
 
 TargetTransformInfo (const DataLayout &DL)
 Construct a baseline TTI object using a minimal implementation of the Concept API below. More...
 
 TargetTransformInfo (TargetTransformInfo &&Arg)
 
TargetTransformInfooperator= (TargetTransformInfo &&RHS)
 
 ~TargetTransformInfo ()
 
bool invalidate (Function &, const PreservedAnalyses &, FunctionAnalysisManager::Invalidator &)
 Handle the invalidation of this information. More...
 

Generic Target Information

enum  TargetCostKind { TCK_RecipThroughput, TCK_Latency, TCK_CodeSize }
 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...
 
int getInstructionCost (const Instruction *I, enum TargetCostKind kind) const
 Query the cost of a specified instruction. More...
 
int getOperationCost (unsigned Opcode, Type *Ty, Type *OpTy=nullptr) const
 Estimate the cost of a specific operation when lowered. More...
 
int getGEPCost (Type *PointeeType, const Value *Ptr, ArrayRef< const Value *> Operands) const
 Estimate the cost of a GEP operation when lowered. More...
 
int getExtCost (const Instruction *I, const Value *Src) const
 Estimate the cost of a EXT operation when lowered. More...
 
int getCallCost (FunctionType *FTy, int NumArgs=-1) const
 Estimate the cost of a function call when lowered. More...
 
int getCallCost (const Function *F, int NumArgs=-1) const
 Estimate the cost of calling a specific function when lowered. More...
 
int getCallCost (const Function *F, ArrayRef< const Value *> Arguments) const
 Estimate the cost of calling a specific function when lowered. More...
 
unsigned getInliningThresholdMultiplier () const
 
int getIntrinsicCost (Intrinsic::ID IID, Type *RetTy, ArrayRef< Type *> ParamTys) const
 Estimate the cost of an intrinsic when lowered. More...
 
int getIntrinsicCost (Intrinsic::ID IID, Type *RetTy, ArrayRef< const Value *> Arguments) const
 Estimate the cost of an intrinsic when lowered. More...
 
unsigned getEstimatedNumberOfCaseClusters (const SwitchInst &SI, unsigned &JTSize) const
 
int getUserCost (const User *U, ArrayRef< const Value *> Operands) const
 Estimate the cost of a given IR user when lowered. More...
 
int getUserCost (const User *U) const
 This is a helper function which calls the two-argument getUserCost with Operands which are the current operands U has. More...
 
bool hasBranchDivergence () const
 Return true if branch divergence exists. More...
 
bool isSourceOfDivergence (const Value *V) const
 Returns whether V is a source of divergence. More...
 
bool isAlwaysUniform (const Value *V) const
 
unsigned getFlatAddressSpace () const
 Returns the address space ID for a target's 'flat' address space. More...
 
bool isLoweredToCall (const Function *F) const
 Test whether calls to a function lower to actual program function calls. More...
 
void getUnrollingPreferences (Loop *L, ScalarEvolution &, UnrollingPreferences &UP) const
 Get target-customized preferences for the generic loop unrolling transformation. More...
 

Scalar Target Information

enum  PopcntSupportKind { PSK_Software, PSK_SlowHardware, PSK_FastHardware }
 Flags indicating the kind of support for population count. More...
 
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. More...
 
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. More...
 
bool isLegalAddressingMode (Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset, bool HasBaseReg, int64_t Scale, unsigned AddrSpace=0, Instruction *I=nullptr) const
 Return true if the addressing mode represented by AM is legal for this target, for a load/store of the specified type. More...
 
bool isLSRCostLess (TargetTransformInfo::LSRCost &C1, TargetTransformInfo::LSRCost &C2) const
 Return true if LSR cost of C1 is lower than C1. More...
 
bool isLegalMaskedStore (Type *DataType) const
 Return true if the target supports masked load/store AVX2 and AVX-512 targets allow masks for consecutive load and store. More...
 
bool isLegalMaskedLoad (Type *DataType) const
 
bool isLegalMaskedScatter (Type *DataType) const
 Return true if the target supports masked gather/scatter AVX-512 fully supports gather and scatter for vectors with 32 and 64 bits scalar type. More...
 
bool isLegalMaskedGather (Type *DataType) const
 
bool hasDivRemOp (Type *DataType, bool IsSigned) const
 Return true if the target has a unified operation to calculate division and remainder. More...
 
bool hasVolatileVariant (Instruction *I, unsigned AddrSpace) const
 Return true if the given instruction (assumed to be a memory access instruction) has a volatile variant. More...
 
bool prefersVectorizedAddressing () const
 Return true if target doesn't mind addresses in vectors. More...
 
int getScalingFactorCost (Type *Ty, GlobalValue *BaseGV, int64_t 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. More...
 
bool LSRWithInstrQueries () const
 Return true if the loop strength reduce pass should make Instruction* based TTI queries to isLegalAddressingMode(). More...
 
bool isTruncateFree (Type *Ty1, Type *Ty2) const
 Return true if it's free to truncate a value of type Ty1 to type Ty2. More...
 
bool isProfitableToHoist (Instruction *I) const
 Return true if it is profitable to hoist instruction in the then/else to before if. More...
 
bool isTypeLegal (Type *Ty) const
 Return true if this type is legal. More...
 
unsigned getJumpBufAlignment () const
 Returns the target's jmp_buf alignment in bytes. More...
 
unsigned getJumpBufSize () const
 Returns the target's jmp_buf size in bytes. More...
 
bool shouldBuildLookupTables () const
 Return true if switches should be turned into lookup tables for the target. More...
 
bool shouldBuildLookupTablesForConstant (Constant *C) const
 Return true if switches should be turned into lookup tables containing this constant value for the target. More...
 
unsigned getScalarizationOverhead (Type *Ty, bool Insert, bool Extract) const
 
unsigned getOperandsScalarizationOverhead (ArrayRef< const Value *> Args, unsigned VF) const
 
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. More...
 
bool enableAggressiveInterleaving (bool LoopHasReductions) const
 Don't restrict interleaved unrolling to small loops. More...
 
const MemCmpExpansionOptionsenableMemCmpExpansion (bool IsZeroCmp) const
 
bool enableInterleavedAccessVectorization () const
 Enable matching of interleaved access groups. More...
 
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. More...
 
bool allowsMisalignedMemoryAccesses (LLVMContext &Context, unsigned BitWidth, unsigned AddressSpace=0, unsigned Alignment=1, bool *Fast=nullptr) const
 Determine if the target supports unaligned memory accesses. More...
 
PopcntSupportKind getPopcntSupport (unsigned IntTyWidthInBit) const
 Return hardware support for population count. More...
 
bool haveFastSqrt (Type *Ty) const
 Return true if the hardware has a fast square-root instruction. More...
 
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. More...
 
int getFPOpCost (Type *Ty) const
 Return the expected cost of supporting the floating point operation of the specified type. More...
 
int getIntImmCost (const APInt &Imm, Type *Ty) const
 Return the expected cost of materializing for the given integer immediate of the specified type. More...
 
int getIntImmCost (unsigned Opc, unsigned Idx, const APInt &Imm, Type *Ty) const
 Return the expected cost of materialization for the given integer immediate of the specified type for a given instruction. More...
 
int getIntImmCost (Intrinsic::ID IID, unsigned Idx, const APInt &Imm, Type *Ty) const
 
int getIntImmCodeSizeCost (unsigned Opc, unsigned Idx, const APInt &Imm, Type *Ty) const
 Return the expected cost for the given integer when optimising for size. More...
 

Vector Target Information

enum  ShuffleKind {
  SK_Broadcast, SK_Reverse, SK_Alternate, SK_InsertSubvector,
  SK_ExtractSubvector, SK_PermuteTwoSrc, SK_PermuteSingleSrc
}
 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 }
 Additional properties of an operand's values. More...
 
enum  CacheLevel { CacheLevel::L1D, CacheLevel::L2D }
 The possible cache levels. More...
 
unsigned getNumberOfRegisters (bool Vector) const
 
unsigned getRegisterBitWidth (bool Vector) const
 
unsigned getMinVectorRegisterBitWidth () const
 
bool shouldConsiderAddressTypePromotion (const Instruction &I, bool &AllowPromotionWithoutCommonHeader) const
 
unsigned getCacheLineSize () const
 
llvm::Optional< unsignedgetCacheSize (CacheLevel Level) const
 
llvm::Optional< unsignedgetCacheAssociativity (CacheLevel Level) const
 
unsigned getPrefetchDistance () const
 
unsigned getMinPrefetchStride () const
 
unsigned getMaxPrefetchIterationsAhead () const
 
unsigned getMaxInterleaveFactor (unsigned VF) const
 
int getArithmeticInstrCost (unsigned Opcode, Type *Ty, OperandValueKind Opd1Info=OK_AnyValue, OperandValueKind Opd2Info=OK_AnyValue, OperandValueProperties Opd1PropInfo=OP_None, OperandValueProperties Opd2PropInfo=OP_None, ArrayRef< const Value *> Args=ArrayRef< const Value *>()) const
 
int getShuffleCost (ShuffleKind Kind, Type *Tp, int Index=0, Type *SubTp=nullptr) const
 
int getCastInstrCost (unsigned Opcode, Type *Dst, Type *Src, const Instruction *I=nullptr) const
 
int getExtractWithExtendCost (unsigned Opcode, Type *Dst, VectorType *VecTy, unsigned Index=-1) const
 
int getCFInstrCost (unsigned Opcode) const
 
int getCmpSelInstrCost (unsigned Opcode, Type *ValTy, Type *CondTy=nullptr, const Instruction *I=nullptr) const
 
int getVectorInstrCost (unsigned Opcode, Type *Val, unsigned Index=-1) const
 
int getMemoryOpCost (unsigned Opcode, Type *Src, unsigned Alignment, unsigned AddressSpace, const Instruction *I=nullptr) const
 
int getMaskedMemoryOpCost (unsigned Opcode, Type *Src, unsigned Alignment, unsigned AddressSpace) const
 
int getGatherScatterOpCost (unsigned Opcode, Type *DataTy, Value *Ptr, bool VariableMask, unsigned Alignment) const
 
int getInterleavedMemoryOpCost (unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, unsigned Alignment, unsigned AddressSpace) const
 
int getArithmeticReductionCost (unsigned Opcode, Type *Ty, bool IsPairwiseForm) const
 Calculate the cost of performing a vector reduction. More...
 
int getMinMaxReductionCost (Type *Ty, Type *CondTy, bool IsPairwiseForm, bool IsUnsigned) const
 
int getIntrinsicInstrCost (Intrinsic::ID ID, Type *RetTy, ArrayRef< Value *> Args, FastMathFlags FMF, unsigned VF=1) const
 
int getIntrinsicInstrCost (Intrinsic::ID ID, Type *RetTy, ArrayRef< Type *> Tys, FastMathFlags FMF, unsigned ScalarizationCostPassed=UINT_MAX) const
 
int getCallInstrCost (Function *F, Type *RetTy, ArrayRef< Type *> Tys) const
 
unsigned getNumberOfParts (Type *Tp) const
 
int getAddressComputationCost (Type *Ty, ScalarEvolution *SE=nullptr, const SCEV *Ptr=nullptr) const
 
unsigned getCostOfKeepingLiveOverCall (ArrayRef< Type *> Tys) const
 
bool getTgtMemIntrinsic (IntrinsicInst *Inst, MemIntrinsicInfo &Info) const
 
unsigned getAtomicMemIntrinsicMaxElementSize () const
 
ValuegetOrCreateResultFromMemIntrinsic (IntrinsicInst *Inst, Type *ExpectedType) const
 
TypegetMemcpyLoopLoweringType (LLVMContext &Context, Value *Length, unsigned SrcAlign, unsigned DestAlign) const
 
void getMemcpyLoopResidualLoweringType (SmallVectorImpl< Type *> &OpsOut, LLVMContext &Context, unsigned RemainingBytes, unsigned SrcAlign, unsigned DestAlign) const
 
bool useWideIRMemcpyLoopLowering () const
 
bool areInlineCompatible (const Function *Caller, const Function *Callee) const
 
unsigned getLoadStoreVecRegBitWidth (unsigned AddrSpace) const
 
bool isLegalToVectorizeLoad (LoadInst *LI) const
 
bool isLegalToVectorizeStore (StoreInst *SI) const
 
bool isLegalToVectorizeLoadChain (unsigned ChainSizeInBytes, unsigned Alignment, unsigned AddrSpace) const
 
bool isLegalToVectorizeStoreChain (unsigned ChainSizeInBytes, unsigned Alignment, unsigned AddrSpace) const
 
unsigned getLoadVectorFactor (unsigned VF, unsigned LoadSize, unsigned ChainSizeInBytes, VectorType *VecTy) const
 
unsigned getStoreVectorFactor (unsigned VF, unsigned StoreSize, unsigned ChainSizeInBytes, VectorType *VecTy) const
 
bool useReductionIntrinsic (unsigned Opcode, Type *Ty, ReductionFlags Flags) const
 
bool shouldExpandReduction (const IntrinsicInst *II) const
 

Detailed Description

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

Definition at line 78 of file TargetTransformInfo.h.

Member Enumeration Documentation

◆ CacheLevel

The possible cache levels.

Enumerator
L1D 
L2D 

Definition at line 670 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 639 of file TargetTransformInfo.h.

◆ OperandValueProperties

Additional properties of an operand's values.

Enumerator
OP_None 
OP_PowerOf2 

Definition at line 647 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 446 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_Alternate 

Choose alternate elements from vector.

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.

Definition at line 626 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 166 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.

Enumerator
TCK_RecipThroughput 

Reciprocal throughput.

TCK_Latency 

The latency of instruction.

TCK_CodeSize 

Instruction code size.

Definition at line 121 of file TargetTransformInfo.h.

Constructor & Destructor Documentation

◆ TargetTransformInfo() [1/3]

template<typename T >
llvm::TargetTransformInfo::TargetTransformInfo ( T  Impl)

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 implementaion that encodes appropriate costs for their target.

Definition at line 1495 of file TargetTransformInfo.h.

◆ 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 49 of file TargetTransformInfo.cpp.

◆ TargetTransformInfo() [3/3]

TargetTransformInfo::TargetTransformInfo ( TargetTransformInfo &&  Arg)

Definition at line 54 of file TargetTransformInfo.cpp.

◆ ~TargetTransformInfo()

TargetTransformInfo::~TargetTransformInfo ( )

Definition at line 52 of file TargetTransformInfo.cpp.

Member Function Documentation

◆ allowsMisalignedMemoryAccesses()

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

Determine if the target supports unaligned memory accesses.

Definition at line 266 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 554 of file TargetTransformInfo.cpp.

Referenced by functionsHaveCompatibleAttributes(), and isWrapperOnlyCall().

◆ enableAggressiveInterleaving()

bool TargetTransformInfo::enableAggressiveInterleaving ( bool  LoopHasReductions) const

Don't restrict interleaved unrolling to small loops.

Definition at line 249 of file TargetTransformInfo.cpp.

Referenced by hasOutsideLoopUser().

◆ enableInterleavedAccessVectorization()

bool TargetTransformInfo::enableInterleavedAccessVectorization ( ) const

Enable matching of interleaved access groups.

Definition at line 258 of file TargetTransformInfo.cpp.

Referenced by canIfConvertPHINodes().

◆ enableMemCmpExpansion()

const TargetTransformInfo::MemCmpExpansionOptions * TargetTransformInfo::enableMemCmpExpansion ( bool  IsZeroCmp) const

Definition at line 254 of file TargetTransformInfo.cpp.

◆ getAddressComputationCost()

int TargetTransformInfo::getAddressComputationCost ( Type Ty,
ScalarEvolution SE = nullptr,
const SCEV Ptr = nullptr 
) 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 on vector types and scalar types. Such targets should override this function. The 'SE' parameter holds pointer for the scalar evolution object which is used in order to get the Ptr step value in case of constant stride. The 'Ptr' parameter holds SCEV of the access pointer.

Definition at line 492 of file TargetTransformInfo.cpp.

References assert().

Referenced by chainToBasePointerCost(), and isStrideMul().

◆ getArithmeticInstrCost()

int TargetTransformInfo::getArithmeticInstrCost ( unsigned  Opcode,
Type Ty,
OperandValueKind  Opd1Info = OK_AnyValue,
OperandValueKind  Opd2Info = OK_AnyValue,
OperandValueProperties  Opd1PropInfo = OP_None,
OperandValueProperties  Opd2PropInfo = OP_None,
ArrayRef< const Value *>  Args = ArrayRef<const Value *>() 
) const
Returns
The expected cost of arithmetic ops, such as mul, xor, fsub, etc. Args is an optional argument which holds the instruction operands values so the TTI can analyize those values searching for special cases based on those values.

Definition at line 370 of file TargetTransformInfo.cpp.

References assert().

Referenced by createRdxShuffleMask(), isBroadcastShuffle(), isStrideMul(), matchVectorSplittingReduction(), and visitIVCast().

◆ getArithmeticReductionCost()

int TargetTransformInfo::getArithmeticReductionCost ( unsigned  Opcode,
Type Ty,
bool  IsPairwiseForm 
) const

Calculate the cost of performing a vector reduction.

This is the cost of reducing the vector value of type Ty to a scalar value using the operation denoted by Opcode. The form of the reduction can either be a pairwise reduction or a reduction that splits the vector at every reduction level.

Pairwise: (v0, v1, v2, v3) ((v0+v1), (v2+v3), undef, undef) Split: (v0, v1, v2, v3) ((v0+v2), (v1+v3), undef, undef)

Definition at line 500 of file TargetTransformInfo.cpp.

References assert().

Referenced by createRdxShuffleMask(), and matchVectorSplittingReduction().

◆ getAtomicMemIntrinsicMaxElementSize()

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

Definition at line 526 of file TargetTransformInfo.cpp.

Referenced by getNumBytes().

◆ getCacheAssociativity()

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

Definition at line 349 of file TargetTransformInfo.cpp.

◆ getCacheLineSize()

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

Definition at line 340 of file TargetTransformInfo.cpp.

◆ getCacheSize()

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

Definition at line 344 of file TargetTransformInfo.cpp.

◆ getCallCost() [1/3]

int TargetTransformInfo::getCallCost ( FunctionType FTy,
int  NumArgs = -1 
) const

Estimate the cost of a function call when lowered.

The contract for this is the same as getOperationCost except that it supports an interface that provides extra information specific to call instructions.

This is the most basic query for estimating call cost: it only knows the function type and (potentially) the number of arguments at the call site. The latter is only interesting for varargs function types.

Definition at line 69 of file TargetTransformInfo.cpp.

References assert().

◆ getCallCost() [2/3]

int llvm::TargetTransformInfo::getCallCost ( const Function F,
int  NumArgs = -1 
) const

Estimate the cost of calling a specific function when lowered.

This overload adds the ability to reason about the particular function being called in the event it is a library call with special lowering.

◆ getCallCost() [3/3]

int TargetTransformInfo::getCallCost ( const Function F,
ArrayRef< const Value *>  Arguments 
) const

Estimate the cost of calling a specific function when lowered.

This overload allows specifying a set of candidate argument values.

Definition at line 75 of file TargetTransformInfo.cpp.

References assert().

◆ getCallInstrCost()

int TargetTransformInfo::getCallInstrCost ( Function F,
Type RetTy,
ArrayRef< Type *>  Tys 
) const
Returns
The cost of Call instructions.

Definition at line 481 of file TargetTransformInfo.cpp.

References assert().

Referenced by getVectorCallCost().

◆ getCastInstrCost()

int TargetTransformInfo::getCastInstrCost ( unsigned  Opcode,
Type Dst,
Type Src,
const Instruction I = nullptr 
) const
Returns
The expected cost of cast instructions, such as bitcast, trunc, zext, etc. If there is an existing instruction that holds Opcode, it may be passed in the 'I' parameter.

Definition at line 388 of file TargetTransformInfo.cpp.

References assert(), and llvm::Instruction::getOpcode().

Referenced by chainToBasePointerCost(), isStrideMul(), and matchVectorSplittingReduction().

◆ getCFInstrCost()

int TargetTransformInfo::getCFInstrCost ( unsigned  Opcode) const
Returns
The expected cost of control-flow related instructions such as Phi, Ret, Br.

Definition at line 405 of file TargetTransformInfo.cpp.

References assert().

Referenced by hasOutsideLoopUser(), isStrideMul(), and matchVectorSplittingReduction().

◆ getCmpSelInstrCost()

int TargetTransformInfo::getCmpSelInstrCost ( unsigned  Opcode,
Type ValTy,
Type CondTy = nullptr,
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.

Definition at line 411 of file TargetTransformInfo.cpp.

References assert(), and llvm::Instruction::getOpcode().

Referenced by createRdxShuffleMask(), isStrideMul(), and matchVectorSplittingReduction().

◆ getCostOfKeepingLiveOverCall()

unsigned 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 517 of file TargetTransformInfo.cpp.

◆ getEstimatedNumberOfCaseClusters()

unsigned TargetTransformInfo::getEstimatedNumberOfCaseClusters ( const SwitchInst SI,
unsigned JTSize 
) 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 104 of file TargetTransformInfo.cpp.

◆ getExtCost()

int TargetTransformInfo::getExtCost ( const Instruction I,
const Value Src 
) const

Estimate the cost of a EXT operation when lowered.

The contract for this function is the same as getOperationCost except that it supports an interface that provides extra information specific to the EXT operation.

Definition at line 91 of file TargetTransformInfo.cpp.

◆ getExtractWithExtendCost()

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

Definition at line 397 of file TargetTransformInfo.cpp.

References assert().

◆ 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 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 128 of file TargetTransformInfo.cpp.

Referenced by cloneConstantExprWithNewAddressSpace().

◆ getFPOpCost()

int TargetTransformInfo::getFPOpCost ( Type Ty) const

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

Definition at line 288 of file TargetTransformInfo.cpp.

References assert().

◆ getGatherScatterOpCost()

int TargetTransformInfo::getGatherScatterOpCost ( unsigned  Opcode,
Type DataTy,
Value Ptr,
bool  VariableMask,
unsigned  Alignment 
) 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

Definition at line 447 of file TargetTransformInfo.cpp.

References assert().

Referenced by isStrideMul().

◆ getGEPCost()

int TargetTransformInfo::getGEPCost ( Type PointeeType,
const Value Ptr,
ArrayRef< const Value *>  Operands 
) const

Estimate the cost of a GEP operation when lowered.

The contract for this function is the same as getOperationCost except that it supports an interface that provides extra information specific to the GEP operation.

Definition at line 86 of file TargetTransformInfo.cpp.

Referenced by isGEPFoldable().

◆ 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 82 of file TargetTransformInfo.cpp.

◆ getInstructionCost()

int llvm::TargetTransformInfo::getInstructionCost ( const Instruction I,
enum TargetCostKind  kind 
) const
inline

Query the cost of a specified instruction.

Clients should use this interface to query the cost of an existing instruction. The instruction must have a valid parent (basic block).

Note, this method does not cache the cost calculation and it can be expensive in some cases.

Definition at line 134 of file TargetTransformInfo.h.

References llvm_unreachable.

◆ getInterleavedMemoryOpCost()

int TargetTransformInfo::getInterleavedMemoryOpCost ( unsigned  Opcode,
Type VecTy,
unsigned  Factor,
ArrayRef< unsigned Indices,
unsigned  Alignment,
unsigned  AddressSpace 
) 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.

Definition at line 456 of file TargetTransformInfo.cpp.

References assert().

Referenced by isStrideMul().

◆ getIntImmCodeSizeCost()

int 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 294 of file TargetTransformInfo.cpp.

References assert().

◆ getIntImmCost() [1/3]

int TargetTransformInfo::getIntImmCost ( const APInt Imm,
Type Ty 
) const

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

Definition at line 302 of file TargetTransformInfo.cpp.

References assert().

Referenced by isSafeAndProfitableToSpeculateAroundPHI(), and tryUnmergingGEPsAcrossIndirectBr().

◆ getIntImmCost() [2/3]

int TargetTransformInfo::getIntImmCost ( unsigned  Opc,
unsigned  Idx,
const APInt Imm,
Type Ty 
) 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 308 of file TargetTransformInfo.cpp.

References assert().

◆ getIntImmCost() [3/3]

int TargetTransformInfo::getIntImmCost ( Intrinsic::ID  IID,
unsigned  Idx,
const APInt Imm,
Type Ty 
) const

Definition at line 315 of file TargetTransformInfo.cpp.

References assert().

◆ getIntrinsicCost() [1/2]

int llvm::TargetTransformInfo::getIntrinsicCost ( Intrinsic::ID  IID,
Type RetTy,
ArrayRef< Type *>  ParamTys 
) const

Estimate the cost of an intrinsic when lowered.

Mirrors the getCallCost method but uses an intrinsic identifier.

Referenced by detectCTLZIdiom().

◆ getIntrinsicCost() [2/2]

int TargetTransformInfo::getIntrinsicCost ( Intrinsic::ID  IID,
Type RetTy,
ArrayRef< const Value *>  Arguments 
) const

Estimate the cost of an intrinsic when lowered.

Mirrors the getCallCost method but uses an intrinsic identifier.

Definition at line 96 of file TargetTransformInfo.cpp.

References assert().

◆ getIntrinsicInstrCost() [1/2]

int TargetTransformInfo::getIntrinsicInstrCost ( Intrinsic::ID  ID,
Type RetTy,
ArrayRef< Value *>  Args,
FastMathFlags  FMF,
unsigned  VF = 1 
) 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 with VF.

Definition at line 474 of file TargetTransformInfo.cpp.

References assert().

Referenced by getVectorIntrinsicCost(), and matchVectorSplittingReduction().

◆ getIntrinsicInstrCost() [2/2]

int TargetTransformInfo::getIntrinsicInstrCost ( Intrinsic::ID  ID,
Type RetTy,
ArrayRef< Type *>  Tys,
FastMathFlags  FMF,
unsigned  ScalarizationCostPassed = UINT_MAX 
) const
Returns
The cost of Intrinsic instructions. Types analysis only. If ScalarizationCostPassed is UINT_MAX, the cost of scalarizing the arguments and the return value will be computed based on types.

Definition at line 465 of file TargetTransformInfo.cpp.

References assert().

◆ getJumpBufAlignment()

unsigned TargetTransformInfo::getJumpBufAlignment ( ) const

Returns the target's jmp_buf alignment in bytes.

Definition at line 219 of file TargetTransformInfo.cpp.

◆ getJumpBufSize()

unsigned TargetTransformInfo::getJumpBufSize ( ) const

Returns the target's jmp_buf size in bytes.

Definition at line 223 of file TargetTransformInfo.cpp.

◆ 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 559 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 583 of file TargetTransformInfo.cpp.

◆ getMaskedMemoryOpCost()

int TargetTransformInfo::getMaskedMemoryOpCost ( unsigned  Opcode,
Type Src,
unsigned  Alignment,
unsigned  AddressSpace 
) const
Returns
The cost of masked Load and Store instructions.

Definition at line 438 of file TargetTransformInfo.cpp.

References assert().

Referenced by isStrideMul().

◆ getMaxInterleaveFactor()

unsigned TargetTransformInfo::getMaxInterleaveFactor ( unsigned  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 366 of file TargetTransformInfo.cpp.

Referenced by hasOutsideLoopUser(), and llvm::LoopVectorizePass::runImpl().

◆ 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 362 of file TargetTransformInfo.cpp.

◆ getMemcpyLoopLoweringType()

Type * TargetTransformInfo::getMemcpyLoopLoweringType ( LLVMContext Context,
Value Length,
unsigned  SrcAlign,
unsigned  DestAlign 
) const
Returns
The type to use in a loop expansion of a memcpy call.

Definition at line 535 of file TargetTransformInfo.cpp.

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

◆ getMemcpyLoopResidualLoweringType()

void TargetTransformInfo::getMemcpyLoopResidualLoweringType ( SmallVectorImpl< Type *> &  OpsOut,
LLVMContext Context,
unsigned  RemainingBytes,
unsigned  SrcAlign,
unsigned  DestAlign 
) 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 543 of file TargetTransformInfo.cpp.

Referenced by llvm::createMemCpyLoopKnownSize().

◆ getMemoryOpCost()

int TargetTransformInfo::getMemoryOpCost ( unsigned  Opcode,
Type Src,
unsigned  Alignment,
unsigned  AddressSpace,
const Instruction I = nullptr 
) const
Returns
The cost of Load and Store instructions.

Definition at line 427 of file TargetTransformInfo.cpp.

References assert(), and llvm::Instruction::getOpcode().

Referenced by isStrideMul(), and matchVectorSplittingReduction().

◆ getMinMaxReductionCost()

int TargetTransformInfo::getMinMaxReductionCost ( Type Ty,
Type CondTy,
bool  IsPairwiseForm,
bool  IsUnsigned 
) const

Definition at line 507 of file TargetTransformInfo.cpp.

References assert().

Referenced by createRdxShuffleMask(), and matchVectorSplittingReduction().

◆ getMinPrefetchStride()

unsigned TargetTransformInfo::getMinPrefetchStride ( ) const
Returns
Some HW prefetchers can handle accesses up to a certain constant stride. 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 358 of file TargetTransformInfo.cpp.

◆ getMinVectorRegisterBitWidth()

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

Definition at line 330 of file TargetTransformInfo.cpp.

◆ 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 488 of file TargetTransformInfo.cpp.

Referenced by isStrideMul().

◆ getNumberOfRegisters()

unsigned TargetTransformInfo::getNumberOfRegisters ( bool  Vector) const
Returns
The number of scalar or vector registers that the target has. If 'Vectors' is true, it returns the number of vector registers. If it is set to false, it returns the number of scalar registers.

Definition at line 322 of file TargetTransformInfo.cpp.

Referenced by DeleteTriviallyDeadInstructions(), hasOutsideLoopUser(), and llvm::LoopVectorizePass::runImpl().

◆ getOperandsScalarizationOverhead()

unsigned TargetTransformInfo::getOperandsScalarizationOverhead ( ArrayRef< const Value *>  Args,
unsigned  VF 
) const

Definition at line 240 of file TargetTransformInfo.cpp.

Referenced by getScalarizationOverhead(), and getScalarizationOverhead().

◆ getOperationCost()

int TargetTransformInfo::getOperationCost ( unsigned  Opcode,
Type Ty,
Type OpTy = nullptr 
) const

Estimate the cost of a specific operation when lowered.

Note that this is designed to work on an arbitrary synthetic opcode, and thus work for hypothetical queries before an instruction has even been formed. However, this does not work for GEPs, and must not be called for a GEP instruction. Instead, use the dedicated getGEPCost interface as analyzing a GEP's cost required more information.

Typically only the result type is required, and the operand type can be omitted. However, if the opcode is one of the cast instructions, the operand type is required.

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

Definition at line 62 of file TargetTransformInfo.cpp.

References assert().

◆ getOrCreateResultFromMemIntrinsic()

Value * TargetTransformInfo::getOrCreateResultFromMemIntrinsic ( IntrinsicInst Inst,
Type ExpectedType 
) const
Returns
A value which is the result of the given memory intrinsic. 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 530 of file TargetTransformInfo.cpp.

Referenced by llvm::DenseMapInfo< CallValue >::getTombstoneKey().

◆ getPopcntSupport()

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

Return hardware support for population count.

Definition at line 276 of file TargetTransformInfo.cpp.

Referenced by detectCTLZIdiom().

◆ 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 354 of file TargetTransformInfo.cpp.

◆ getRegisterBitWidth()

unsigned TargetTransformInfo::getRegisterBitWidth ( bool  Vector) const
Returns
The width of the largest scalar or vector register type.

Definition at line 326 of file TargetTransformInfo.cpp.

Referenced by hasOutsideLoopUser().

◆ getScalarizationOverhead()

unsigned TargetTransformInfo::getScalarizationOverhead ( Type Ty,
bool  Insert,
bool  Extract 
) const

◆ getScalingFactorCost()

int TargetTransformInfo::getScalingFactorCost ( Type Ty,
GlobalValue BaseGV,
int64_t  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 192 of file TargetTransformInfo.cpp.

References assert().

Referenced by getScalingFactorCost().

◆ getShuffleCost()

int TargetTransformInfo::getShuffleCost ( ShuffleKind  Kind,
Type Tp,
int  Index = 0,
Type SubTp = nullptr 
) const
Returns
The cost of a shuffle instruction of kind Kind and of type Tp. The index and subtype parameters are used by the subvector insertion and extraction shuffle kinds.

Definition at line 381 of file TargetTransformInfo.cpp.

References assert().

Referenced by isStrideMul(), and matchVectorSplittingReduction().

◆ 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 590 of file TargetTransformInfo.cpp.

◆ 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 521 of file TargetTransformInfo.cpp.

Referenced by getAccessType(), llvm::DenseMapInfo< CallValue >::getTombstoneKey(), and isAddressUse().

◆ getUnrollingPreferences()

void TargetTransformInfo::getUnrollingPreferences ( Loop L,
ScalarEvolution SE,
UnrollingPreferences UP 
) 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 136 of file TargetTransformInfo.cpp.

Referenced by gatherUnrollingPreferences().

◆ getUserCost() [1/2]

int TargetTransformInfo::getUserCost ( const User U,
ArrayRef< const Value *>  Operands 
) const

Estimate the cost of a given IR user when lowered.

This can estimate the cost of either a ConstantExpr or Instruction when lowered. It has two primary advantages over the getOperationCost and getGEPCost above, and one significant disadvantage: it can only be used when the IR construct has already been formed.

The advantages are that it can inspect the SSA use graph to reason more accurately about the cost. For example, all-constant-GEPs can often be folded into a load or other instruction, but if they are used in some other context they may not be folded. This routine can distinguish such cases.

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 109 of file TargetTransformInfo.cpp.

References assert().

Referenced by llvm::CodeMetrics::analyzeBasicBlock(), analyzeLoopUnrollCost(), llvm::ComputeSpeculationCost(), ComputeSpeculationCost(), findProfitablePHIs(), matchVectorSplittingReduction(), sinkSelectOperand(), and unswitchLoop().

◆ getUserCost() [2/2]

int llvm::TargetTransformInfo::getUserCost ( const User U) const
inline

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

Definition at line 276 of file TargetTransformInfo.h.

References F(), llvm::User::value_op_begin(), and llvm::User::value_op_end().

◆ getVectorInstrCost()

int TargetTransformInfo::getVectorInstrCost ( unsigned  Opcode,
Type Val,
unsigned  Index = -1 
) const
Returns
The expected cost of vector Insert and Extract. Use -1 to indicate that there is no information on the index value.

Definition at line 420 of file TargetTransformInfo.cpp.

References assert().

Referenced by isBroadcastShuffle(), and matchVectorSplittingReduction().

◆ hasBranchDivergence()

bool TargetTransformInfo::hasBranchDivergence ( ) 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.

Definition at line 116 of file TargetTransformInfo.cpp.

Referenced by hasOutsideLoopUser(), llvm::SpeculativeExecutionPass::runImpl(), and llvm::DivergenceAnalysis::runOnFunction().

◆ 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 179 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 183 of file TargetTransformInfo.cpp.

Referenced by isSimplePointerUseValidToReplace().

◆ haveFastSqrt()

bool TargetTransformInfo::haveFastSqrt ( Type Ty) const

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

Definition at line 280 of file TargetTransformInfo.cpp.

Referenced by runPartiallyInlineLibCalls().

◆ 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 107 of file TargetTransformInfo.h.

◆ isAlwaysUniform()

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

Definition at line 124 of file TargetTransformInfo.cpp.

◆ 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 284 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 262 of file TargetTransformInfo.cpp.

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

◆ 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 141 of file TargetTransformInfo.cpp.

Referenced by CollectSubexprs().

◆ isLegalAddressingMode()

bool TargetTransformInfo::isLegalAddressingMode ( Type Ty,
GlobalValue BaseGV,
int64_t  BaseOffset,
bool  HasBaseReg,
int64_t  Scale,
unsigned  AddrSpace = 0,
Instruction I = nullptr 
) 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. TODO: Handle pre/postinc as well.

Definition at line 149 of file TargetTransformInfo.cpp.

Referenced by llvm::createSeparateConstOffsetFromGEPPass(), isAddFoldable(), isAlwaysFoldable(), and isAMCompletelyFolded().

◆ 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 145 of file TargetTransformInfo.cpp.

Referenced by isAMCompletelyFolded().

◆ isLegalMaskedGather()

bool TargetTransformInfo::isLegalMaskedGather ( Type DataType) const

Definition at line 171 of file TargetTransformInfo.cpp.

Referenced by emitMissedWarning().

◆ isLegalMaskedLoad()

bool TargetTransformInfo::isLegalMaskedLoad ( Type DataType) const

Definition at line 167 of file TargetTransformInfo.cpp.

Referenced by emitMissedWarning().

◆ isLegalMaskedScatter()

bool TargetTransformInfo::isLegalMaskedScatter ( Type DataType) const

Return true if the target supports masked gather/scatter AVX-512 fully supports gather and scatter for vectors with 32 and 64 bits scalar type.

Definition at line 175 of file TargetTransformInfo.cpp.

Referenced by emitMissedWarning().

◆ isLegalMaskedStore()

bool TargetTransformInfo::isLegalMaskedStore ( Type DataType) const

Return true if the target supports masked load/store AVX2 and AVX-512 targets allow masks for consecutive load and store.

Definition at line 163 of file TargetTransformInfo.cpp.

Referenced by emitMissedWarning().

◆ isLegalToVectorizeLoad()

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

Definition at line 563 of file TargetTransformInfo.cpp.

◆ isLegalToVectorizeLoadChain()

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

Definition at line 571 of file TargetTransformInfo.cpp.

◆ isLegalToVectorizeStore()

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

Definition at line 567 of file TargetTransformInfo.cpp.

◆ isLegalToVectorizeStoreChain()

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

Definition at line 577 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 132 of file TargetTransformInfo.cpp.

Referenced by llvm::CodeMetrics::analyzeBasicBlock(), and findTRECandidate().

◆ isLSRCostLess()

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

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

Definition at line 159 of file TargetTransformInfo.cpp.

Referenced by DeleteTriviallyDeadInstructions().

◆ 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 211 of file TargetTransformInfo.cpp.

Referenced by HoistThenElseCodeToIf().

◆ 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 DivergenceAnalysis. DivergenceAnalysis first builds the dependency graph, and then runs the reachability algorithm starting with the sources of divergence.

Definition at line 120 of file TargetTransformInfo.cpp.

◆ 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 207 of file TargetTransformInfo.cpp.

Referenced by CollectSubexprs(), emitMissedWarning(), and llvm::SCEVExpander::replaceCongruentIVs().

◆ isTypeLegal()

bool TargetTransformInfo::isTypeLegal ( Type Ty) const

Return true if this type is legal.

Definition at line 215 of file TargetTransformInfo.cpp.

Referenced by llvm::computeMinimumValueSizes(), isAlwaysFoldable(), and ShouldBuildLookupTable().

◆ 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 203 of file TargetTransformInfo.cpp.

Referenced by isAMCompletelyFolded().

◆ operator=()

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

Definition at line 57 of file TargetTransformInfo.cpp.

◆ prefersVectorizedAddressing()

bool TargetTransformInfo::prefersVectorizedAddressing ( ) const

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

Definition at line 188 of file TargetTransformInfo.cpp.

Referenced by isStrideMul().

◆ shouldBuildLookupTables()

bool TargetTransformInfo::shouldBuildLookupTables ( ) const

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

Definition at line 227 of file TargetTransformInfo.cpp.

Referenced by SwitchToLookupTable().

◆ 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 230 of file TargetTransformInfo.cpp.

References getScalarizationOverhead().

Referenced by ValidLookupTableConstant().

◆ 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 334 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 602 of file TargetTransformInfo.cpp.

References I.

◆ 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 245 of file TargetTransformInfo.cpp.

Referenced by getScalarizationOverhead().

◆ useReductionIntrinsic()

bool TargetTransformInfo::useReductionIntrinsic ( unsigned  Opcode,
Type Ty,
ReductionFlags  Flags 
) const
Returns
True if the target wants to handle the given reduction idiom in the intrinsics form instead of the shuffle form.

Definition at line 597 of file TargetTransformInfo.cpp.

Referenced by llvm::createSimpleTargetReduction().

◆ useWideIRMemcpyLoopLowering()

bool TargetTransformInfo::useWideIRMemcpyLoopLowering ( ) const
Returns
True if we want to test the new memcpy lowering functionality in Transform/Utils. Temporary. Will be removed once we move to the new functionality and remove the old.

Definition at line 550 of file TargetTransformInfo.cpp.

References UseWideMemcpyLoopLowering.

Referenced by llvm::expandMemCpyAsLoop().


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