[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:
Philip Reames 2022-08-22 15:26:36 -07:00 committed by Philip Reames
parent 2c923b8863
commit c9608d57b8
18 changed files with 30 additions and 33 deletions

View File

@ -1769,7 +1769,7 @@ public:
virtual InstructionCost virtual InstructionCost
getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
unsigned AddressSpace, TTI::TargetCostKind CostKind, unsigned AddressSpace, TTI::TargetCostKind CostKind,
OperandValueKind OpdInfo, const Instruction *I) = 0; OperandValueInfo OpInfo, const Instruction *I) = 0;
virtual InstructionCost getVPMemoryOpCost(unsigned Opcode, Type *Src, virtual InstructionCost getVPMemoryOpCost(unsigned Opcode, Type *Src,
Align Alignment, Align Alignment,
unsigned AddressSpace, unsigned AddressSpace,
@ -2336,10 +2336,10 @@ public:
InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
unsigned AddressSpace, unsigned AddressSpace,
TTI::TargetCostKind CostKind, TTI::TargetCostKind CostKind,
OperandValueKind OpdInfo, OperandValueInfo OpInfo,
const Instruction *I) override { const Instruction *I) override {
return Impl.getMemoryOpCost(Opcode, Src, Alignment, AddressSpace, CostKind, return Impl.getMemoryOpCost(Opcode, Src, Alignment, AddressSpace, CostKind,
OpdInfo, I); OpInfo, I);
} }
InstructionCost getVPMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, InstructionCost getVPMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
unsigned AddressSpace, unsigned AddressSpace,

View File

