28 #define DEBUG_TYPE "hexagontti" 35 cl::desc(
"Control lookup table emission on Hexagon target"));
42 bool HexagonTTIImpl::useHVX()
const {
46 bool HexagonTTIImpl::isTypeForHVX(
Type *VecTy)
const {
49 if (!cast<VectorType>(VecTy)->getElementType()->isIntegerTy())
60 unsigned HexagonTTIImpl::getTypeNumElements(
Type *Ty)
const {
64 "Expecting scalar type");
96 return useHVX() ? 32 : 0;
101 return useHVX() ? 2 : 0;
138 unsigned ScalarizationCostPassed) {
139 if (ID == Intrinsic::bswap) {
144 ScalarizationCostPassed);
161 if (useHVX() && isTypeForHVX(VecTy)) {
163 Alignment = std::min(Alignment, RegWidth/8);
165 if (VecWidth % RegWidth == 0)
166 return VecWidth / RegWidth;
168 unsigned AlignWidth = 8 *
std::max(1u, Alignment);
169 unsigned NumLoads =
alignTo(VecWidth, AlignWidth) / AlignWidth;
177 Alignment = std::min(Alignment, 8u);
178 unsigned AlignWidth = 8 *
std::max(1u, Alignment);
179 unsigned NumLoads =
alignTo(VecWidth, AlignWidth) / AlignWidth;
180 if (Alignment == 4 || Alignment == 8)
181 return Cost * NumLoads;
183 unsigned LogA =
Log2_32(Alignment);
184 return (3 - LogA) * Cost * NumLoads;
201 Value *Ptr,
bool VariableMask,
unsigned Alignment) {
208 unsigned Alignment,
unsigned AddressSpace,
bool UseMaskForCond,
209 bool UseMaskForGaps) {
210 if (Indices.
size() != Factor || UseMaskForCond || UseMaskForGaps)
212 Alignment, AddressSpace,
213 UseMaskForCond, UseMaskForGaps);
214 return getMemoryOpCost(Opcode, VecTy, Alignment, AddressSpace,
nullptr);
221 if (Opcode == Instruction::FCmp)
222 return LT.first + FloatFactor * getTypeNumElements(ValTy);
233 if (LT.second.isFloatingPoint())
234 return LT.first + FloatFactor * getTypeNumElements(Ty);
237 Opd1PropInfo, Opd2PropInfo, Args);
248 return std::max(SrcLT.first, DstLT.first) + FloatFactor * (SrcN + DstN);
255 Type *ElemTy = Val->
isVectorTy() ? cast<VectorType>(Val)->getElementType()
257 if (Opcode == Instruction::InsertElement) {
259 unsigned Cost = (Index != 0) ? 2 : 0;
266 if (Opcode == Instruction::ExtractElement)
284 auto isCastFoldedIntoLoad = [
this](
const CastInst *CI) ->
bool {
285 if (!CI->isIntegerCast())
292 if (DBW != 32 || SBW >= DBW)
302 if (
const CastInst *CI = dyn_cast<const CastInst>(U))
303 if (isCastFoldedIntoLoad(CI))
unsigned getOperandsScalarizationOverhead(ArrayRef< const Value *> Args, unsigned VF)
unsigned getSmallConstantTripCount(const Loop *L)
Returns the maximum trip count of the loop if it is a single-exit loop and we can compute a small max...
A parsed version of the target data layout string in and methods for querying it. ...
unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty, 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 * >())
unsigned getScalarizationOverhead(Type *Ty, bool Insert, bool Extract)
unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty, 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 *>())
int getUserCost(const User *U, ArrayRef< const Value *> Operands)
bool shouldBuildLookupTables() const
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
unsigned getMinimumVF(unsigned ElemWidth) const
This class represents lattice values for constants.
unsigned getScalarizationOverhead(Type *Ty, bool Insert, bool Extract)
Estimate the overhead of scalarizing an instruction.
The main scalar evolution driver.
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
unsigned getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, unsigned Alignment, unsigned AddressSpace, bool UseMaskForCond=false, bool UseMaskForGaps=false)
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
An instruction for reading from memory.
bool isVectorTy() const
True if this is an instance of VectorType.
unsigned getL1CacheLineSize() const
unsigned getSmallConstantMaxTripCount(const Loop *L)
Returns the upper bound of the loop trip count as a normal unsigned value.
unsigned getIntrinsicInstrCost(Intrinsic::ID IID, Type *RetTy, ArrayRef< Value * > Args, FastMathFlags FMF, unsigned VF=1)
Get intrinsic cost based on arguments.
unsigned getBitWidth() const
Return the number of bits in the Vector type.
unsigned getOperandsScalarizationOverhead(ArrayRef< const Value * > Args, unsigned VF)
Estimate the overhead of scalarizing an instructions unique non-constant operands.
This is the base class for all instructions that perform data casts.
bool isFloatingPointTy() const
Return true if this is one of the six floating-point types.
unsigned getGatherScatterOpCost(unsigned Opcode, Type *DataTy, Value *Ptr, bool VariableMask, unsigned Alignment)
bool isIntegerTy() const
True if this is an instance of IntegerType.
unsigned getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, unsigned AddressSpace, const Instruction *I=nullptr)
unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, const Instruction *I)
unsigned getSizeInBits() const
Return the size of the specified value type in bits.
unsigned getL1PrefetchDistance() const
unsigned getMinVectorRegisterBitWidth() const
TargetLoweringBase::LegalizeTypeAction getPreferredVectorAction(MVT VT) const override
Return the preferred vector type legalization action.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
unsigned getAddressComputationCost(Type *Tp, ScalarEvolution *SE, const SCEV *S)
initializer< Ty > init(const Ty &Val)
The instances of the Type class are immutable: once they are created, they are never changed...
unsigned getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, unsigned Alignment, unsigned AddressSpace, bool UseMaskForCond=false, bool UseMaskForGaps=false)
size_t size() const
size - Get the array size.
unsigned getRegisterBitWidth(bool Vector) const
unsigned getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp)
unsigned getCallInstrCost(Function *F, Type *RetTy, ArrayRef< Type *> Tys)
unsigned getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index)
bool shouldFavorPostInc() const
Bias LSR towards creating post-increment opportunities.
bool isHVXVectorType(MVT VecTy, bool IncludeBool=false) const
unsigned getCacheLineSize() const
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
unsigned getVectorNumElements() const
Class to represent vector types.
unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, const Instruction *I)
unsigned getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, unsigned AddressSpace, const Instruction *I=nullptr)
unsigned getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy, ArrayRef< Value *> Args, FastMathFlags FMF, unsigned VF)
uint64_t getTypeSizeInBits(Type *Ty) const
Size examples:
unsigned getPrefetchDistance() const
— Vector TTI end —
unsigned getVectorLength() const
This class represents an analyzed expression in the program.
unsigned getNumberOfRegisters(bool vector) const
— Vector TTI begin —
Represents a single loop in the control flow graph.
unsigned getMaxInterleaveFactor(unsigned VF)
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
unsigned getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, const Instruction *I=nullptr)
static EVT getEVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.
unsigned getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, unsigned AddressSpace)
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, TTI::UnrollingPreferences &UP)
Type * getElementType() const
bool hasOneUse() const
Return true if there is exactly one user of this value.
Convenience struct for specifying and reasoning about fast-math flags.
unsigned getCallInstrCost(Function *F, Type *RetTy, ArrayRef< Type * > Tys)
Compute a cost of the given call instruction.
TTI::PopcntSupportKind getPopcntSupport(unsigned IntTyWidthInBit) const
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
std::pair< int, MVT > getTypeLegalizationCost(const DataLayout &DL, Type *Ty) const
Estimate the cost of type-legalization and the legalized type.