diff options
Diffstat (limited to 'llvm/lib/Target/X86/X86TargetTransformInfo.h')
-rw-r--r-- | llvm/lib/Target/X86/X86TargetTransformInfo.h | 119 |
1 files changed, 70 insertions, 49 deletions
diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.h b/llvm/lib/Target/X86/X86TargetTransformInfo.h index b9c2dbd78058..d462e1f96ca2 100644 --- a/llvm/lib/Target/X86/X86TargetTransformInfo.h +++ b/llvm/lib/Target/X86/X86TargetTransformInfo.h @@ -16,11 +16,9 @@ #ifndef LLVM_LIB_TARGET_X86_X86TARGETTRANSFORMINFO_H #define LLVM_LIB_TARGET_X86_X86TARGETTRANSFORMINFO_H -#include "X86.h" #include "X86TargetMachine.h" #include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/CodeGen/BasicTTIImpl.h" -#include "llvm/CodeGen/TargetLowering.h" namespace llvm { @@ -107,9 +105,9 @@ public: /// \name Cache TTI Implementation /// @{ llvm::Optional<unsigned> getCacheSize( - TargetTransformInfo::CacheLevel Level) const; + TargetTransformInfo::CacheLevel Level) const override; llvm::Optional<unsigned> getCacheAssociativity( - TargetTransformInfo::CacheLevel Level) const; + TargetTransformInfo::CacheLevel Level) const override; /// @} /// \name Vector TTI Implementations @@ -121,76 +119,90 @@ public: unsigned getMaxInterleaveFactor(unsigned VF); int getArithmeticInstrCost( unsigned Opcode, Type *Ty, + TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput, TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue, TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue, TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None, TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None, ArrayRef<const Value *> Args = ArrayRef<const Value *>(), const Instruction *CxtI = nullptr); - int getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp); + int getShuffleCost(TTI::ShuffleKind Kind, VectorType *Tp, int Index, + VectorType *SubTp); int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, + TTI::TargetCostKind CostKind, const Instruction *I = nullptr); int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, + TTI::TargetCostKind CostKind, const Instruction *I = nullptr); int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index); + unsigned getScalarizationOverhead(VectorType *Ty, const APInt &DemandedElts, + bool Insert, bool Extract); int getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment, - unsigned AddressSpace, const Instruction *I = nullptr); - int getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, - unsigned AddressSpace); - int getGatherScatterOpCost(unsigned Opcode, Type *DataTy, Value *Ptr, - bool VariableMask, unsigned Alignment); + unsigned AddressSpace, + TTI::TargetCostKind CostKind, + const Instruction *I = nullptr); + int getMaskedMemoryOpCost( + unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, + TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency); + int getGatherScatterOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr, + bool VariableMask, Align Alignment, + TTI::TargetCostKind CostKind, + const Instruction *I); int getAddressComputationCost(Type *PtrTy, ScalarEvolution *SE, const SCEV *Ptr); unsigned getAtomicMemIntrinsicMaxElementSize() const; - int getIntrinsicInstrCost(Intrinsic::ID IID, Type *RetTy, - ArrayRef<Type *> Tys, FastMathFlags FMF, - unsigned ScalarizationCostPassed = UINT_MAX); - int getIntrinsicInstrCost(Intrinsic::ID IID, Type *RetTy, - ArrayRef<Value *> Args, FastMathFlags FMF, - unsigned VF = 1); - - int getArithmeticReductionCost(unsigned Opcode, Type *Ty, - bool IsPairwiseForm); - - int getMinMaxReductionCost(Type *Ty, Type *CondTy, bool IsPairwiseForm, - bool IsUnsigned); - - int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, - unsigned Factor, ArrayRef<unsigned> Indices, - unsigned Alignment, unsigned AddressSpace, - bool UseMaskForCond = false, - bool UseMaskForGaps = false); - int getInterleavedMemoryOpCostAVX512(unsigned Opcode, Type *VecTy, - unsigned Factor, ArrayRef<unsigned> Indices, - unsigned Alignment, unsigned AddressSpace, - bool UseMaskForCond = false, - bool UseMaskForGaps = false); - int getInterleavedMemoryOpCostAVX2(unsigned Opcode, Type *VecTy, - unsigned Factor, ArrayRef<unsigned> Indices, - unsigned Alignment, unsigned AddressSpace, - bool UseMaskForCond = false, - bool UseMaskForGaps = false); + int getTypeBasedIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, + TTI::TargetCostKind CostKind); + int getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, + TTI::TargetCostKind CostKind); + + int getArithmeticReductionCost(unsigned Opcode, VectorType *Ty, + bool IsPairwiseForm, + TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency); + + int getMinMaxCost(Type *Ty, Type *CondTy, bool IsUnsigned); + + int getMinMaxReductionCost(VectorType *Ty, VectorType *CondTy, + bool IsPairwiseForm, bool IsUnsigned, + TTI::TargetCostKind CostKind); + + int getInterleavedMemoryOpCost( + unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices, + Align Alignment, unsigned AddressSpace, + TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency, + bool UseMaskForCond = false, bool UseMaskForGaps = false); + int getInterleavedMemoryOpCostAVX512( + unsigned Opcode, FixedVectorType *VecTy, unsigned Factor, + ArrayRef<unsigned> Indices, Align Alignment, unsigned AddressSpace, + TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency, + bool UseMaskForCond = false, bool UseMaskForGaps = false); + int getInterleavedMemoryOpCostAVX2( + unsigned Opcode, FixedVectorType *VecTy, unsigned Factor, + ArrayRef<unsigned> Indices, Align Alignment, unsigned AddressSpace, + TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency, + bool UseMaskForCond = false, bool UseMaskForGaps = false); int getIntImmCost(int64_t); - int getIntImmCost(const APInt &Imm, Type *Ty); + int getIntImmCost(const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind); - unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands); + unsigned getCFInstrCost(unsigned Opcode, TTI::TargetCostKind CostKind); - int getIntImmCostInst(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty); + int getIntImmCostInst(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty, + TTI::TargetCostKind CostKind); int getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, - Type *Ty); + Type *Ty, TTI::TargetCostKind CostKind); bool isLSRCostLess(TargetTransformInfo::LSRCost &C1, TargetTransformInfo::LSRCost &C2); bool canMacroFuseCmp(); - bool isLegalMaskedLoad(Type *DataType, MaybeAlign Alignment); - bool isLegalMaskedStore(Type *DataType, MaybeAlign Alignment); + bool isLegalMaskedLoad(Type *DataType, Align Alignment); + bool isLegalMaskedStore(Type *DataType, Align Alignment); bool isLegalNTLoad(Type *DataType, Align Alignment); bool isLegalNTStore(Type *DataType, Align Alignment); - bool isLegalMaskedGather(Type *DataType, MaybeAlign Alignment); - bool isLegalMaskedScatter(Type *DataType, MaybeAlign Alignment); + bool isLegalMaskedGather(Type *DataType, Align Alignment); + bool isLegalMaskedScatter(Type *DataType, Align Alignment); bool isLegalMaskedExpandLoad(Type *DataType); bool isLegalMaskedCompressStore(Type *DataType); bool hasDivRemOp(Type *DataType, bool IsSigned); @@ -203,11 +215,20 @@ public: TTI::MemCmpExpansionOptions enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const; bool enableInterleavedAccessVectorization(); + + /// Allow vectorizers to form reduction intrinsics in IR. The IR is expanded + /// into shuffles and vector math/logic by the backend + /// (see TTI::shouldExpandReduction) + bool useReductionIntrinsic(unsigned Opcode, Type *Ty, + TTI::ReductionFlags Flags) const { + return true; + } + private: int getGSScalarCost(unsigned Opcode, Type *DataTy, bool VariableMask, - unsigned Alignment, unsigned AddressSpace); - int getGSVectorCost(unsigned Opcode, Type *DataTy, Value *Ptr, - unsigned Alignment, unsigned AddressSpace); + Align Alignment, unsigned AddressSpace); + int getGSVectorCost(unsigned Opcode, Type *DataTy, const Value *Ptr, + Align Alignment, unsigned AddressSpace); /// @} }; |