@ -599,7 +599,7 @@ public:
InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
unsigned AddressSpace, unsigned AddressSpace,
TTI::TargetCostKind CostKind, TTI::TargetCostKind CostKind,
TTI::OperandValueKind OpdInfo, TTI::OperandValueInfo OpInfo,
const Instruction *I) const { const Instruction *I) const {
return 1; return 1;
} }
@ -1101,10 +1101,10 @@ public:
case Instruction::Store: { case Instruction::Store: {
auto *SI = cast<StoreInst>(U); auto *SI = cast<StoreInst>(U);
Type *ValTy = U->getOperand(0)->getType(); 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(), return TargetTTI->getMemoryOpCost(Opcode, ValTy, SI->getAlign(),
SI->getPointerAddressSpace(), CostKind, SI->getPointerAddressSpace(), CostKind,
OpVK, I); OpInfo, I);
} }
case Instruction::Load: { case Instruction::Load: {
// FIXME: Arbitary cost which could come from the backend. // FIXME: Arbitary cost which could come from the backend.
@ -1126,7 +1126,7 @@ public:
} }
return TargetTTI->getMemoryOpCost(Opcode, LoadType, LI->getAlign(), return TargetTTI->getMemoryOpCost(Opcode, LoadType, LI->getAlign(),
LI->getPointerAddressSpace(), CostKind, LI->getPointerAddressSpace(), CostKind,
TTI::OK_AnyValue, I); {TTI::OK_AnyValue, TTI::OP_None}, I);
} }
case Instruction::Select: { case Instruction::Select: {
const Value *Op0, *Op1; const Value *Op0, *Op1;

View File

@ -1221,7 +1221,7 @@ public:
InstructionCost InstructionCost
getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment, getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
unsigned AddressSpace, TTI::TargetCostKind CostKind, unsigned AddressSpace, TTI::TargetCostKind CostKind,
TTI::OperandValueKind OpdInfo = TTI::OK_AnyValue, TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
const Instruction *I = nullptr) { const Instruction *I = nullptr) {
assert(!Src->isVoidTy() && "Invalid type"); assert(!Src->isVoidTy() && "Invalid type");
// Assume types, such as structs, are expensive. // Assume types, such as structs, are expensive.

View File

@ -903,12 +903,12 @@ InstructionCost TargetTransformInfo::getReplicationShuffleCost(
InstructionCost TargetTransformInfo::getMemoryOpCost( InstructionCost TargetTransformInfo::getMemoryOpCost(
unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,
TTI::TargetCostKind CostKind, TTI::OperandValueInfo OpdInfo, TTI::TargetCostKind CostKind, TTI::OperandValueInfo OpInfo,
const Instruction *I) const { const Instruction *I) const {
assert((I == nullptr || I->getOpcode() == Opcode) && assert((I == nullptr || I->getOpcode() == Opcode) &&
"Opcode should reflect passed instruction."); "Opcode should reflect passed instruction.");
InstructionCost Cost = TTIImpl->getMemoryOpCost( 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!"); assert(Cost >= 0 && "TTI should not produce negative costs!");
return Cost; return Cost;
} }

View File

@ -2241,7 +2241,7 @@ InstructionCost AArch64TTIImpl::getGatherScatterOpCost(
ElementCount LegalVF = LT.second.getVectorElementCount(); ElementCount LegalVF = LT.second.getVectorElementCount();
InstructionCost MemOpCost = InstructionCost MemOpCost =
getMemoryOpCost(Opcode, VT->getElementType(), Alignment, 0, CostKind, 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. // Add on an overhead cost for using gathers/scatters.
// TODO: At the moment this is applied unilaterally for all CPUs, but at some // TODO: At the moment this is applied unilaterally for all CPUs, but at some
// point we may want a per-CPU overhead. // point we may want a per-CPU overhead.
@ -2257,7 +2257,7 @@ InstructionCost AArch64TTIImpl::getMemoryOpCost(unsigned Opcode, Type *Ty,
MaybeAlign Alignment, MaybeAlign Alignment,
unsigned AddressSpace, unsigned AddressSpace,
TTI::TargetCostKind CostKind, TTI::TargetCostKind CostKind,
TTI::OperandValueKind OpdInfo, TTI::OperandValueInfo OpInfo,
const Instruction *I) { const Instruction *I) {
EVT VT = TLI->getValueType(DL, Ty, true); EVT VT = TLI->getValueType(DL, Ty, true);
// Type legalization can't handle structs // Type legalization can't handle structs

View File

@ -209,7 +209,7 @@ public:
InstructionCost InstructionCost
getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment, getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
unsigned AddressSpace, TTI::TargetCostKind CostKind, unsigned AddressSpace, TTI::TargetCostKind CostKind,
TTI::OperandValueKind OpdInfo = TTI::OK_AnyValue, TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
const Instruction *I = nullptr); const Instruction *I = nullptr);
InstructionCost getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys); InstructionCost getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys);

View File

@ -1451,7 +1451,7 @@ InstructionCost ARMTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
MaybeAlign Alignment, MaybeAlign Alignment,
unsigned AddressSpace, unsigned AddressSpace,
TTI::TargetCostKind CostKind, TTI::TargetCostKind CostKind,
TTI::OperandValueKind OpdInfo, TTI::OperandValueInfo OpInfo,
const Instruction *I) { const Instruction *I) {
// TODO: Handle other cost kinds. // TODO: Handle other cost kinds.
if (CostKind != TTI::TCK_RecipThroughput) if (CostKind != TTI::TCK_RecipThroughput)
@ -1491,7 +1491,7 @@ InstructionCost ARMTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
? ST->getMVEVectorCostFactor(CostKind) ? ST->getMVEVectorCostFactor(CostKind)
: 1; : 1;
return BaseCost * BaseT::getMemoryOpCost(Opcode, Src, Alignment, AddressSpace, return BaseCost * BaseT::getMemoryOpCost(Opcode, Src, Alignment, AddressSpace,
CostKind, OpdInfo, I); CostKind, OpInfo, I);
} }
InstructionCost InstructionCost

View File

@ -255,7 +255,7 @@ public:
InstructionCost InstructionCost
getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment, getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
unsigned AddressSpace, TTI::TargetCostKind CostKind, unsigned AddressSpace, TTI::TargetCostKind CostKind,
TTI::OperandValueKind OpdInfo = TTI::OK_AnyValue, TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
const Instruction *I = nullptr); const Instruction *I = nullptr);
InstructionCost getMaskedMemoryOpCost(unsigned Opcode, Type *Src, InstructionCost getMaskedMemoryOpCost(unsigned Opcode, Type *Src,

View File

@ -161,7 +161,7 @@ InstructionCost HexagonTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
MaybeAlign Alignment, MaybeAlign Alignment,
unsigned AddressSpace, unsigned AddressSpace,
TTI::TargetCostKind CostKind, TTI::TargetCostKind CostKind,
TTI::OperandValueKind OpdInfo, TTI::OperandValueInfo OpInfo,
const Instruction *I) { const Instruction *I) {
assert(Opcode == Instruction::Load || Opcode == Instruction::Store); assert(Opcode == Instruction::Load || Opcode == Instruction::Store);
// TODO: Handle other cost kinds. // TODO: Handle other cost kinds.
@ -170,7 +170,7 @@ InstructionCost HexagonTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
if (Opcode == Instruction::Store) if (Opcode == Instruction::Store)
return BaseT::getMemoryOpCost(Opcode, Src, Alignment, AddressSpace, return BaseT::getMemoryOpCost(Opcode, Src, Alignment, AddressSpace,
CostKind, OpdInfo, I); CostKind, OpInfo, I);
if (Src->isVectorTy()) { if (Src->isVectorTy()) {
VectorType *VecTy = cast<VectorType>(Src); VectorType *VecTy = cast<VectorType>(Src);
@ -211,7 +211,7 @@ InstructionCost HexagonTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
} }
return BaseT::getMemoryOpCost(Opcode, Src, Alignment, AddressSpace, CostKind, return BaseT::getMemoryOpCost(Opcode, Src, Alignment, AddressSpace, CostKind,
OpdInfo, I); OpInfo, I);
} }
InstructionCost InstructionCost

View File

@ -119,7 +119,7 @@ public:
InstructionCost InstructionCost
getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment, getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
unsigned AddressSpace, TTI::TargetCostKind CostKind, unsigned AddressSpace, TTI::TargetCostKind CostKind,
TTI::OperandValueKind OpdInfo = TTI::OK_AnyValue, TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
const Instruction *I = nullptr); const Instruction *I = nullptr);
InstructionCost getMaskedMemoryOpCost(unsigned Opcode, Type *Src, InstructionCost getMaskedMemoryOpCost(unsigned Opcode, Type *Src,
Align Alignment, unsigned AddressSpace, Align Alignment, unsigned AddressSpace,

View File

@ -1144,7 +1144,7 @@ InstructionCost PPCTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
MaybeAlign Alignment, MaybeAlign Alignment,
unsigned AddressSpace, unsigned AddressSpace,
TTI::TargetCostKind CostKind, TTI::TargetCostKind CostKind,
TTI::OperandValueKind OpdInfo, TTI::OperandValueInfo OpInfo,
const Instruction *I) { const Instruction *I) {
InstructionCost CostFactor = vectorCostAdjustmentFactor(Opcode, Src, nullptr); InstructionCost CostFactor = vectorCostAdjustmentFactor(Opcode, Src, nullptr);

View File

@ -130,7 +130,7 @@ public:
InstructionCost InstructionCost
getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment, getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
unsigned AddressSpace, TTI::TargetCostKind CostKind, unsigned AddressSpace, TTI::TargetCostKind CostKind,
TTI::OperandValueKind OpdInfo = TTI::OK_AnyValue, TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
const Instruction *I = nullptr); const Instruction *I = nullptr);
InstructionCost getInterleavedMemoryOpCost( InstructionCost getInterleavedMemoryOpCost(
unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices, unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,

View File

@ -247,7 +247,7 @@ InstructionCost RISCVTTIImpl::getGatherScatterOpCost(
auto &VTy = *cast<VectorType>(DataTy); auto &VTy = *cast<VectorType>(DataTy);
InstructionCost MemOpCost = InstructionCost MemOpCost =
getMemoryOpCost(Opcode, VTy.getElementType(), Alignment, 0, CostKind, getMemoryOpCost(Opcode, VTy.getElementType(), Alignment, 0, CostKind,
TTI::OK_AnyValue, I); {TTI::OK_AnyValue, TTI::OP_None}, I);
unsigned NumLoads = getEstimatedVLFor(&VTy); unsigned NumLoads = getEstimatedVLFor(&VTy);
return NumLoads * MemOpCost; return NumLoads * MemOpCost;
} }
@ -530,14 +530,13 @@ InstructionCost RISCVTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
MaybeAlign Alignment, MaybeAlign Alignment,
unsigned AddressSpace, unsigned AddressSpace,
TTI::TargetCostKind CostKind, TTI::TargetCostKind CostKind,
TTI::OperandValueKind OpdKind, TTI::OperandValueInfo OpInfo,
const Instruction *I) { const Instruction *I) {
const TTI::OperandValueInfo OpInfo = {OpdKind, TTI::OP_None};
InstructionCost Cost = 0; InstructionCost Cost = 0;
if (Opcode == Instruction::Store && isa<VectorType>(Src) && OpInfo.isConstant()) if (Opcode == Instruction::Store && isa<VectorType>(Src) && OpInfo.isConstant())
Cost += getVectorImmCost(cast<VectorType>(Src), OpInfo, CostKind); Cost += getVectorImmCost(cast<VectorType>(Src), OpInfo, CostKind);
return Cost + BaseT::getMemoryOpCost(Opcode, Src, Alignment, AddressSpace, return Cost + BaseT::getMemoryOpCost(Opcode, Src, Alignment, AddressSpace,
CostKind, OpInfo.Kind, I); CostKind, OpInfo, I);
} }
void RISCVTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE, void RISCVTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE,

