forked from OSchip/llvm-project
[TTI] NFC: Change getArithmeticInstrCost to return InstructionCost
This patch migrates the TTI cost interfaces to return an InstructionCost. See this patch for the introduction of the type: https://reviews.llvm.org/D91174 See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2020-November/146408.html Reviewed By: dmgreen Differential Revision: https://reviews.llvm.org/D100317
This commit is contained in:
parent
d84bd951a8
commit
4f42d873c2
|
@ -1036,7 +1036,7 @@ public:
|
|||
/// cases or optimizations based on those values.
|
||||
/// \p CxtI is the optional original context instruction, if one exists, to
|
||||
/// provide even more information.
|
||||
int getArithmeticInstrCost(
|
||||
InstructionCost getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty,
|
||||
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput,
|
||||
OperandValueKind Opd1Info = OK_AnyValue,
|
||||
|
@ -1568,13 +1568,11 @@ public:
|
|||
virtual bool enableWritePrefetching() const = 0;
|
||||
|
||||
virtual unsigned getMaxInterleaveFactor(unsigned VF) = 0;
|
||||
virtual unsigned getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty,
|
||||
TTI::TargetCostKind CostKind,
|
||||
OperandValueKind Opd1Info,
|
||||
OperandValueKind Opd2Info, OperandValueProperties Opd1PropInfo,
|
||||
OperandValueProperties Opd2PropInfo, ArrayRef<const Value *> Args,
|
||||
const Instruction *CxtI = nullptr) = 0;
|
||||
virtual InstructionCost getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
|
||||
OperandValueKind Opd1Info, OperandValueKind Opd2Info,
|
||||
OperandValueProperties Opd1PropInfo, OperandValueProperties Opd2PropInfo,
|
||||
ArrayRef<const Value *> Args, const Instruction *CxtI = nullptr) = 0;
|
||||
virtual InstructionCost getShuffleCost(ShuffleKind Kind, VectorType *Tp,
|
||||
ArrayRef<int> Mask, int Index,
|
||||
VectorType *SubTp) = 0;
|
||||
|
@ -2039,12 +2037,10 @@ public:
|
|||
BlockFrequencyInfo *BFI) override {
|
||||
return Impl.getEstimatedNumberOfCaseClusters(SI, JTSize, PSI, BFI);
|
||||
}
|
||||
unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty,
|
||||
TTI::TargetCostKind CostKind,
|
||||
OperandValueKind Opd1Info,
|
||||
OperandValueKind Opd2Info,
|
||||
OperandValueProperties Opd1PropInfo,
|
||||
OperandValueProperties Opd2PropInfo,
|
||||
InstructionCost getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
|
||||
OperandValueKind Opd1Info, OperandValueKind Opd2Info,
|
||||
OperandValueProperties Opd1PropInfo, OperandValueProperties Opd2PropInfo,
|
||||
ArrayRef<const Value *> Args,
|
||||
const Instruction *CxtI = nullptr) override {
|
||||
return Impl.getArithmeticInstrCost(Opcode, Ty, CostKind, Opd1Info, Opd2Info,
|
||||
|
|
|
@ -441,13 +441,11 @@ public:
|
|||
|
||||
unsigned getMaxInterleaveFactor(unsigned VF) const { return 1; }
|
||||
|
||||
unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty,
|
||||
TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind Opd1Info,
|
||||
TTI::OperandValueKind Opd2Info,
|
||||
InstructionCost getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind Opd1Info, TTI::OperandValueKind Opd2Info,
|
||||
TTI::OperandValueProperties Opd1PropInfo,
|
||||
TTI::OperandValueProperties Opd2PropInfo,
|
||||
ArrayRef<const Value *> Args,
|
||||
TTI::OperandValueProperties Opd2PropInfo, ArrayRef<const Value *> Args,
|
||||
const Instruction *CxtI = nullptr) const {
|
||||
// FIXME: A number of transformation tests seem to require these values
|
||||
// which seems a little odd for how arbitary there are.
|
||||
|
|
|
@ -680,7 +680,7 @@ public:
|
|||
|
||||
unsigned getMaxInterleaveFactor(unsigned VF) { return 1; }
|
||||
|
||||
unsigned getArithmeticInstrCost(
|
||||
InstructionCost getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty,
|
||||
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput,
|
||||
TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
|
||||
|
@ -725,7 +725,7 @@ public:
|
|||
// similarly to what getCastInstrCost() does.
|
||||
if (auto *VTy = dyn_cast<VectorType>(Ty)) {
|
||||
unsigned Num = cast<FixedVectorType>(VTy)->getNumElements();
|
||||
unsigned Cost = thisT()->getArithmeticInstrCost(
|
||||
InstructionCost Cost = thisT()->getArithmeticInstrCost(
|
||||
Opcode, VTy->getScalarType(), CostKind, Opd1Info, Opd2Info,
|
||||
Opd1PropInfo, Opd2PropInfo, Args, CxtI);
|
||||
// Return the cost of multiple scalar invocation plus the cost of
|
||||
|
|
|
@ -703,15 +703,14 @@ TargetTransformInfo::getOperandInfo(const Value *V,
|
|||
return OpInfo;
|
||||
}
|
||||
|
||||
int TargetTransformInfo::getArithmeticInstrCost(
|
||||
InstructionCost TargetTransformInfo::getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
|
||||
OperandValueKind Opd1Info,
|
||||
OperandValueKind Opd2Info, OperandValueProperties Opd1PropInfo,
|
||||
OperandValueProperties Opd2PropInfo, ArrayRef<const Value *> Args,
|
||||
const Instruction *CxtI) const {
|
||||
int Cost = TTIImpl->getArithmeticInstrCost(
|
||||
Opcode, Ty, CostKind, Opd1Info, Opd2Info, Opd1PropInfo, Opd2PropInfo,
|
||||
Args, CxtI);
|
||||
OperandValueKind Opd1Info, OperandValueKind Opd2Info,
|
||||
OperandValueProperties Opd1PropInfo, OperandValueProperties Opd2PropInfo,
|
||||
ArrayRef<const Value *> Args, const Instruction *CxtI) const {
|
||||
InstructionCost Cost =
|
||||
TTIImpl->getArithmeticInstrCost(Opcode, Ty, CostKind, Opd1Info, Opd2Info,
|
||||
Opd1PropInfo, Opd2PropInfo, Args, CxtI);
|
||||
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
||||
return Cost;
|
||||
}
|
||||
|
|
|
@ -261,13 +261,13 @@ AArch64TTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
|||
break;
|
||||
}
|
||||
case Intrinsic::experimental_stepvector: {
|
||||
unsigned Cost = 1; // Cost of the `index' instruction
|
||||
InstructionCost Cost = 1; // Cost of the `index' instruction
|
||||
auto LT = TLI->getTypeLegalizationCost(DL, RetTy);
|
||||
// Legalisation of illegal vectors involves an `index' instruction plus
|
||||
// (LT.first - 1) vector adds.
|
||||
if (LT.first > 1) {
|
||||
Type *LegalVTy = EVT(LT.second).getTypeForEVT(RetTy->getContext());
|
||||
unsigned AddCost =
|
||||
InstructionCost AddCost =
|
||||
getArithmeticInstrCost(Instruction::Add, LegalVTy, CostKind);
|
||||
Cost += AddCost * (LT.first - 1);
|
||||
}
|
||||
|
@ -690,10 +690,10 @@ InstructionCost AArch64TTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
|
|||
return ST->getVectorInsertExtractBaseCost();
|
||||
}
|
||||
|
||||
int AArch64TTIImpl::getArithmeticInstrCost(
|
||||
InstructionCost AArch64TTIImpl::getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind Opd1Info,
|
||||
TTI::OperandValueKind Opd2Info, TTI::OperandValueProperties Opd1PropInfo,
|
||||
TTI::OperandValueKind Opd1Info, TTI::OperandValueKind Opd2Info,
|
||||
TTI::OperandValueProperties Opd1PropInfo,
|
||||
TTI::OperandValueProperties Opd2PropInfo, ArrayRef<const Value *> Args,
|
||||
const Instruction *CxtI) {
|
||||
// TODO: Handle more cost kinds.
|
||||
|
@ -711,7 +711,7 @@ int AArch64TTIImpl::getArithmeticInstrCost(
|
|||
// aren't present in the generated code and have a zero cost. By adding a
|
||||
// widening overhead here, we attach the total cost of the combined operation
|
||||
// to the widening instruction.
|
||||
int Cost = 0;
|
||||
InstructionCost Cost = 0;
|
||||
if (isWideningInstruction(Ty, Opcode, Args))
|
||||
Cost += ST->getWideningBaseCost();
|
||||
|
||||
|
@ -755,18 +755,15 @@ int AArch64TTIImpl::getArithmeticInstrCost(
|
|||
// Vector signed division by constant are expanded to the
|
||||
// sequence MULHS + ADD/SUB + SRA + SRL + ADD, and unsigned division
|
||||
// to MULHS + SUB + SRL + ADD + SRL.
|
||||
int MulCost = getArithmeticInstrCost(Instruction::Mul, Ty, CostKind,
|
||||
Opd1Info, Opd2Info,
|
||||
TargetTransformInfo::OP_None,
|
||||
TargetTransformInfo::OP_None);
|
||||
int AddCost = getArithmeticInstrCost(Instruction::Add, Ty, CostKind,
|
||||
Opd1Info, Opd2Info,
|
||||
TargetTransformInfo::OP_None,
|
||||
TargetTransformInfo::OP_None);
|
||||
int ShrCost = getArithmeticInstrCost(Instruction::AShr, Ty, CostKind,
|
||||
Opd1Info, Opd2Info,
|
||||
TargetTransformInfo::OP_None,
|
||||
TargetTransformInfo::OP_None);
|
||||
InstructionCost MulCost = getArithmeticInstrCost(
|
||||
Instruction::Mul, Ty, CostKind, Opd1Info, Opd2Info,
|
||||
TargetTransformInfo::OP_None, TargetTransformInfo::OP_None);
|
||||
InstructionCost AddCost = getArithmeticInstrCost(
|
||||
Instruction::Add, Ty, CostKind, Opd1Info, Opd2Info,
|
||||
TargetTransformInfo::OP_None, TargetTransformInfo::OP_None);
|
||||
InstructionCost ShrCost = getArithmeticInstrCost(
|
||||
Instruction::AShr, Ty, CostKind, Opd1Info, Opd2Info,
|
||||
TargetTransformInfo::OP_None, TargetTransformInfo::OP_None);
|
||||
return MulCost * 2 + AddCost * 2 + ShrCost * 2 + 1;
|
||||
}
|
||||
}
|
||||
|
@ -1280,7 +1277,7 @@ InstructionCost AArch64TTIImpl::getArithmeticReductionCostSVE(
|
|||
assert(!IsPairwise && "Cannot be pair wise to continue");
|
||||
|
||||
std::pair<int, MVT> LT = TLI->getTypeLegalizationCost(DL, ValTy);
|
||||
int LegalizationCost = 0;
|
||||
InstructionCost LegalizationCost = 0;
|
||||
if (LT.first > 1) {
|
||||
Type *LegalVTy = EVT(LT.second).getTypeForEVT(ValTy->getContext());
|
||||
LegalizationCost = getArithmeticInstrCost(Opcode, LegalVTy, CostKind);
|
||||
|
|
|
@ -156,7 +156,7 @@ public:
|
|||
bool IsPairwiseForm,
|
||||
TTI::TargetCostKind CostKind);
|
||||
|
||||
int getArithmeticInstrCost(
|
||||
InstructionCost getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty,
|
||||
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput,
|
||||
TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
|
||||
|
|
|
@ -510,13 +510,11 @@ bool GCNTTIImpl::getTgtMemIntrinsic(IntrinsicInst *Inst,
|
|||
}
|
||||
}
|
||||
|
||||
int GCNTTIImpl::getArithmeticInstrCost(unsigned Opcode, Type *Ty,
|
||||
TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind Opd1Info,
|
||||
TTI::OperandValueKind Opd2Info,
|
||||
InstructionCost GCNTTIImpl::getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind Opd1Info, TTI::OperandValueKind Opd2Info,
|
||||
TTI::OperandValueProperties Opd1PropInfo,
|
||||
TTI::OperandValueProperties Opd2PropInfo,
|
||||
ArrayRef<const Value *> Args,
|
||||
TTI::OperandValueProperties Opd2PropInfo, ArrayRef<const Value *> Args,
|
||||
const Instruction *CxtI) {
|
||||
EVT OrigTy = TLI->getValueType(DL, Ty);
|
||||
if (!OrigTy.isSimple()) {
|
||||
|
@ -557,7 +555,7 @@ int GCNTTIImpl::getArithmeticInstrCost(unsigned Opcode, Type *Ty,
|
|||
// similarly to what getCastInstrCost() does.
|
||||
if (auto *VTy = dyn_cast<VectorType>(Ty)) {
|
||||
unsigned Num = cast<FixedVectorType>(VTy)->getNumElements();
|
||||
unsigned Cost = getArithmeticInstrCost(
|
||||
InstructionCost Cost = getArithmeticInstrCost(
|
||||
Opcode, VTy->getScalarType(), CostKind, Opd1Info, Opd2Info,
|
||||
Opd1PropInfo, Opd2PropInfo, Args, CxtI);
|
||||
// Return the cost of multiple scalar invocation plus the cost of
|
||||
|
|
|
@ -153,7 +153,7 @@ public:
|
|||
|
||||
bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info) const;
|
||||
|
||||
int getArithmeticInstrCost(
|
||||
InstructionCost getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty,
|
||||
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput,
|
||||
TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
|
||||
|
|
|
@ -1240,13 +1240,11 @@ InstructionCost ARMTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
|
|||
return BaseCost * BaseT::getShuffleCost(Kind, Tp, Mask, Index, SubTp);
|
||||
}
|
||||
|
||||
int ARMTTIImpl::getArithmeticInstrCost(unsigned Opcode, Type *Ty,
|
||||
TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind Op1Info,
|
||||
TTI::OperandValueKind Op2Info,
|
||||
InstructionCost ARMTTIImpl::getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind Op1Info, TTI::OperandValueKind Op2Info,
|
||||
TTI::OperandValueProperties Opd1PropInfo,
|
||||
TTI::OperandValueProperties Opd2PropInfo,
|
||||
ArrayRef<const Value *> Args,
|
||||
TTI::OperandValueProperties Opd2PropInfo, ArrayRef<const Value *> Args,
|
||||
const Instruction *CxtI) {
|
||||
int ISDOpcode = TLI->InstructionOpcodeToISD(Opcode);
|
||||
if (ST->isThumb() && CostKind == TTI::TCK_CodeSize && Ty->isIntegerTy(1)) {
|
||||
|
@ -1313,9 +1311,8 @@ int ARMTTIImpl::getArithmeticInstrCost(unsigned Opcode, Type *Ty,
|
|||
if (const auto *Entry = CostTableLookup(CostTbl, ISDOpcode, LT.second))
|
||||
return LT.first * Entry->Cost;
|
||||
|
||||
int Cost = BaseT::getArithmeticInstrCost(Opcode, Ty, CostKind, Op1Info,
|
||||
Op2Info,
|
||||
Opd1PropInfo, Opd2PropInfo);
|
||||
InstructionCost Cost = BaseT::getArithmeticInstrCost(
|
||||
Opcode, Ty, CostKind, Op1Info, Op2Info, Opd1PropInfo, Opd2PropInfo);
|
||||
|
||||
// This is somewhat of a hack. The problem that we are facing is that SROA
|
||||
// creates a sequence of shift, and, or instructions to construct values.
|
||||
|
@ -1374,8 +1371,8 @@ int ARMTTIImpl::getArithmeticInstrCost(unsigned Opcode, Type *Ty,
|
|||
// Else this is expand, assume that we need to scalarize this op.
|
||||
if (auto *VTy = dyn_cast<FixedVectorType>(Ty)) {
|
||||
unsigned Num = VTy->getNumElements();
|
||||
unsigned Cost = getArithmeticInstrCost(Opcode, Ty->getScalarType(),
|
||||
CostKind);
|
||||
InstructionCost Cost =
|
||||
getArithmeticInstrCost(Opcode, Ty->getScalarType(), CostKind);
|
||||
// Return the cost of multiple scalar invocation plus the cost of
|
||||
// inserting and extracting the values.
|
||||
SmallVector<Type *> Tys(Args.size(), Ty);
|
||||
|
|
|
@ -218,7 +218,7 @@ public:
|
|||
int getAddressComputationCost(Type *Val, ScalarEvolution *SE,
|
||||
const SCEV *Ptr);
|
||||
|
||||
int getArithmeticInstrCost(
|
||||
InstructionCost getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty,
|
||||
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput,
|
||||
TTI::OperandValueKind Op1Info = TTI::OK_AnyValue,
|
||||
|
|
|
@ -258,10 +258,10 @@ InstructionCost HexagonTTIImpl::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
|
|||
return BaseT::getCmpSelInstrCost(Opcode, ValTy, CondTy, VecPred, CostKind, I);
|
||||
}
|
||||
|
||||
unsigned HexagonTTIImpl::getArithmeticInstrCost(
|
||||
InstructionCost HexagonTTIImpl::getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind Opd1Info,
|
||||
TTI::OperandValueKind Opd2Info, TTI::OperandValueProperties Opd1PropInfo,
|
||||
TTI::OperandValueKind Opd1Info, TTI::OperandValueKind Opd2Info,
|
||||
TTI::OperandValueProperties Opd1PropInfo,
|
||||
TTI::OperandValueProperties Opd2PropInfo, ArrayRef<const Value *> Args,
|
||||
const Instruction *CxtI) {
|
||||
// TODO: Handle more cost kinds.
|
||||
|
|
|
@ -139,7 +139,7 @@ public:
|
|||
CmpInst::Predicate VecPred,
|
||||
TTI::TargetCostKind CostKind,
|
||||
const Instruction *I = nullptr);
|
||||
unsigned getArithmeticInstrCost(
|
||||
InstructionCost getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty,
|
||||
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput,
|
||||
TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
return getIntImmCost(Imm, Ty, CostKind);
|
||||
}
|
||||
|
||||
unsigned getArithmeticInstrCost(
|
||||
InstructionCost getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty,
|
||||
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput,
|
||||
TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
|
||||
|
|
|
@ -368,10 +368,10 @@ NVPTXTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
|
|||
return None;
|
||||
}
|
||||
|
||||
int NVPTXTTIImpl::getArithmeticInstrCost(
|
||||
InstructionCost NVPTXTTIImpl::getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind Opd1Info,
|
||||
TTI::OperandValueKind Opd2Info, TTI::OperandValueProperties Opd1PropInfo,
|
||||
TTI::OperandValueKind Opd1Info, TTI::OperandValueKind Opd2Info,
|
||||
TTI::OperandValueProperties Opd1PropInfo,
|
||||
TTI::OperandValueProperties Opd2PropInfo, ArrayRef<const Value *> Args,
|
||||
const Instruction *CxtI) {
|
||||
// Legalize the type.
|
||||
|
|
|
@ -88,7 +88,7 @@ public:
|
|||
// calls are particularly expensive in NVPTX.
|
||||
unsigned getInliningThresholdMultiplier() { return 5; }
|
||||
|
||||
int getArithmeticInstrCost(
|
||||
InstructionCost getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty,
|
||||
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput,
|
||||
TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
|
||||
|
|
|
@ -965,13 +965,11 @@ InstructionCost PPCTTIImpl::vectorCostAdjustment(InstructionCost Cost,
|
|||
return Cost * 2;
|
||||
}
|
||||
|
||||
int PPCTTIImpl::getArithmeticInstrCost(unsigned Opcode, Type *Ty,
|
||||
TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind Op1Info,
|
||||
TTI::OperandValueKind Op2Info,
|
||||
InstructionCost PPCTTIImpl::getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind Op1Info, TTI::OperandValueKind Op2Info,
|
||||
TTI::OperandValueProperties Opd1PropInfo,
|
||||
TTI::OperandValueProperties Opd2PropInfo,
|
||||
ArrayRef<const Value *> Args,
|
||||
TTI::OperandValueProperties Opd2PropInfo, ArrayRef<const Value *> Args,
|
||||
const Instruction *CxtI) {
|
||||
assert(TLI->InstructionOpcodeToISD(Opcode) && "Invalid opcode");
|
||||
// TODO: Handle more cost kinds.
|
||||
|
@ -981,10 +979,9 @@ int PPCTTIImpl::getArithmeticInstrCost(unsigned Opcode, Type *Ty,
|
|||
Opd2PropInfo, Args, CxtI);
|
||||
|
||||
// Fallback to the default implementation.
|
||||
int Cost = BaseT::getArithmeticInstrCost(Opcode, Ty, CostKind, Op1Info,
|
||||
Op2Info,
|
||||
Opd1PropInfo, Opd2PropInfo);
|
||||
return *vectorCostAdjustment(Cost, Opcode, Ty, nullptr).getValue();
|
||||
InstructionCost Cost = BaseT::getArithmeticInstrCost(
|
||||
Opcode, Ty, CostKind, Op1Info, Op2Info, Opd1PropInfo, Opd2PropInfo);
|
||||
return vectorCostAdjustment(Cost, Opcode, Ty, nullptr);
|
||||
}
|
||||
|
||||
InstructionCost PPCTTIImpl::getShuffleCost(TTI::ShuffleKind Kind, Type *Tp,
|
||||
|
|
|
@ -99,7 +99,7 @@ public:
|
|||
unsigned getMaxInterleaveFactor(unsigned VF);
|
||||
InstructionCost vectorCostAdjustment(InstructionCost Cost, unsigned Opcode,
|
||||
Type *Ty1, Type *Ty2);
|
||||
int getArithmeticInstrCost(
|
||||
InstructionCost getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty,
|
||||
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput,
|
||||
TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
|
||||
|
|
|
@ -379,10 +379,10 @@ static unsigned getNumVectorRegs(Type *Ty) {
|
|||
return ((WideBits % 128U) ? ((WideBits / 128U) + 1) : (WideBits / 128U));
|
||||
}
|
||||
|
||||
int SystemZTTIImpl::getArithmeticInstrCost(
|
||||
InstructionCost SystemZTTIImpl::getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind Op1Info,
|
||||
TTI::OperandValueKind Op2Info, TTI::OperandValueProperties Opd1PropInfo,
|
||||
TTI::OperandValueKind Op1Info, TTI::OperandValueKind Op2Info,
|
||||
TTI::OperandValueProperties Opd1PropInfo,
|
||||
TTI::OperandValueProperties Opd2PropInfo, ArrayRef<const Value *> Args,
|
||||
const Instruction *CxtI) {
|
||||
|
||||
|
@ -518,10 +518,10 @@ int SystemZTTIImpl::getArithmeticInstrCost(
|
|||
return NumVectors;
|
||||
// Return the cost of multiple scalar invocation plus the cost of
|
||||
// inserting and extracting the values.
|
||||
unsigned ScalarCost =
|
||||
InstructionCost ScalarCost =
|
||||
getArithmeticInstrCost(Opcode, Ty->getScalarType(), CostKind);
|
||||
SmallVector<Type *> Tys(Args.size(), Ty);
|
||||
unsigned Cost =
|
||||
InstructionCost Cost =
|
||||
(VF * ScalarCost) + getScalarizationOverhead(VTy, Args, Tys);
|
||||
// FIXME: VF 2 for these FP operations are currently just as
|
||||
// expensive as for VF 4.
|
||||
|
|
|
@ -78,7 +78,7 @@ public:
|
|||
bool supportsEfficientVectorElementLoadStore() { return true; }
|
||||
bool enableInterleavedAccessVectorization() { return true; }
|
||||
|
||||
int getArithmeticInstrCost(
|
||||
InstructionCost getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty,
|
||||
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput,
|
||||
TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
|
||||
|
|
|
@ -50,14 +50,15 @@ TypeSize WebAssemblyTTIImpl::getRegisterBitWidth(
|
|||
llvm_unreachable("Unsupported register kind");
|
||||
}
|
||||
|
||||
unsigned WebAssemblyTTIImpl::getArithmeticInstrCost(
|
||||
InstructionCost WebAssemblyTTIImpl::getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind Opd1Info,
|
||||
TTI::OperandValueKind Opd2Info, TTI::OperandValueProperties Opd1PropInfo,
|
||||
TTI::OperandValueKind Opd1Info, TTI::OperandValueKind Opd2Info,
|
||||
TTI::OperandValueProperties Opd1PropInfo,
|
||||
TTI::OperandValueProperties Opd2PropInfo, ArrayRef<const Value *> Args,
|
||||
const Instruction *CxtI) {
|
||||
|
||||
unsigned Cost = BasicTTIImplBase<WebAssemblyTTIImpl>::getArithmeticInstrCost(
|
||||
InstructionCost Cost =
|
||||
BasicTTIImplBase<WebAssemblyTTIImpl>::getArithmeticInstrCost(
|
||||
Opcode, Ty, CostKind, Opd1Info, Opd2Info, Opd1PropInfo, Opd2PropInfo);
|
||||
|
||||
if (auto *VTy = dyn_cast<VectorType>(Ty)) {
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
|
||||
unsigned getNumberOfRegisters(unsigned ClassID) const;
|
||||
TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const;
|
||||
unsigned getArithmeticInstrCost(
|
||||
InstructionCost getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty,
|
||||
TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency,
|
||||
TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
|
||||
|
|
|
@ -173,13 +173,11 @@ unsigned X86TTIImpl::getMaxInterleaveFactor(unsigned VF) {
|
|||
return 2;
|
||||
}
|
||||
|
||||
int X86TTIImpl::getArithmeticInstrCost(unsigned Opcode, Type *Ty,
|
||||
TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind Op1Info,
|
||||
TTI::OperandValueKind Op2Info,
|
||||
InstructionCost X86TTIImpl::getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind Op1Info, TTI::OperandValueKind Op2Info,
|
||||
TTI::OperandValueProperties Opd1PropInfo,
|
||||
TTI::OperandValueProperties Opd2PropInfo,
|
||||
ArrayRef<const Value *> Args,
|
||||
TTI::OperandValueProperties Opd2PropInfo, ArrayRef<const Value *> Args,
|
||||
const Instruction *CxtI) {
|
||||
// TODO: Handle more cost kinds.
|
||||
if (CostKind != TTI::TCK_RecipThroughput)
|
||||
|
@ -265,10 +263,9 @@ int X86TTIImpl::getArithmeticInstrCost(unsigned Opcode, Type *Ty,
|
|||
// normally expanded to the sequence SRA + SRL + ADD + SRA.
|
||||
// The OperandValue properties may not be the same as that of the previous
|
||||
// operation; conservatively assume OP_None.
|
||||
int Cost =
|
||||
InstructionCost Cost =
|
||||
2 * getArithmeticInstrCost(Instruction::AShr, Ty, CostKind, Op1Info,
|
||||
Op2Info,
|
||||
TargetTransformInfo::OP_None,
|
||||
Op2Info, TargetTransformInfo::OP_None,
|
||||
TargetTransformInfo::OP_None);
|
||||
Cost += getArithmeticInstrCost(Instruction::LShr, Ty, CostKind, Op1Info,
|
||||
Op2Info,
|
||||
|
@ -953,7 +950,7 @@ int X86TTIImpl::getArithmeticInstrCost(unsigned Opcode, Type *Ty,
|
|||
// to hide "20 cycles" for each lane.
|
||||
if (LT.second.isVector() && (ISD == ISD::SDIV || ISD == ISD::SREM ||
|
||||
ISD == ISD::UDIV || ISD == ISD::UREM)) {
|
||||
int ScalarCost = getArithmeticInstrCost(
|
||||
InstructionCost ScalarCost = getArithmeticInstrCost(
|
||||
Opcode, Ty->getScalarType(), CostKind, Op1Info, Op2Info,
|
||||
TargetTransformInfo::OP_None, TargetTransformInfo::OP_None);
|
||||
return 20 * LT.first * LT.second.getVectorNumElements() * ScalarCost;
|
||||
|
@ -3419,14 +3416,13 @@ X86TTIImpl::getArithmeticReductionCost(unsigned Opcode, VectorType *ValTy,
|
|||
if (ISD == ISD::MUL && MTy.getScalarType() == MVT::i8) {
|
||||
auto *WideSclTy = IntegerType::get(ValVTy->getContext(), 16);
|
||||
auto *WideVecTy = FixedVectorType::get(WideSclTy, ValVTy->getNumElements());
|
||||
return *getCastInstrCost(Instruction::ZExt, WideVecTy, ValTy,
|
||||
return getCastInstrCost(Instruction::ZExt, WideVecTy, ValTy,
|
||||
TargetTransformInfo::CastContextHint::None,
|
||||
CostKind)
|
||||
.getValue() +
|
||||
CostKind) +
|
||||
getArithmeticReductionCost(Opcode, WideVecTy, IsPairwise, CostKind);
|
||||
}
|
||||
|
||||
unsigned ArithmeticCost = 0;
|
||||
InstructionCost ArithmeticCost = 0;
|
||||
if (LT.first != 1 && MTy.isVector() &&
|
||||
MTy.getVectorNumElements() < ValVTy->getNumElements()) {
|
||||
// Type needs to be split. We need LT.first - 1 arithmetic ops.
|
||||
|
@ -3496,7 +3492,7 @@ X86TTIImpl::getArithmeticReductionCost(unsigned Opcode, VectorType *ValTy,
|
|||
|
||||
// Handle bool allof/anyof patterns.
|
||||
if (ValVTy->getElementType()->isIntegerTy(1)) {
|
||||
unsigned ArithmeticCost = 0;
|
||||
InstructionCost ArithmeticCost = 0;
|
||||
if (LT.first != 1 && MTy.isVector() &&
|
||||
MTy.getVectorNumElements() < ValVTy->getNumElements()) {
|
||||
// Type needs to be split. We need LT.first - 1 arithmetic ops.
|
||||
|
|
|
@ -118,7 +118,7 @@ public:
|
|||
TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const;
|
||||
unsigned getLoadStoreVecRegBitWidth(unsigned AS) const;
|
||||
unsigned getMaxInterleaveFactor(unsigned VF);
|
||||
int getArithmeticInstrCost(
|
||||
InstructionCost getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty,
|
||||
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput,
|
||||
TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
|
||||
|
|
Loading…
Reference in New Issue