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:
168 ST->hasExtLSX() && VTy &&
isPowerOf2_32(VTy->getNumElements())) {
169 unsigned Size = VTy->getPrimitiveSizeInBits().getFixedValue();
170 EVT VT = getTLI()->getValueType(
DL, Src);
172 getTLI()->getTypeAction(Src->getContext(), VT) ==
174 getTLI()->allowsMemoryAccessForAlignment(Src->getContext(),
DL, VT,
190 Options.MaxNumLoads = TLI->getMaxExpandSizeMemcmp(OptSize);
192 Options.AllowOverlappingLoads =
true;
196 Options.LoadSizes = {8, 4, 2, 1};
197 Options.AllowedTailExpansions = {3, 5, 6};
200 Options.AllowedTailExpansions = {3};
212 int ISD = TLI->InstructionOpcodeToISD(Opcode);
342 if (ST->hasExtLSX()) {
344 if (
auto KindCost = Entry->Cost[CostKind])
345 return LT.first * *KindCost;
405 {
ISD::OR, MVT::v16i16, {1, 1}},
427 if (ST->hasExtLASX()) {
428 if (
const auto *Entry =
430 if (
auto KindCost = Entry->Cost[CostKind])
431 return LT.first * *KindCost;
460 if (
auto KindCost = Entry->Cost[CostKind])
461 return LT.first * *KindCost;
489 if (
auto KindCost = Entry->Cost[CostKind])
490 return LT.first * *KindCost;
502 unsigned Bits = VTy->getPrimitiveSizeInBits().getFixedValue();
503 return (Bits == 128 && ST->hasExtLSX()) || (Bits == 256 && ST->hasExtLASX());
511 if (Opcode == Instruction::ExtractElement && Index == 0 &&
524 unsigned EltBits = SrcTy->getScalarSizeInBits();
525 bool Is128 = SrcTy->getPrimitiveSizeInBits().getFixedValue() == 128;
534 if (Is128 && EltBits >= 32)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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),...
TTI::ShuffleKind improveShuffleKindFromMask(TTI::ShuffleKind Kind, ArrayRef< int > Mask, VectorType *SrcTy, int &Index, VectorType *&SubTy) const
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
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *DstTy, VectorType *SrcTy, TTI::TargetCostKind CostKind, ArrayRef< int > Mask, int Index, VectorType *SubTp, ArrayRef< const Value * > Args={}, const Instruction *CtxI=nullptr, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
std::pair< InstructionCost, MVT > getTypeLegalizationCost(Type *Ty) const
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, TTI::OperandValueInfo OpInfo={TTI::OK_AnyValue, TTI::OP_None}, const Instruction *I=nullptr) const override
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
InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, TTI::OperandValueInfo OpInfo={TTI::OK_AnyValue, TTI::OP_None}, const Instruction *I=nullptr) const override
const char * getRegisterClassName(unsigned ClassID) const override
unsigned getNumberOfRegisters(unsigned ClassID) const override
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *DstTy, VectorType *SrcTy, TTI::TargetCostKind CostKind, ArrayRef< int > Mask, int Index, VectorType *SubTp, ArrayRef< const Value * > Args={}, const Instruction *CxtI=nullptr, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) 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.
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
LLVM Value Representation.
Base class of all SIMD vector types.
#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.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
This struct is a compact representation of a valid (non-zero power of two) alignment.