View File

@ -135,7 +135,7 @@ public:
InstructionCost InstructionCost
getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment, getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
unsigned AddressSpace, TTI::TargetCostKind CostKind, unsigned AddressSpace, TTI::TargetCostKind CostKind,
TTI::OperandValueKind OpdInfo = TTI::OK_AnyValue, TTI::OperandValueInfo OpdInfo = {TTI::OK_AnyValue, TTI::OP_None},
const Instruction *I = nullptr); const Instruction *I = nullptr);
bool isElementTypeLegalForScalableVector(Type *Ty) const { bool isElementTypeLegalForScalableVector(Type *Ty) const {

View File

@ -1108,7 +1108,7 @@ InstructionCost SystemZTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
MaybeAlign Alignment, MaybeAlign Alignment,
unsigned AddressSpace, unsigned AddressSpace,
TTI::TargetCostKind CostKind, TTI::TargetCostKind CostKind,
TTI::OperandValueKind OpdInfo, TTI::OperandValueInfo OpInfo,
const Instruction *I) { const Instruction *I) {
assert(!Src->isVoidTy() && "Invalid type"); assert(!Src->isVoidTy() && "Invalid type");

View File

@ -113,7 +113,7 @@ public:
InstructionCost InstructionCost
getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment, getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
unsigned AddressSpace, TTI::TargetCostKind CostKind, unsigned AddressSpace, TTI::TargetCostKind CostKind,
TTI::OperandValueKind OpdInfo = TTI::OK_AnyValue, TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
const Instruction *I = nullptr); const Instruction *I = nullptr);
InstructionCost getInterleavedMemoryOpCost( InstructionCost getInterleavedMemoryOpCost(

View File

@ -4029,10 +4029,8 @@ InstructionCost X86TTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
MaybeAlign Alignment, MaybeAlign Alignment,
unsigned AddressSpace, unsigned AddressSpace,
TTI::TargetCostKind CostKind, TTI::TargetCostKind CostKind,
TTI::OperandValueKind OpdKind, TTI::OperandValueInfo OpInfo,
const Instruction *I) { const Instruction *I) {
const TTI::OperandValueInfo OpInfo = {OpdKind, TTI::OP_None};
// TODO: Handle other cost kinds. // TODO: Handle other cost kinds.
if (CostKind != TTI::TCK_RecipThroughput) { if (CostKind != TTI::TCK_RecipThroughput) {
if (auto *SI = dyn_cast_or_null<StoreInst>(I)) { if (auto *SI = dyn_cast_or_null<StoreInst>(I)) {

View File

@ -158,7 +158,7 @@ public:
InstructionCost InstructionCost
getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment, getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
unsigned AddressSpace, TTI::TargetCostKind CostKind, unsigned AddressSpace, TTI::TargetCostKind CostKind,
TTI::OperandValueKind OpdInfo = TTI::OK_AnyValue, TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
const Instruction *I = nullptr); const Instruction *I = nullptr);
InstructionCost getMaskedMemoryOpCost(unsigned Opcode, Type *Src, InstructionCost getMaskedMemoryOpCost(unsigned Opcode, Type *Src,
Align Alignment, unsigned AddressSpace, Align Alignment, unsigned AddressSpace,