29 #define DEBUG_TYPE "hexagontti" 36 cl::desc(
"Control lookup table emission on Hexagon target"));
43 bool HexagonTTIImpl::useHVX()
const {
47 bool HexagonTTIImpl::isTypeForHVX(
Type *VecTy)
const {
50 if (!cast<VectorType>(VecTy)->getElementType()->isIntegerTy())
61 unsigned HexagonTTIImpl::getTypeNumElements(
Type *Ty)
const {
65 "Expecting scalar type");
97 return useHVX() ? 32 : 0;
102 return useHVX() ? 2 : 0;
139 unsigned ScalarizationCostPassed) {
145 ScalarizationCostPassed);
162 if (useHVX() && isTypeForHVX(VecTy)) {
164 Alignment = std::min(Alignment, RegWidth/8);
166 if (VecWidth % RegWidth == 0)
167 return VecWidth / RegWidth;
169 unsigned AlignWidth = 8 *
std::max(1u, Alignment);
170 unsigned NumLoads =
alignTo(VecWidth, AlignWidth) / AlignWidth;
178 Alignment = std::min(Alignment, 8u);
179 unsigned AlignWidth = 8 *
std::max(1u, Alignment);
180 unsigned NumLoads =
alignTo(VecWidth, AlignWidth) / AlignWidth;
181 if (Alignment == 4 || Alignment == 8)
182 return Cost * NumLoads;
184 unsigned LogA =
Log2_32(Alignment);
185 return (3 - LogA) * Cost * NumLoads;
202 Value *Ptr,
bool VariableMask,
unsigned Alignment) {
209 unsigned Alignment,
unsigned AddressSpace,
bool UseMaskForCond,
210 bool UseMaskForGaps) {
211 if (Indices.
size() != Factor || UseMaskForCond || UseMaskForGaps)
213 Alignment, AddressSpace,
214 UseMaskForCond, UseMaskForGaps);
215 return getMemoryOpCost(Opcode, VecTy, Alignment, AddressSpace,
nullptr);
222 if (Opcode == Instruction::FCmp)
223 return LT.first + FloatFactor * getTypeNumElements(ValTy);
234 if (LT.second.isFloatingPoint())
235 return LT.first + FloatFactor * getTypeNumElements(Ty);
238 Opd1PropInfo, Opd2PropInfo, Args);
249 return std::max(SrcLT.first, DstLT.first) + FloatFactor * (SrcN + DstN);
256 Type *ElemTy = Val->
isVectorTy() ? cast<VectorType>(Val)->getElementType()
258 if (Opcode == Instruction::InsertElement) {
260 unsigned Cost = (Index != 0) ? 2 : 0;
267 if (Opcode == Instruction::ExtractElement)
285 auto isCastFoldedIntoLoad = [
this](
const CastInst *CI) ->
bool {
286 if (!CI->isIntegerCast())
293 if (DBW != 32 || SBW >= DBW)
303 if (
const CastInst *CI = dyn_cast<const CastInst>(U))
304 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.