forked from OSchip/llvm-project
[TTI] Use OperandValueInfo in getMemoryOpCost client api [nfc]
This removes the last use of OperandValueKind from the client side API, and (once this is fully plumbed through TTI implementation) allow use of the same properties in store costing as arithmetic costing.
This commit is contained in:
parent
71771f8510
commit
27d3321c4f
|
@ -1182,7 +1182,7 @@ public:
|
||||||
getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
|
getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
|
||||||
unsigned AddressSpace,
|
unsigned AddressSpace,
|
||||||
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput,
|
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput,
|
||||||
OperandValueKind OpdInfo = OK_AnyValue,
|
OperandValueInfo OpdInfo = {OK_AnyValue, OP_None},
|
||||||
const Instruction *I = nullptr) const;
|
const Instruction *I = nullptr) const;
|
||||||
|
|
||||||
/// \return The cost of VP Load and Store instructions.
|
/// \return The cost of VP Load and Store instructions.
|
||||||
|
|
|
@ -904,12 +904,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::OperandValueKind OpdInfo,
|
TTI::TargetCostKind CostKind, TTI::OperandValueInfo OpdInfo,
|
||||||
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, I);
|
Opcode, Src, Alignment, AddressSpace, CostKind, OpdInfo.Kind, I);
|
||||||
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
||||||
return Cost;
|
return Cost;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6398,9 +6398,9 @@ LoopVectorizationCostModel::getConsecutiveMemOpCost(Instruction *I,
|
||||||
Cost += TTI.getMaskedMemoryOpCost(I->getOpcode(), VectorTy, Alignment, AS,
|
Cost += TTI.getMaskedMemoryOpCost(I->getOpcode(), VectorTy, Alignment, AS,
|
||||||
CostKind);
|
CostKind);
|
||||||
} else {
|
} else {
|
||||||
TTI::OperandValueKind OpVK = TTI::getOperandInfo(I->getOperand(0)).Kind;
|
TTI::OperandValueInfo OpInfo = TTI::getOperandInfo(I->getOperand(0));
|
||||||
Cost += TTI.getMemoryOpCost(I->getOpcode(), VectorTy, Alignment, AS,
|
Cost += TTI.getMemoryOpCost(I->getOpcode(), VectorTy, Alignment, AS,
|
||||||
CostKind, OpVK, I);
|
CostKind, OpInfo, I);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Reverse = ConsecutiveStride < 0;
|
bool Reverse = ConsecutiveStride < 0;
|
||||||
|
@ -6679,10 +6679,10 @@ LoopVectorizationCostModel::getMemoryInstructionCost(Instruction *I,
|
||||||
const Align Alignment = getLoadStoreAlignment(I);
|
const Align Alignment = getLoadStoreAlignment(I);
|
||||||
unsigned AS = getLoadStoreAddressSpace(I);
|
unsigned AS = getLoadStoreAddressSpace(I);
|
||||||
|
|
||||||
TTI::OperandValueKind OpVK = TTI::getOperandInfo(I->getOperand(0)).Kind;
|
TTI::OperandValueInfo OpInfo = TTI::getOperandInfo(I->getOperand(0));
|
||||||
return TTI.getAddressComputationCost(ValTy) +
|
return TTI.getAddressComputationCost(ValTy) +
|
||||||
TTI.getMemoryOpCost(I->getOpcode(), ValTy, Alignment, AS,
|
TTI.getMemoryOpCost(I->getOpcode(), ValTy, Alignment, AS,
|
||||||
TTI::TCK_RecipThroughput, OpVK, I);
|
TTI::TCK_RecipThroughput, OpInfo, I);
|
||||||
}
|
}
|
||||||
return getWideningCost(I, VF);
|
return getWideningCost(I, VF);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6048,7 +6048,8 @@ InstructionCost BoUpSLP::getEntryCost(const TreeEntry *E,
|
||||||
auto *LI = cast<LoadInst>(V);
|
auto *LI = cast<LoadInst>(V);
|
||||||
ScalarsCost += TTI->getMemoryOpCost(
|
ScalarsCost += TTI->getMemoryOpCost(
|
||||||
Instruction::Load, LI->getType(), LI->getAlign(),
|
Instruction::Load, LI->getType(), LI->getAlign(),
|
||||||
LI->getPointerAddressSpace(), CostKind, TTI::OK_AnyValue, LI);
|
LI->getPointerAddressSpace(), CostKind,
|
||||||
|
{TTI::OK_AnyValue, TTI::OP_None}, LI);
|
||||||
}
|
}
|
||||||
auto *LI = cast<LoadInst>(E->getMainOp());
|
auto *LI = cast<LoadInst>(E->getMainOp());
|
||||||
auto *LoadTy = FixedVectorType::get(LI->getType(), VF);
|
auto *LoadTy = FixedVectorType::get(LI->getType(), VF);
|
||||||
|
@ -6056,7 +6057,8 @@ InstructionCost BoUpSLP::getEntryCost(const TreeEntry *E,
|
||||||
GatherCost += VectorizedCnt *
|
GatherCost += VectorizedCnt *
|
||||||
TTI->getMemoryOpCost(Instruction::Load, LoadTy, Alignment,
|
TTI->getMemoryOpCost(Instruction::Load, LoadTy, Alignment,
|
||||||
LI->getPointerAddressSpace(),
|
LI->getPointerAddressSpace(),
|
||||||
CostKind, TTI::OK_AnyValue, LI);
|
CostKind, {TTI::OK_AnyValue,
|
||||||
|
TTI::OP_None}, LI);
|
||||||
GatherCost += ScatterVectorizeCnt *
|
GatherCost += ScatterVectorizeCnt *
|
||||||
TTI->getGatherScatterOpCost(
|
TTI->getGatherScatterOpCost(
|
||||||
Instruction::Load, LoadTy, LI->getPointerOperand(),
|
Instruction::Load, LoadTy, LI->getPointerOperand(),
|
||||||
|
@ -6462,7 +6464,7 @@ InstructionCost BoUpSLP::getEntryCost(const TreeEntry *E,
|
||||||
Align Alignment = cast<LoadInst>(VL0)->getAlign();
|
Align Alignment = cast<LoadInst>(VL0)->getAlign();
|
||||||
InstructionCost ScalarEltCost =
|
InstructionCost ScalarEltCost =
|
||||||
TTI->getMemoryOpCost(Instruction::Load, ScalarTy, Alignment, 0,
|
TTI->getMemoryOpCost(Instruction::Load, ScalarTy, Alignment, 0,
|
||||||
CostKind, TTI::OK_AnyValue, VL0);
|
CostKind, {TTI::OK_AnyValue, TTI::OP_None}, VL0);
|
||||||
if (NeedToShuffleReuses) {
|
if (NeedToShuffleReuses) {
|
||||||
CommonCost -= (EntryVF - VL.size()) * ScalarEltCost;
|
CommonCost -= (EntryVF - VL.size()) * ScalarEltCost;
|
||||||
}
|
}
|
||||||
|
@ -6470,7 +6472,7 @@ InstructionCost BoUpSLP::getEntryCost(const TreeEntry *E,
|
||||||
InstructionCost VecLdCost;
|
InstructionCost VecLdCost;
|
||||||
if (E->State == TreeEntry::Vectorize) {
|
if (E->State == TreeEntry::Vectorize) {
|
||||||
VecLdCost = TTI->getMemoryOpCost(Instruction::Load, VecTy, Alignment, 0,
|
VecLdCost = TTI->getMemoryOpCost(Instruction::Load, VecTy, Alignment, 0,
|
||||||
CostKind, TTI::OK_AnyValue, VL0);
|
CostKind, {TTI::OK_AnyValue, TTI::OP_None}, VL0);
|
||||||
} else {
|
} else {
|
||||||
assert(E->State == TreeEntry::ScatterVectorize && "Unknown EntryState");
|
assert(E->State == TreeEntry::ScatterVectorize && "Unknown EntryState");
|
||||||
Align CommonAlignment = Alignment;
|
Align CommonAlignment = Alignment;
|
||||||
|
@ -6490,11 +6492,11 @@ InstructionCost BoUpSLP::getEntryCost(const TreeEntry *E,
|
||||||
auto *SI =
|
auto *SI =
|
||||||
cast<StoreInst>(IsReorder ? VL[E->ReorderIndices.front()] : VL0);
|
cast<StoreInst>(IsReorder ? VL[E->ReorderIndices.front()] : VL0);
|
||||||
Align Alignment = SI->getAlign();
|
Align Alignment = SI->getAlign();
|
||||||
TTI::OperandValueKind OpVK = TTI::getOperandInfo(SI->getOperand(0)).Kind;
|
TTI::OperandValueInfo OpInfo = TTI::getOperandInfo(SI->getOperand(0));
|
||||||
InstructionCost ScalarEltCost = TTI->getMemoryOpCost(
|
InstructionCost ScalarEltCost = TTI->getMemoryOpCost(
|
||||||
Instruction::Store, ScalarTy, Alignment, 0, CostKind, OpVK, VL0);
|
Instruction::Store, ScalarTy, Alignment, 0, CostKind, OpInfo, VL0);
|
||||||
InstructionCost ScalarStCost = VecTy->getNumElements() * ScalarEltCost;
|
InstructionCost ScalarStCost = VecTy->getNumElements() * ScalarEltCost;
|
||||||
OpVK = TTI::OK_AnyValue;
|
TTI::OperandValueKind OpVK = TTI::OK_AnyValue;
|
||||||
if (all_of(E->Scalars,
|
if (all_of(E->Scalars,
|
||||||
[](Value *V) {
|
[](Value *V) {
|
||||||
return isConstant(cast<Instruction>(V)->getOperand(0));
|
return isConstant(cast<Instruction>(V)->getOperand(0));
|
||||||
|
@ -6505,7 +6507,8 @@ InstructionCost BoUpSLP::getEntryCost(const TreeEntry *E,
|
||||||
}))
|
}))
|
||||||
OpVK = TTI::OK_NonUniformConstantValue;
|
OpVK = TTI::OK_NonUniformConstantValue;
|
||||||
InstructionCost VecStCost = TTI->getMemoryOpCost(
|
InstructionCost VecStCost = TTI->getMemoryOpCost(
|
||||||
Instruction::Store, VecTy, Alignment, 0, CostKind, OpVK, VL0);
|
Instruction::Store, VecTy, Alignment, 0, CostKind,
|
||||||
|
{OpVK, TTI::OP_None}, VL0);
|
||||||
LLVM_DEBUG(dumpTreeCosts(E, CommonCost, VecStCost, ScalarStCost));
|
LLVM_DEBUG(dumpTreeCosts(E, CommonCost, VecStCost, ScalarStCost));
|
||||||
return CommonCost + VecStCost - ScalarStCost;
|
return CommonCost + VecStCost - ScalarStCost;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue