28#define DEBUG_TYPE "loongarchtti"
32 unsigned LatencyCost = ~0U;
33 unsigned RecipThroughputCost = ~0U;
34 unsigned CodeSizeCost = ~0U;
35 unsigned SizeAndLatencyCost = ~0U;
37 std::optional<unsigned>
45 Cost = RecipThroughputCost;
51 Cost = SizeAndLatencyCost;
83 case LoongArchRegisterClass::GPRRC:
86 case LoongArchRegisterClass::FPRRC:
87 return ST->hasBasicF() ? 32 : 0;
88 case LoongArchRegisterClass::VRRC:
89 return ST->hasExtLSX() ? 32 : 0;
97 return LoongArchRegisterClass::VRRC;
99 return LoongArchRegisterClass::GPRRC;
102 if ((ScalarTy->
isFloatTy() && ST->hasBasicF()) ||
103 (ScalarTy->
isDoubleTy() && ST->hasBasicD())) {
104 return LoongArchRegisterClass::FPRRC;
107 return LoongArchRegisterClass::GPRRC;
112 bool HasUnorderedReductions)
const {
113 return ST->getMaxInterleaveFactor();
118 case LoongArchRegisterClass::GPRRC:
119 return "LoongArch::GPRRC";
120 case LoongArchRegisterClass::FPRRC:
121 return "LoongArch::FPRRC";
122 case LoongArchRegisterClass::VRRC:
123 return "LoongArch::VRRC";
141 switch (
II->getIntrinsicID()) {
144 case Intrinsic::vector_reduce_add:
145 case Intrinsic::vector_reduce_and:
146 case Intrinsic::vector_reduce_or:
147 case Intrinsic::vector_reduce_smax:
148 case Intrinsic::vector_reduce_smin:
149 case Intrinsic::vector_reduce_umax:
150 case Intrinsic::vector_reduce_umin:
151 case Intrinsic::vector_reduce_xor:
163 Options.MaxNumLoads = TLI->getMaxExpandSizeMemcmp(OptSize);
165 Options.AllowOverlappingLoads =
true;
169 Options.LoadSizes = {8, 4, 2, 1};
170 Options.AllowedTailExpansions = {3, 5, 6};
173 Options.AllowedTailExpansions = {3};
185 int ISD = TLI->InstructionOpcodeToISD(Opcode);
315 if (ST->hasExtLSX()) {
317 if (
auto KindCost = Entry->Cost[
CostKind])
318 return LT.first * *KindCost;
378 {
ISD::OR, MVT::v16i16, {1, 1}},
400 if (ST->hasExtLASX()) {
401 if (
const auto *Entry =
403 if (
auto KindCost = Entry->Cost[
CostKind])
404 return LT.first * *KindCost;
433 if (
auto KindCost = Entry->Cost[
CostKind])
434 return LT.first * *KindCost;
462 if (
auto KindCost = Entry->Cost[
CostKind])
463 return LT.first * *KindCost;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static cl::opt< OutputCostKind > CostKind("cost-kind", cl::desc("Target cost kind"), cl::init(OutputCostKind::RecipThroughput), cl::values(clEnumValN(OutputCostKind::RecipThroughput, "throughput", "Reciprocal throughput"), clEnumValN(OutputCostKind::Latency, "latency", "Instruction latency"), clEnumValN(OutputCostKind::CodeSize, "code-size", "Code size"), clEnumValN(OutputCostKind::SizeAndLatency, "size-latency", "Code size and latency"), clEnumValN(OutputCostKind::All, "all", "Print all cost kinds")))
Cost tables and simple lookup functions.
This file defines an InstructionCost class that is used when calculating the cost of an instruction,...
uint64_t IntrinsicInst * II
Represent a constant reference to an array (0 or more elements consecutively in memory),...
InstructionCost getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Opd1Info={TTI::OK_AnyValue, TTI::OP_None}, TTI::OperandValueInfo Opd2Info={TTI::OK_AnyValue, TTI::OP_None}, ArrayRef< const Value * > Args={}, const Instruction *CtxI=nullptr) const override
std::pair< InstructionCost, MVT > getTypeLegalizationCost(Type *Ty) const
A wrapper class for inspecting calls to intrinsic functions.
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const override
unsigned getCacheLineSize() const override
unsigned getMaxInterleaveFactor(ElementCount VF, bool HasUnorderedReductions) const override
bool shouldExpandReduction(const IntrinsicInst *II) const override
InstructionCost getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Op1Info={TTI::OK_AnyValue, TTI::OP_None}, TTI::OperandValueInfo Op2Info={TTI::OK_AnyValue, TTI::OP_None}, ArrayRef< const Value * > Args={}, const Instruction *CxtI=nullptr) const override
unsigned getRegisterClassForType(bool Vector, Type *Ty=nullptr) const override
TTI::MemCmpExpansionOptions enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const override
const char * getRegisterClassName(unsigned ClassID) const override
unsigned getNumberOfRegisters(unsigned ClassID) const override
unsigned getPrefetchDistance() const override
bool enableWritePrefetching() const override
TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const override
static constexpr TypeSize getFixed(ScalarTy ExactSize)
The instances of the Type class are immutable: once they are created, they are never changed.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
ISD namespace - This namespace contains an enum which represents all of the SelectionDAG node types a...
@ ADD
Simple integer binary arithmetic operators.
@ FADD
Simple binary floating point operators.
@ SHL
Shift and rotation operations.
@ AND
Bitwise operators - logical and, logical or, logical xor.
This is an optimization pass for GlobalISel generic memory operations.
const CostTblEntryT< CostType > * CostTableLookup(ArrayRef< CostTblEntryT< CostType > > Tbl, int ISD, MVT Ty)
Find in cost table.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.