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

Synopsis

Declared in <llvm/Analysis/TargetTransformInfo.h>

class TargetTransformInfo;

Types

Name

Description

LSRCost

Cost metrics used by Loop Strength Reduction.

MemCmpExpansionOptions

Returns options for expansion of memcmp. IsZeroCmp is

OperandValueInfo

Describe the values an operand can take.

PeelingPreferences

Parameters that control the loop peeling transformation.

PointersChainInfo

Describe known properties for a set of pointers.

UnrollingPreferences

Parameters that control the generic loop unrolling transformation.

VPLegalization

Describe how a vector‐predicated operation should be legalized.

Type Aliases

Name

Description

VectorInstrContext

Alias of llvm::VectorInstrContext for use on TargetTransformInfo.

Enums

Name

Description

AddressingModeKind

Which addressing mode Loop Strength Reduction will try to generate.

CacheLevel

The possible cache levels.

CastContextHint

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

MaskKind

Some targets only support masked load/store with a constant mask.

MemIndexedMode

The type of load/store indexing.

OperandValueKind

Additional information about an operand's possible values.

OperandValueProperties

Additional properties of an operand's values.

PartialReductionExtendKind

Kind of extend used in a partial reduction.

PopcntSupportKind

Flags indicating the kind of support for population count.

ReductionShuffle

Shuffle pattern used when expanding a reduction intrinsic.

RegisterKind

Kind of register whose bit width is being queried.

ShuffleKind

The various kinds of shuffle patterns for vector queries.

TargetCostConstants

Underlying constants for 'cost' values in this interface.

TargetCostKind

The kind of cost model.

Member Functions

Name

Description

TargetTransformInfo [constructor]

Constructors

~TargetTransformInfo [destructor]

Destroy TargetTransformInfo.

operator=

Move‐assign TargetTransformInfo.

LSRWithInstrQueries

Return true if LSR should query isLegalAddressingMode with an Instruction.

addrspacesMayAlias

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

adjustInliningThreshold

Return a value to be added to the inlining threshold.

allowVectorElementIndexingUsingGEP

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

allowsMisalignedMemoryAccesses

Determine if the target supports unaligned memory accesses.

areInlineCompatible

Return true if the two functions have compatible attributes for inlining.

areTypesABICompatible

Return true if caller and callee agree on how Types are passed.

canHaveNonUndefGlobalInitializerInAddressSpace

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

canMacroFuseCmp

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

canSaveCmp

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

collectFlatAddressOperands

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

collectKernelLaunchBounds

Collect kernel launch bounds for F into LB.

computeKnownBitsAddrSpaceCast

computeKnownBitsAddrSpaceCast overloads

enableAggressiveInterleaving

Don't restrict interleaved unrolling to small loops.

enableInterleavedAccessVectorization

Enable matching of interleaved access groups.

enableMaskedInterleavedAccessVectorization

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

enableMemCmpExpansion

Return target options for expanding memcmp.

enableOrderedReductions

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

enableScalableVectorization

Return true when scalable vectorization is preferred.

enableSelectOptimize

Should the Select Optimization pass be enabled and ran.

enableWritePrefetching

Return true if prefetching should also be done for writes.

forceScalarizeMaskedGather

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

forceScalarizeMaskedScatter

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

getAddrSpaceCastPreservedPtrMask

Return a mask of pointer bits preserved by an address‐space cast.

getAddressComputationCost

Return the cost of computing an address for a memory operation.

getAltInstrCost

Return the cost of an alternating‐opcode pattern lowered as one instruction.

getArithmeticInstrCost

Estimate the reciprocal‐throughput cost of a math or logic instruction.

getArithmeticReductionCost

Calculate the cost of vector reduction intrinsics.

getAssumedAddrSpace

Return an assumed address space for value V.

getAtomicMemIntrinsicMaxElementSize

Return the max element size in bytes for unordered‐atomic mem intrinsics.

getBranchMispredictPenalty

Return estimated branch‐misprediction penalty in latency.

getCFInstrCost

Return the expected cost of control‐flow instructions such as Phi or Br.

getCacheAssociativity

Return the associativity of the cache level, if available.

getCacheLineSize

Return the size of a cache line in bytes.

getCacheSize

Return the size of the cache level in bytes, if available.

getCallInstrCost

Return the cost of Call instructions.

getCallerAllocaCost

Return the cost of leaving an Alloca in the caller when not inlined.

getCastInstrCost

Return the expected cost of cast instructions such as bitcast or trunc.

getCmpSelInstrCost

Return the expected cost of compare and select instructions.

getCostOfKeepingLiveOverCall

Return the cost of keeping values of the given types alive over a call.

