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 {
48 if (cast<VectorType>(VecTy)->isScalable())
51 if (!cast<VectorType>(VecTy)->getElementType()->isIntegerTy())
62 unsigned HexagonTTIImpl::getTypeNumElements(
Type *Ty)
const {
66 "Expecting scalar type");
98 return useHVX() ? 32 : 0;
103 return useHVX() ? 2 : 0;
140 unsigned ScalarizationCostPassed) {
141 if (ID == Intrinsic::bswap) {
146 ScalarizationCostPassed);
165 if (useHVX() && isTypeForHVX(VecTy)) {
167 assert(RegWidth &&
"Non-zero vector register width expected");
169 if (VecWidth % RegWidth == 0)
170 return VecWidth / RegWidth;
172 const Align RegAlign(RegWidth / 8);
173 if (!Alignment || *Alignment > RegAlign)
174 Alignment = RegAlign;
176 unsigned AlignWidth = 8 * Alignment->value();
177 unsigned NumLoads =
alignTo(VecWidth, AlignWidth) / AlignWidth;
188 unsigned AlignWidth = 8 * BoundAlignment.
value();
189 unsigned NumLoads =
alignTo(VecWidth, AlignWidth) / AlignWidth;
190 if (Alignment ==
Align(4) || Alignment ==
Align(8))
191 return Cost * NumLoads;
194 unsigned LogA =
Log2(BoundAlignment);
195 return (3 - LogA) * Cost * NumLoads;
212 Value *Ptr,
bool VariableMask,
unsigned Alignment) {
219 unsigned Alignment,
unsigned AddressSpace,
bool UseMaskForCond,
220 bool UseMaskForGaps) {
221 if (Indices.
size() != Factor || UseMaskForCond || UseMaskForGaps)
223 Alignment, AddressSpace,
224 UseMaskForCond, UseMaskForGaps);
233 if (Opcode == Instruction::FCmp)
234 return LT.first + FloatFactor * getTypeNumElements(ValTy);
246 if (LT.second.isFloatingPoint())
247 return LT.first + FloatFactor * getTypeNumElements(Ty);
250 Opd1PropInfo, Opd2PropInfo, Args, CxtI);
261 return std::max(SrcLT.first, DstLT.first) + FloatFactor * (SrcN + DstN);
268 Type *ElemTy = Val->
isVectorTy() ? cast<VectorType>(Val)->getElementType()
270 if (Opcode == Instruction::InsertElement) {
272 unsigned Cost = (Index != 0) ? 2 : 0;
279 if (Opcode == Instruction::ExtractElement)
297 auto isCastFoldedIntoLoad = [
this](
const CastInst *CI) ->
bool {
298 if (!CI->isIntegerCast())
305 if (DBW != 32 || SBW >= DBW)
315 if (
const CastInst *CI = dyn_cast<const CastInst>(U))
316 if (isCastFoldedIntoLoad(CI))
unsigned Log2(Align A)
Returns the log2 of the alignment.
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. ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
unsigned getScalarizationOverhead(Type *Ty, bool Insert, bool Extract)
int getUserCost(const User *U, ArrayRef< const Value *> Operands)
Align valueOrOne() const
For convenience, returns a valid alignment or 1 if undefined.
bool shouldBuildLookupTables() const
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.
unsigned getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment, unsigned AddressSpace, const Instruction *I=nullptr)
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)
An instruction for reading from memory.
TypeSize getTypeSizeInBits(Type *Ty) const
Size examples:
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 minimum 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.
mir Rename Register Operands
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 *>(), const Instruction *CxtI=nullptr)
unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, const Instruction *I)
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)
uint64_t value() const
This is a hole in the type system and should not be abused.
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)
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
This struct is a compact representation of a valid (non-zero power of two) alignment.
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
Align max(MaybeAlign Lhs, Align Rhs)
This struct is a compact representation of a valid (power of two) or undefined (0) alignment...
unsigned getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment, unsigned AddressSpace, const Instruction *I=nullptr)
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 * >(), const Instruction *CxtI=nullptr)
unsigned getVectorNumElements() const
Class to represent vector types.
unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, const Instruction *I)
unsigned getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy, ArrayRef< Value *> Args, FastMathFlags FMF, unsigned VF)
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
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)
unsigned getCacheLineSize() const override
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).
unsigned getPrefetchDistance() const override
— Vector TTI end —
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.