27#define DEBUG_TYPE "loongarchtti"
52 case LoongArchRegisterClass::GPRRC:
55 case LoongArchRegisterClass::FPRRC:
56 return ST->hasBasicF() ? 32 : 0;
57 case LoongArchRegisterClass::VRRC:
58 return ST->hasExtLSX() ? 32 : 0;
66 return LoongArchRegisterClass::VRRC;
68 return LoongArchRegisterClass::GPRRC;
71 if ((ScalarTy->
isFloatTy() && ST->hasBasicF()) ||
73 return LoongArchRegisterClass::FPRRC;
76 return LoongArchRegisterClass::GPRRC;
81 bool HasUnorderedReductions)
const {
82 return ST->getMaxInterleaveFactor();
87 case LoongArchRegisterClass::GPRRC:
88 return "LoongArch::GPRRC";
89 case LoongArchRegisterClass::FPRRC:
90 return "LoongArch::FPRRC";
91 case LoongArchRegisterClass::VRRC:
92 return "LoongArch::VRRC";
100 switch (
II->getIntrinsicID()) {
103 case Intrinsic::vector_reduce_add:
104 case Intrinsic::vector_reduce_and:
105 case Intrinsic::vector_reduce_or:
106 case Intrinsic::vector_reduce_smax:
107 case Intrinsic::vector_reduce_smin:
108 case Intrinsic::vector_reduce_umax:
109 case Intrinsic::vector_reduce_umin:
110 case Intrinsic::vector_reduce_xor:
127 ST->hasExtLSX() && VTy &&
isPowerOf2_32(VTy->getNumElements())) {
128 unsigned Size = VTy->getPrimitiveSizeInBits().getFixedValue();
129 EVT VT = getTLI()->getValueType(
DL, Src);
131 getTLI()->getTypeAction(Src->getContext(), VT) ==
133 getTLI()->allowsMemoryAccessForAlignment(Src->getContext(),
DL, VT,
149 Options.MaxNumLoads = TLI->getMaxExpandSizeMemcmp(OptSize);
151 Options.AllowOverlappingLoads =
true;
155 Options.LoadSizes = {8, 4, 2, 1};
156 Options.AllowedTailExpansions = {3, 5, 6};
159 Options.AllowedTailExpansions = {3};
172 int ISD = TLI->InstructionOpcodeToISD(Opcode);
302 if (ST->hasExtLSX()) {
304 if (
auto KindCost = Entry->Cost[CostKind])
305 return LT.first * *KindCost;
365 {
ISD::OR, MVT::v16i16, {1, 1}},
387 if (ST->hasExtLASX()) {
388 if (
const auto *Entry =
390 if (
auto KindCost = Entry->Cost[CostKind])
391 return LT.first * *KindCost;
420 if (
auto KindCost = Entry->Cost[CostKind])
421 return LT.first * *KindCost;
449 if (
auto KindCost = Entry->Cost[CostKind])
450 return LT.first * *KindCost;
454 Args, CxtI, TLibInfo, Scalars);
462 unsigned Bits = VTy->getPrimitiveSizeInBits().getFixedValue();
463 return (Bits == 128 && ST->hasExtLSX()) || (Bits == 256 && ST->hasExtLASX());
471 if (Opcode == Instruction::ExtractElement && Index == 0 &&
484 unsigned EltBits = SrcTy->getScalarSizeInBits();
485 bool Is128 = SrcTy->getPrimitiveSizeInBits().getFixedValue() == 128;
494 if (Is128 && EltBits >= 32)
506 unsigned Opcode,
Type *InputTypeA,
Type *InputTypeB,
Type *AccumType,
515 if (Opcode != Instruction::Add)
524 if (InputTypeA != InputTypeB)
527 if (!BinOp || *BinOp != Instruction::Mul)
543 auto TC = TLI->getTypeConversion(AccumVectorType->
getContext(),
552 if (TLI->getTypeAction(AccumVectorType->
getContext(), TC.second) !=
558 std::pair<InstructionCost, MVT> AccumLT =
560 std::pair<InstructionCost, MVT> InputLT =
567 unsigned Bits = AccumLT.second.getSizeInBits();
568 if (AccumLT.second.getScalarType() == MVT::i32 &&
569 InputLT.second.getScalarType() == MVT::i8)
570 if ((ST->hasExtLASX() && Bits <= 256) || (ST->hasExtLSX() && Bits <= 128))
574 AccumType, VF, OpAExtend, OpBExtend,
575 BinOp, CostKind, FMF);
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 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 getPartialReductionCost(unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType, ElementCount VF, TTI::PartialReductionExtendKind OpAExtend, TTI::PartialReductionExtendKind OpBExtend, std::optional< unsigned > BinOp, TTI::TargetCostKind CostKind, std::optional< FastMathFlags > FMF) 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
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
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 TargetLibraryInfo *TLibInfo=nullptr, ArrayRef< const Value * > Scalars={}) const override
static InstructionCost getInvalid(CostType Val=0)
A wrapper class for inspecting calls to intrinsic functions.
unsigned getCacheLineSize() const override
unsigned getMaxInterleaveFactor(ElementCount VF, bool HasUnorderedReductions) const override
bool shouldExpandReduction(const IntrinsicInst *II) const override
unsigned getRegisterClassForType(bool Vector, Type *Ty=nullptr) 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 TargetLibraryInfo *TLibInfo=nullptr, ArrayRef< const Value * > Scalars={}) 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
InstructionCost getPartialReductionCost(unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType, ElementCount VF, TTI::PartialReductionExtendKind OpAExtend, TTI::PartialReductionExtendKind OpBExtend, std::optional< unsigned > BinOp, TTI::TargetCostKind CostKind, std::optional< FastMathFlags > FMF) 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
TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const override
Provides information about what library functions are available for the current target.
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.
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
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.
static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
constexpr LeafTy divideCoefficientBy(ScalarTy RHS) const
We do not provide the '/' operator here because division for polynomial types does not work in the sa...
#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.
static LLVM_ABI EVT getEVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.