getEpilogueVectorizationMinVF

Query the target for which minimum VF epilogue vectorization should use.

getEstimatedNumberOfCaseClusters

Return the estimated number of case clusters when lowering SI.

getExtendedReductionCost

Return the cost of an extended reduction pattern.

getExtractWithExtendCost

Return the expected cost of a sign‐ or zero‐extended vector extract.

getFPOpCost

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

getFeatureMask

Returns a bitmask constructed from the target‐features or fmv‐features metadata of a function corresponding to its Arch Extensions.

getFlatAddressSpace

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

getGEPCost

Estimate the cost of a GEP operation when lowered.

getGISelRematGlobalCost

Return the size cost of rematerializing a GlobalValue versus a reload.

getIndexedVectorInstrCostFromEnd

Return the cost of inserting or extracting a lane from the vector end.

getInlineCallPenalty

Return a penalty for invoking call Call from function F.

getInlinerVectorBonusPercent

Return the vector‐instruction inlining bonus as a percent.

getInliningCostBenefitAnalysisProfitableMultiplier

Return the profitability multiplier used by inlining cost‐benefit analysis.

getInliningCostBenefitAnalysisSavingsMultiplier

Return the savings multiplier used by inlining cost‐benefit analysis.

getInliningLastCallToStaticBonus

Return the bonus of inlining the last call to a static function.

getInliningThresholdMultiplier

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

getInsertExtractValueCost

Return the expected cost of aggregate inserts and extracts.

getInstructionCost

getInstructionCost overloads

getIntImmCodeSizeCost

Return the size‐optimization cost of materializing the given integer.

getIntImmCost

Return the expected cost of materializing the given integer immediate.

getIntImmCostInst

Return the materialization cost of an immediate used by an instruction.

getIntImmCostIntrin

Return the materialization cost of an immediate used by an intrinsic.

getInterleavedMemoryOpCost

Return the cost of an interleaved memory operation.

getIntrinsicInstrCost

Return the cost of Intrinsic instructions. Analyses the real arguments.

getLoadStoreVecRegBitWidth

Return the largest vector bitwidth for loads and stores in AddrSpace.

getLoadVectorFactor

Return the adjusted VF if the target cannot use SizeInBytes loads.

getMaxInterleaveFactor

Return the maximum interleave factor any transform should try for this target.

getMaxMemIntrinsicInlineSizeThreshold

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

getMaxNumArgs

Return the maximum number of function arguments the target supports.

getMaxPrefetchIterationsAhead

Return the maximum number of iterations to prefetch ahead.

getMaxVScale

Return the architectural maximum vscale, if the target specifies one.

getMaximumVF

Return the maximum VF for the given element width and opcode, or 0.

getMemIntrinsicInstrCost

Return the cost of memory intrinsic instructions.

getMemcpyCost

Return the expected cost of a memcpy.

getMemcpyLoopLoweringType

Return the type to use in a loop expansion of a memcpy call.

getMemcpyLoopResidualLoweringType

Calculate operand types to copy RemainingBytes of residual memory.

getMemoryOpCost

Return the cost of Load and Store instructions.

getMinMaxReductionCost

Return the cost of a min/max vector reduction.

getMinPageSize

Return the minimum architectural page size for the target.

getMinPrefetchStride

Return the minimum stride in bytes at which software prefetching is useful.

getMinTripCountTailFoldingThreshold

Return the minimum trip count to consider vectorizing with tail‐folding.

getMinVectorRegisterBitWidth

Return the width of the smallest vector register type.

getMinimumLookupTableEntryBitWidth

Return the minimum bit width to use for integer switch lookup table elements on this target.

getMinimumVF

Return the minimum VF for the given element width, or 0 if there is none.

getMulAccReductionCost

Return the cost of a multiply‐accumulate reduction pattern.

getNumBytesToPadGlobalArray

Return how many padding bytes to add for a global array of the given size.

getNumberOfParts

Return how many parts Tp splits into during legalization.

getNumberOfRegisters

Return the number of registers in the target‐provided register class.

getOperandsScalarizationOverhead

Estimate the overhead of scalarizing operands with the given types.

getOrCreateResultFromMemIntrinsic

Return a value holding the result of the given memory intrinsic.

getPartialReductionCost

Return the cost of a partial reduction from a vector to a narrower vector.

getPeelingPreferences

Get target‐customized preferences for generic loop peeling.

getPointersChainCost

Estimate the cost of a chain of pointer operations when lowered.

getPopcntSupport

Return hardware support for population count.

getPredicatedAddrSpace

Return a predicated pointer and its address space for value V.

getPredictableBranchThreshold

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.

