forked from OSchip/llvm-project
[TTI] Plumb through OperandValueInfo in getMemoryOpCost [NFC]
This has the effect of exposing the power-of-two property for use in memory op costing, but no target actually uses it yet. The main point of this change is simple consistency with the recently changes getArithmeticInstrCost, and to remove the last (interface) use of OperandValueKind.
This commit is contained in:
parent
2c923b8863
commit
c9608d57b8
|
@ -1769,7 +1769,7 @@ public:
|
|||
virtual InstructionCost
|
||||
getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
|
||||
unsigned AddressSpace, TTI::TargetCostKind CostKind,
|
||||
OperandValueKind OpdInfo, const Instruction *I) = 0;
|
||||
OperandValueInfo OpInfo, const Instruction *I) = 0;
|
||||
virtual InstructionCost getVPMemoryOpCost(unsigned Opcode, Type *Src,
|
||||
Align Alignment,
|
||||
unsigned AddressSpace,
|
||||
|
@ -2336,10 +2336,10 @@ public:
|
|||
InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
|
||||
unsigned AddressSpace,
|
||||
TTI::TargetCostKind CostKind,
|
||||
OperandValueKind OpdInfo,
|
||||
OperandValueInfo OpInfo,
|
||||
const Instruction *I) override {
|
||||
return Impl.getMemoryOpCost(Opcode, Src, Alignment, AddressSpace, CostKind,
|
||||
OpdInfo, I);
|
||||
OpInfo, I);
|
||||
}
|
||||
InstructionCost getVPMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
|
||||
unsigned AddressSpace,
|
||||
|
|
|
@ -599,7 +599,7 @@ public:
|
|||
InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
|
||||
unsigned AddressSpace,
|
||||
TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind OpdInfo,
|
||||
TTI::OperandValueInfo OpInfo,
|
||||
const Instruction *I) const {
|
||||
return 1;
|
||||
}
|
||||
|
@ -1101,10 +1101,10 @@ public:
|
|||
case Instruction::Store: {
|
||||
auto *SI = cast<StoreInst>(U);
|
||||
Type *ValTy = U->getOperand(0)->getType();
|
||||
TTI::OperandValueKind OpVK = TTI::getOperandInfo(U->getOperand(0)).Kind;
|
||||
TTI::OperandValueInfo OpInfo = TTI::getOperandInfo(U->getOperand(0));
|
||||
return TargetTTI->getMemoryOpCost(Opcode, ValTy, SI->getAlign(),
|
||||
SI->getPointerAddressSpace(), CostKind,
|
||||
OpVK, I);
|
||||
OpInfo, I);
|
||||
}
|
||||
case Instruction::Load: {
|
||||
// FIXME: Arbitary cost which could come from the backend.
|
||||
|
@ -1126,7 +1126,7 @@ public:
|
|||
}
|
||||
return TargetTTI->getMemoryOpCost(Opcode, LoadType, LI->getAlign(),
|
||||
LI->getPointerAddressSpace(), CostKind,
|
||||
TTI::OK_AnyValue, I);
|
||||
{TTI::OK_AnyValue, TTI::OP_None}, I);
|
||||
}
|
||||
case Instruction::Select: {
|
||||
const Value *Op0, *Op1;
|
||||
|
|
|
@ -1221,7 +1221,7 @@ public:
|
|||
InstructionCost
|
||||
getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
|
||||
unsigned AddressSpace, TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind OpdInfo = TTI::OK_AnyValue,
|
||||
TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
|
||||
const Instruction *I = nullptr) {
|
||||
assert(!Src->isVoidTy() && "Invalid type");
|
||||
// Assume types, such as structs, are expensive.
|
||||
|
|
|
@ -903,12 +903,12 @@ InstructionCost TargetTransformInfo::getReplicationShuffleCost(
|
|||
|
||||
InstructionCost TargetTransformInfo::getMemoryOpCost(
|
||||
unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,
|
||||
TTI::TargetCostKind CostKind, TTI::OperandValueInfo OpdInfo,
|
||||
TTI::TargetCostKind CostKind, TTI::OperandValueInfo OpInfo,
|
||||
const Instruction *I) const {
|
||||
assert((I == nullptr || I->getOpcode() == Opcode) &&
|
||||
"Opcode should reflect passed instruction.");
|
||||
InstructionCost Cost = TTIImpl->getMemoryOpCost(
|
||||
Opcode, Src, Alignment, AddressSpace, CostKind, OpdInfo.Kind, I);
|
||||
Opcode, Src, Alignment, AddressSpace, CostKind, OpInfo, I);
|
||||
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
||||
return Cost;
|
||||
}
|
||||
|
|
|
@ -2241,7 +2241,7 @@ InstructionCost AArch64TTIImpl::getGatherScatterOpCost(
|
|||
ElementCount LegalVF = LT.second.getVectorElementCount();
|
||||
InstructionCost MemOpCost =
|
||||
getMemoryOpCost(Opcode, VT->getElementType(), Alignment, 0, CostKind,
|
||||
TTI::OK_AnyValue, I);
|
||||
{TTI::OK_AnyValue, TTI::OP_None}, I);
|
||||
// Add on an overhead cost for using gathers/scatters.
|
||||
// TODO: At the moment this is applied unilaterally for all CPUs, but at some
|
||||
// point we may want a per-CPU overhead.
|
||||
|
@ -2257,7 +2257,7 @@ InstructionCost AArch64TTIImpl::getMemoryOpCost(unsigned Opcode, Type *Ty,
|
|||
MaybeAlign Alignment,
|
||||
unsigned AddressSpace,
|
||||
TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind OpdInfo,
|
||||
TTI::OperandValueInfo OpInfo,
|
||||
const Instruction *I) {
|
||||
EVT VT = TLI->getValueType(DL, Ty, true);
|
||||
// Type legalization can't handle structs
|
||||
|
|
|
@ -209,7 +209,7 @@ public:
|
|||
InstructionCost
|
||||
getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
|
||||
unsigned AddressSpace, TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind OpdInfo = TTI::OK_AnyValue,
|
||||
TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
|
||||
const Instruction *I = nullptr);
|
||||
|
||||
InstructionCost getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys);
|
||||
|
|
|
@ -1451,7 +1451,7 @@ InstructionCost ARMTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
|
|||
MaybeAlign Alignment,
|
||||
unsigned AddressSpace,
|
||||
TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind OpdInfo,
|
||||
TTI::OperandValueInfo OpInfo,
|
||||
const Instruction *I) {
|
||||
// TODO: Handle other cost kinds.
|
||||
if (CostKind != TTI::TCK_RecipThroughput)
|
||||
|
@ -1491,7 +1491,7 @@ InstructionCost ARMTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
|
|||
? ST->getMVEVectorCostFactor(CostKind)
|
||||
: 1;
|
||||
return BaseCost * BaseT::getMemoryOpCost(Opcode, Src, Alignment, AddressSpace,
|
||||
CostKind, OpdInfo, I);
|
||||
CostKind, OpInfo, I);
|
||||
}
|
||||
|
||||
InstructionCost
|
||||
|
|
|
@ -255,7 +255,7 @@ public:
|
|||
InstructionCost
|
||||
getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
|
||||
unsigned AddressSpace, TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind OpdInfo = TTI::OK_AnyValue,
|
||||
TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
|
||||
const Instruction *I = nullptr);
|
||||
|
||||
InstructionCost getMaskedMemoryOpCost(unsigned Opcode, Type *Src,
|
||||
|
|
|
@ -161,7 +161,7 @@ InstructionCost HexagonTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
|
|||
MaybeAlign Alignment,
|
||||
unsigned AddressSpace,
|
||||
TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind OpdInfo,
|
||||
TTI::OperandValueInfo OpInfo,
|
||||
const Instruction *I) {
|
||||
assert(Opcode == Instruction::Load || Opcode == Instruction::Store);
|
||||
// TODO: Handle other cost kinds.
|
||||
|
@ -170,7 +170,7 @@ InstructionCost HexagonTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
|
|||
|
||||
if (Opcode == Instruction::Store)
|
||||
return BaseT::getMemoryOpCost(Opcode, Src, Alignment, AddressSpace,
|
||||
CostKind, OpdInfo, I);
|
||||
CostKind, OpInfo, I);
|
||||
|
||||
if (Src->isVectorTy()) {
|
||||
VectorType *VecTy = cast<VectorType>(Src);
|
||||
|
@ -211,7 +211,7 @@ InstructionCost HexagonTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
|
|||
}
|
||||
|
||||
return BaseT::getMemoryOpCost(Opcode, Src, Alignment, AddressSpace, CostKind,
|
||||
OpdInfo, I);
|
||||
OpInfo, I);
|
||||
}
|
||||
|
||||
InstructionCost
|
||||
|
|
|
@ -119,7 +119,7 @@ public:
|
|||
InstructionCost
|
||||
getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
|
||||
unsigned AddressSpace, TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind OpdInfo = TTI::OK_AnyValue,
|
||||
TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
|
||||
const Instruction *I = nullptr);
|
||||
InstructionCost getMaskedMemoryOpCost(unsigned Opcode, Type *Src,
|
||||
Align Alignment, unsigned AddressSpace,
|
||||
|
|
|
@ -1144,7 +1144,7 @@ InstructionCost PPCTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
|
|||
MaybeAlign Alignment,
|
||||
unsigned AddressSpace,
|
||||
TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind OpdInfo,
|
||||
TTI::OperandValueInfo OpInfo,
|
||||
const Instruction *I) {
|
||||
|
||||
InstructionCost CostFactor = vectorCostAdjustmentFactor(Opcode, Src, nullptr);
|
||||
|
|
|
@ -130,7 +130,7 @@ public:
|
|||
InstructionCost
|
||||
getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
|
||||
unsigned AddressSpace, TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind OpdInfo = TTI::OK_AnyValue,
|
||||
TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
|
||||
const Instruction *I = nullptr);
|
||||
InstructionCost getInterleavedMemoryOpCost(
|
||||
unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
|
||||
|
|
|
@ -247,7 +247,7 @@ InstructionCost RISCVTTIImpl::getGatherScatterOpCost(
|
|||
auto &VTy = *cast<VectorType>(DataTy);
|
||||
InstructionCost MemOpCost =
|
||||
getMemoryOpCost(Opcode, VTy.getElementType(), Alignment, 0, CostKind,
|
||||
TTI::OK_AnyValue, I);
|
||||
{TTI::OK_AnyValue, TTI::OP_None}, I);
|
||||
unsigned NumLoads = getEstimatedVLFor(&VTy);
|
||||
return NumLoads * MemOpCost;
|
||||
}
|
||||
|
@ -530,14 +530,13 @@ InstructionCost RISCVTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
|
|||
MaybeAlign Alignment,
|
||||
unsigned AddressSpace,
|
||||
TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind OpdKind,
|
||||
TTI::OperandValueInfo OpInfo,
|
||||
const Instruction *I) {
|
||||
const TTI::OperandValueInfo OpInfo = {OpdKind, TTI::OP_None};
|
||||
InstructionCost Cost = 0;
|
||||
if (Opcode == Instruction::Store && isa<VectorType>(Src) && OpInfo.isConstant())
|
||||
Cost += getVectorImmCost(cast<VectorType>(Src), OpInfo, CostKind);
|
||||
return Cost + BaseT::getMemoryOpCost(Opcode, Src, Alignment, AddressSpace,
|
||||
CostKind, OpInfo.Kind, I);
|
||||
CostKind, OpInfo, I);
|
||||
}
|
||||
|
||||
void RISCVTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
|
||||
|
|
|
@ -135,7 +135,7 @@ public:
|
|||
InstructionCost
|
||||
getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
|
||||
unsigned AddressSpace, TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind OpdInfo = TTI::OK_AnyValue,
|
||||
TTI::OperandValueInfo OpdInfo = {TTI::OK_AnyValue, TTI::OP_None},
|
||||
const Instruction *I = nullptr);
|
||||
|
||||
bool isElementTypeLegalForScalableVector(Type *Ty) const {
|
||||
|
|
|
@ -1108,7 +1108,7 @@ InstructionCost SystemZTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
|
|||
MaybeAlign Alignment,
|
||||
unsigned AddressSpace,
|
||||
TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind OpdInfo,
|
||||
TTI::OperandValueInfo OpInfo,
|
||||
const Instruction *I) {
|
||||
assert(!Src->isVoidTy() && "Invalid type");
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ public:
|
|||
InstructionCost
|
||||
getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
|
||||
unsigned AddressSpace, TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind OpdInfo = TTI::OK_AnyValue,
|
||||
TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
|
||||
const Instruction *I = nullptr);
|
||||
|
||||
InstructionCost getInterleavedMemoryOpCost(
|
||||
|
|
|
@ -4029,10 +4029,8 @@ InstructionCost X86TTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
|
|||
MaybeAlign Alignment,
|
||||
unsigned AddressSpace,
|
||||
TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind OpdKind,
|
||||
TTI::OperandValueInfo OpInfo,
|
||||
const Instruction *I) {
|
||||
const TTI::OperandValueInfo OpInfo = {OpdKind, TTI::OP_None};
|
||||
|
||||
// TODO: Handle other cost kinds.
|
||||
if (CostKind != TTI::TCK_RecipThroughput) {
|
||||
if (auto *SI = dyn_cast_or_null<StoreInst>(I)) {
|
||||
|
|
|
@ -158,7 +158,7 @@ public:
|
|||
InstructionCost
|
||||
getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
|
||||
unsigned AddressSpace, TTI::TargetCostKind CostKind,
|
||||
TTI::OperandValueKind OpdInfo = TTI::OK_AnyValue,
|
||||
TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
|
||||
const Instruction *I = nullptr);
|
||||
InstructionCost getMaskedMemoryOpCost(unsigned Opcode, Type *Src,
|
||||
Align Alignment, unsigned AddressSpace,
|
||||
|
|
Loading…
Reference in New Issue