getPreferredAddressingMode

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

getPreferredExpandedReductionShuffle

Return the shuffle pattern used to expand the given reduction intrinsic.

getPreferredTailFoldingStyle

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

getPrefetchDistance

Return how many instructions before a load a prefetch should be placed.

getPriorityMask

Returns a bitmask constructed from the target‐features or fmv‐features metadata of a function corresponding to its FMV priority.

getRegUsageForType

Returns the estimated number of registers required to represent Ty.

getRegisterBitWidth

Return the width of the largest scalar or vector register type.

getRegisterClassForType

Return the target‐provided register class ID for the provided type.

getRegisterClassName

Return the target‐provided register class name.

getRegisterClassReloadCost

Return the cost of reloading a register in the given class from the stack.

getRegisterClassSpillCost

Return the cost of spilling a register in the given class to the stack.

getReplicationShuffleCost

Return the cost of a replication shuffle of VF elements of type EltTy.

getScalarizationOverhead

Estimate the overhead of scalarizing an instruction.

getScalingFactorCost

Return the cost of the scaling factor used in addressing mode AM.

getShuffleCost

Return the cost of a shuffle of kind Kind from SrcTy to DstTy.

getStoreMinimumVF

Return the minimum vectorization factor for a store instruction.

getStoreVectorFactor

Return the adjusted VF if the target cannot use SizeInBytes stores.

getTgtMemIntrinsic

Return true if the intrinsic is a supported memory intrinsic.

getUnrollingPreferences

Get target‐customized preferences for the generic loop unrolling transformation. The caller will initialize UP with the current target‐independent defaults.

getVPLegalizationStrategy

Return how the target needs this vector‐predicated operation transformed.

getVScaleForTuning

Return the vscale value used to tune the cost model.

getValueUniformity

Get target‐specific uniformity information for a value.

getVectorInstrCost

Return the expected cost of vector Insert and Extract.

hasActiveVectorLength

@{ Return true if the target supports the %evl parameter of VP intrinsics.

hasArmWideBranch

Return whether a 32‐bit branch instruction is available in Arm or Thumb.

hasBranchDivergence

Return true if branch divergence exists.

hasConditionalLoadStoreForType

Return true if the target supports fault‐suppressing predicated load/store.

hasDivRemOp

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

hasVolatileVariant

Return true if the memory access I has a volatile variant.

haveFastClmul

Return true if the hardware has a fast carry‐less multiplication instruction.

haveFastSqrt

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

instCombineIntrinsic

Combine a target‐specific intrinsic during InstCombine.

invalidate

Handle the invalidation of this information.

isElementTypeLegalForScalableVector

Return true if the given type is supported for scalable vectors.

isExpensiveToSpeculativelyExecute

Return true if I is too expensive to speculatively execute.

isFCmpOrdCheaperThanFCmpZero

Return true if an FP NaN check is cheaper than comparing against 0.0.

isFPVectorizationPotentiallyUnsafe

Return true if auto‐vectorizing FP ops may change scalar FP semantics.

isHardwareLoopProfitable

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

isIndexedLoadLegal

Return true if the specified indexed load for the given type is legal.

isIndexedStoreLegal

Return true if the specified indexed store for the given type is legal.

isLSRCostLess

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

isLegalAddImmediate

Return true if Imm is a legal immediate operand of an add.

isLegalAddScalableImmediate

Return true if adding Imm scaled by vscale is a legal add immediate.

isLegalAddressingMode

Return true if the given addressing mode is legal for a load/store of Ty.

isLegalAltInstr

Return true if an alternating‐opcode pattern can be a single instruction.

isLegalBroadcastLoad

Return true if the target supports broadcasting a load to a vector.

isLegalICmpImmediate

Return true if Imm is a legal immediate operand of an icmp.

isLegalInterleavedAccessType

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

isLegalMaskedCompressStore

Return true if the target supports masked compress store.

isLegalMaskedExpandLoad

Return true if the target supports masked expand load.

isLegalMaskedGather

Return true if the target supports masked gather.

isLegalMaskedLoad

Return true if the target supports masked load.

isLegalMaskedScatter

Return true if the target supports masked scatter.

isLegalMaskedStore

Return true if the target supports masked store.

isLegalMaskedVectorHistogram

Return true if the target supports masked vector histograms.

isLegalNTLoad

Return true if the target supports nontemporal load.

isLegalNTStore

Return true if the target supports nontemporal store.

isLegalStridedLoadStore

Return true if the target supports strided load.

isLegalToVectorizeLoad

Return true if the load instruction is legal to vectorize.

isLegalToVectorizeLoadChain

Return true if it is legal to vectorize the given load chain.

isLegalToVectorizeReduction

Return true if it is legal to vectorize the given reduction kind.

isLegalToVectorizeStore

Return true if the store instruction is legal to vectorize.

isLegalToVectorizeStoreChain

Return true if it is legal to vectorize the given store chain.

isLoweredToCall

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

isMultiversionedFunction

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

isNoopAddrSpaceCast

Return true if casting from FromAS to ToAS is a no‐op.

isNumRegsMajorCostOfLSR

Return true if LSR should treat the number of registers as the major cost.

isProfitableLSRChainElement

Return true if LSR should not optimize a chain that includes I.

isProfitableToHoist

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

isProfitableToSinkOperands

Return true if sinking operands of I into I's block is profitable.

isSingleThreaded

Return true if the target is known to be single‐threaded.

isTargetIntrinsicWithOverloadTypeAtArg

Identify if the vector form of the intrinsic is overloaded at OpdIdx.

isTargetIntrinsicWithScalarOpAtArg

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

isTargetIntrinsicWithStructReturnOverloadAtField

Identify if a struct‐returning vector intrinsic is overloaded at RetIdx.

isTruncateFree

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

isTypeLegal

Return true if this type is legal.

isUniform

Determine if an instruction with Custom uniformity can be proven uniform based on which operands are uniform.

isValidAddrSpaceCast

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

isVectorShiftByScalarCheap

Return true if a uniform scalar shift is much cheaper than a per‐lane one.

preferAlternateOpcodeVectorization

Return true if SLP should use alternate‐opcode vectorization.

preferEpilogueVectorization

Return true if a scalar epilogue should still be considered for vectorization.

preferFixedOverScalableIfEqualCost

Return true if equal‐cost fixed‐width vectorization is preferred.

preferInLoopReduction

Return true if reductions of Kind should stay inside the loop.

preferPredicatedReductionSelect

Return true if a predicated reduction select should stay in the loop.

preferSLPInstCountCheck

Return true if SLP should apply the 2‐element instruction‐count check.

preferTailFoldingOverEpilogue

Query the target whether it would be preferred to create a tail‐folded vector loop, which can avoid the need to emit a scalar epilogue loop.

preferToKeepConstantsAttached

Return true if complex constants should stay attached to Inst.

prefersVectorizedAddressing

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

rewriteIntrinsicWithAddressSpace

Rewrite intrinsic II so OldV is replaced by address‐space‐cast NewV.

shouldBuildLookupTables

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

shouldBuildLookupTablesForConstant

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

shouldBuildRelLookupTables

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

shouldConsiderAddressTypePromotion

Return true if address type promotion should be considered for I.

shouldConsiderVectorizationRegPressure

Return true if VFs that exceed register pressure should be discarded.

shouldCopyAttributeWhenOutliningFrom

Return true if Attr should be copied onto a function outlined from Caller.

shouldDropLSRSolutionIfLessProfitable

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

shouldExpandReduction

Return true if the reduction intrinsic should be expanded to shuffles.

shouldMaximizeVectorBandwidth

Return true if VF should match the smallest element type to a register.

shouldPrefetchAddressSpace

Return true if the target wants a prefetch in address space AS.

shouldTreatInstructionLikeSelect

Return true if SelectOpt should treat I like a select.

simplifyDemandedUseBitsIntrinsic

Can be used to implement target‐specific instruction combining.

simplifyDemandedVectorEltsIntrinsic

Can be used to implement target‐specific instruction combining.

supportsEfficientVectorElementLoadStore

Return true if vector element load/store is cheap enough to skip insert/extract.

supportsScalableVectors

Return true if the target supports scalable vectors.

supportsTailCallFor

If target supports tail call on CB

supportsTailCalls

If the target supports tail calls.

useAA

Return true if alias analysis should be used in target‐specific transforms.

useColdCCForColdCall

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

useFastCCForInternalCall

Return true if the input function is internal, should use fastcc calling convention.

Static Member Functions

Name

Description

commonOperandInfo

Collect common data between two OperandValueInfo inputs.

getCastContextHint

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

getOpcodeForPartialReductionExtendKind

Get the cast opcode for an extension kind.

getOperandInfo

Collect properties of V used in cost analysis, e.g. OP_PowerOf2.

getPartialReductionExtendKind

getPartialReductionExtendKind overloads

getVectorInstrContextHint

Calculates a VectorInstrContext from I.

requiresOrderedReduction

A helper function to determine the type of reduction algorithm used for a given Opcode and set of FastMathFlags FMF.

Non-Member Functions

Name

Description

getCallsiteCost

Return the cost associated with a callsite, including parameter passing and the call/return instruction.

Created with MrDocs