forked from OSchip/llvm-project
[Alignment][NFC] Migrate TTI::getMaskedMemoryOpCost to Align
This is patch is part of a series to introduce an Alignment type. See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html See this patch for the introduction of the type: https://reviews.llvm.org/D64790 Differential Revision: https://reviews.llvm.org/D82569
This commit is contained in:
parent
edcfef8fee
commit
7e1f79c3de
|
@ -1024,7 +1024,7 @@ public:
|
||||||
|
|
||||||
/// \return The cost of masked Load and Store instructions.
|
/// \return The cost of masked Load and Store instructions.
|
||||||
int getMaskedMemoryOpCost(
|
int getMaskedMemoryOpCost(
|
||||||
unsigned Opcode, Type *Src, unsigned Alignment, unsigned AddressSpace,
|
unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,
|
||||||
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput) const;
|
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput) const;
|
||||||
|
|
||||||
/// \return The cost of Gather or Scatter operation
|
/// \return The cost of Gather or Scatter operation
|
||||||
|
@ -1426,8 +1426,7 @@ public:
|
||||||
unsigned AddressSpace,
|
unsigned AddressSpace,
|
||||||
TTI::TargetCostKind CostKind,
|
TTI::TargetCostKind CostKind,
|
||||||
const Instruction *I) = 0;
|
const Instruction *I) = 0;
|
||||||
virtual int getMaskedMemoryOpCost(unsigned Opcode, Type *Src,
|
virtual int getMaskedMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
|
||||||
unsigned Alignment,
|
|
||||||
unsigned AddressSpace,
|
unsigned AddressSpace,
|
||||||
TTI::TargetCostKind CostKind) = 0;
|
TTI::TargetCostKind CostKind) = 0;
|
||||||
virtual int getGatherScatterOpCost(unsigned Opcode, Type *DataTy,
|
virtual int getGatherScatterOpCost(unsigned Opcode, Type *DataTy,
|
||||||
|
@ -1844,7 +1843,7 @@ public:
|
||||||
return Impl.getMemoryOpCost(Opcode, Src, Alignment, AddressSpace,
|
return Impl.getMemoryOpCost(Opcode, Src, Alignment, AddressSpace,
|
||||||
CostKind, I);
|
CostKind, I);
|
||||||
}
|
}
|
||||||
int getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
|
int getMaskedMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
|
||||||
unsigned AddressSpace,
|
unsigned AddressSpace,
|
||||||
TTI::TargetCostKind CostKind) override {
|
TTI::TargetCostKind CostKind) override {
|
||||||
return Impl.getMaskedMemoryOpCost(Opcode, Src, Alignment, AddressSpace,
|
return Impl.getMaskedMemoryOpCost(Opcode, Src, Alignment, AddressSpace,
|
||||||
|
|
|
@ -464,7 +464,7 @@ public:
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
|
unsigned getMaskedMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
|
||||||
unsigned AddressSpace,
|
unsigned AddressSpace,
|
||||||
TTI::TargetCostKind CostKind) {
|
TTI::TargetCostKind CostKind) {
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -963,10 +963,10 @@ public:
|
||||||
unsigned Cost;
|
unsigned Cost;
|
||||||
if (UseMaskForCond || UseMaskForGaps)
|
if (UseMaskForCond || UseMaskForGaps)
|
||||||
Cost = static_cast<T *>(this)->getMaskedMemoryOpCost(
|
Cost = static_cast<T *>(this)->getMaskedMemoryOpCost(
|
||||||
Opcode, VecTy, Alignment, AddressSpace, CostKind);
|
Opcode, VecTy, Align(Alignment), AddressSpace, CostKind);
|
||||||
else
|
else
|
||||||
Cost = static_cast<T *>(this)->getMemoryOpCost(
|
Cost = static_cast<T *>(this)->getMemoryOpCost(
|
||||||
Opcode, VecTy, MaybeAlign(Alignment), AddressSpace, CostKind);
|
Opcode, VecTy, Align(Alignment), AddressSpace, CostKind);
|
||||||
|
|
||||||
// Legalize the vector type, and get the legalized and unlegalized type
|
// Legalize the vector type, and get the legalized and unlegalized type
|
||||||
// sizes.
|
// sizes.
|
||||||
|
@ -1389,13 +1389,13 @@ public:
|
||||||
return 0;
|
return 0;
|
||||||
case Intrinsic::masked_store: {
|
case Intrinsic::masked_store: {
|
||||||
Type *Ty = Tys[0];
|
Type *Ty = Tys[0];
|
||||||
unsigned TyAlign = ConcreteTTI->DL.getABITypeAlignment(Ty);
|
Align TyAlign = ConcreteTTI->DL.getABITypeAlign(Ty);
|
||||||
return ConcreteTTI->getMaskedMemoryOpCost(Instruction::Store, Ty, TyAlign,
|
return ConcreteTTI->getMaskedMemoryOpCost(Instruction::Store, Ty, TyAlign,
|
||||||
0, CostKind);
|
0, CostKind);
|
||||||
}
|
}
|
||||||
case Intrinsic::masked_load: {
|
case Intrinsic::masked_load: {
|
||||||
Type *Ty = RetTy;
|
Type *Ty = RetTy;
|
||||||
unsigned TyAlign = ConcreteTTI->DL.getABITypeAlignment(Ty);
|
Align TyAlign = ConcreteTTI->DL.getABITypeAlign(Ty);
|
||||||
return ConcreteTTI->getMaskedMemoryOpCost(Instruction::Load, Ty, TyAlign,
|
return ConcreteTTI->getMaskedMemoryOpCost(Instruction::Load, Ty, TyAlign,
|
||||||
0, CostKind);
|
0, CostKind);
|
||||||
}
|
}
|
||||||
|
|
|
@ -757,9 +757,8 @@ int TargetTransformInfo::getMemoryOpCost(unsigned Opcode, Type *Src,
|
||||||
return Cost;
|
return Cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TargetTransformInfo::getMaskedMemoryOpCost(unsigned Opcode, Type *Src,
|
int TargetTransformInfo::getMaskedMemoryOpCost(
|
||||||
unsigned Alignment,
|
unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,
|
||||||
unsigned AddressSpace,
|
|
||||||
TTI::TargetCostKind CostKind) const {
|
TTI::TargetCostKind CostKind) const {
|
||||||
int Cost =
|
int Cost =
|
||||||
TTIImpl->getMaskedMemoryOpCost(Opcode, Src, Alignment, AddressSpace,
|
TTIImpl->getMaskedMemoryOpCost(Opcode, Src, Alignment, AddressSpace,
|
||||||
|
|
|
@ -200,8 +200,9 @@ unsigned HexagonTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
|
||||||
CostKind, I);
|
CostKind, I);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned HexagonTTIImpl::getMaskedMemoryOpCost(unsigned Opcode,
|
unsigned HexagonTTIImpl::getMaskedMemoryOpCost(unsigned Opcode, Type *Src,
|
||||||
Type *Src, unsigned Alignment, unsigned AddressSpace,
|
Align Alignment,
|
||||||
|
unsigned AddressSpace,
|
||||||
TTI::TargetCostKind CostKind) {
|
TTI::TargetCostKind CostKind) {
|
||||||
return BaseT::getMaskedMemoryOpCost(Opcode, Src, Alignment, AddressSpace,
|
return BaseT::getMaskedMemoryOpCost(Opcode, Src, Alignment, AddressSpace,
|
||||||
CostKind);
|
CostKind);
|
||||||
|
|
|
@ -115,7 +115,8 @@ public:
|
||||||
unsigned AddressSpace,
|
unsigned AddressSpace,
|
||||||
TTI::TargetCostKind CostKind,
|
TTI::TargetCostKind CostKind,
|
||||||
const Instruction *I = nullptr);
|
const Instruction *I = nullptr);
|
||||||
unsigned getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
|
unsigned
|
||||||
|
getMaskedMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
|
||||||
unsigned AddressSpace,
|
unsigned AddressSpace,
|
||||||
TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency);
|
TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency);
|
||||||
unsigned getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index,
|
unsigned getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index,
|
||||||
|
|
|
@ -3031,8 +3031,7 @@ int X86TTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
|
||||||
}
|
}
|
||||||
|
|
||||||
int X86TTIImpl::getMaskedMemoryOpCost(unsigned Opcode, Type *SrcTy,
|
int X86TTIImpl::getMaskedMemoryOpCost(unsigned Opcode, Type *SrcTy,
|
||||||
unsigned Alignment,
|
Align Alignment, unsigned AddressSpace,
|
||||||
unsigned AddressSpace,
|
|
||||||
TTI::TargetCostKind CostKind) {
|
TTI::TargetCostKind CostKind) {
|
||||||
bool IsLoad = (Instruction::Load == Opcode);
|
bool IsLoad = (Instruction::Load == Opcode);
|
||||||
bool IsStore = (Instruction::Store == Opcode);
|
bool IsStore = (Instruction::Store == Opcode);
|
||||||
|
@ -3040,14 +3039,13 @@ int X86TTIImpl::getMaskedMemoryOpCost(unsigned Opcode, Type *SrcTy,
|
||||||
VectorType *SrcVTy = dyn_cast<VectorType>(SrcTy);
|
VectorType *SrcVTy = dyn_cast<VectorType>(SrcTy);
|
||||||
if (!SrcVTy)
|
if (!SrcVTy)
|
||||||
// To calculate scalar take the regular cost, without mask
|
// To calculate scalar take the regular cost, without mask
|
||||||
return getMemoryOpCost(Opcode, SrcTy, MaybeAlign(Alignment), AddressSpace,
|
return getMemoryOpCost(Opcode, SrcTy, Alignment, AddressSpace, CostKind);
|
||||||
CostKind);
|
|
||||||
|
|
||||||
unsigned NumElem = SrcVTy->getNumElements();
|
unsigned NumElem = SrcVTy->getNumElements();
|
||||||
auto *MaskTy =
|
auto *MaskTy =
|
||||||
FixedVectorType::get(Type::getInt8Ty(SrcVTy->getContext()), NumElem);
|
FixedVectorType::get(Type::getInt8Ty(SrcVTy->getContext()), NumElem);
|
||||||
if ((IsLoad && !isLegalMaskedLoad(SrcVTy, Align(Alignment))) ||
|
if ((IsLoad && !isLegalMaskedLoad(SrcVTy, Alignment)) ||
|
||||||
(IsStore && !isLegalMaskedStore(SrcVTy, Align(Alignment))) ||
|
(IsStore && !isLegalMaskedStore(SrcVTy, Alignment)) ||
|
||||||
!isPowerOf2_32(NumElem)) {
|
!isPowerOf2_32(NumElem)) {
|
||||||
// Scalarization
|
// Scalarization
|
||||||
APInt DemandedElts = APInt::getAllOnesValue(NumElem);
|
APInt DemandedElts = APInt::getAllOnesValue(NumElem);
|
||||||
|
@ -3062,8 +3060,7 @@ int X86TTIImpl::getMaskedMemoryOpCost(unsigned Opcode, Type *SrcTy,
|
||||||
getScalarizationOverhead(SrcVTy, DemandedElts, IsLoad, IsStore);
|
getScalarizationOverhead(SrcVTy, DemandedElts, IsLoad, IsStore);
|
||||||
int MemopCost =
|
int MemopCost =
|
||||||
NumElem * BaseT::getMemoryOpCost(Opcode, SrcVTy->getScalarType(),
|
NumElem * BaseT::getMemoryOpCost(Opcode, SrcVTy->getScalarType(),
|
||||||
MaybeAlign(Alignment), AddressSpace,
|
Alignment, AddressSpace, CostKind);
|
||||||
CostKind);
|
|
||||||
return MemopCost + ValueSplitCost + MaskSplitCost + MaskCmpCost;
|
return MemopCost + ValueSplitCost + MaskSplitCost + MaskCmpCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -141,8 +141,8 @@ public:
|
||||||
unsigned AddressSpace,
|
unsigned AddressSpace,
|
||||||
TTI::TargetCostKind CostKind,
|
TTI::TargetCostKind CostKind,
|
||||||
const Instruction *I = nullptr);
|
const Instruction *I = nullptr);
|
||||||
int getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
|
int getMaskedMemoryOpCost(
|
||||||
unsigned AddressSpace,
|
unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,
|
||||||
TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency);
|
TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency);
|
||||||
int getGatherScatterOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr,
|
int getGatherScatterOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr,
|
||||||
bool VariableMask, unsigned Alignment,
|
bool VariableMask, unsigned Alignment,
|
||||||
|
|
|
@ -5890,8 +5890,8 @@ unsigned LoopVectorizationCostModel::getConsecutiveMemOpCost(Instruction *I,
|
||||||
const Align Alignment = getLoadStoreAlignment(I);
|
const Align Alignment = getLoadStoreAlignment(I);
|
||||||
unsigned Cost = 0;
|
unsigned Cost = 0;
|
||||||
if (Legal->isMaskRequired(I))
|
if (Legal->isMaskRequired(I))
|
||||||
Cost += TTI.getMaskedMemoryOpCost(I->getOpcode(), VectorTy,
|
Cost += TTI.getMaskedMemoryOpCost(I->getOpcode(), VectorTy, Alignment, AS,
|
||||||
Alignment.value(), AS, CostKind);
|
CostKind);
|
||||||
else
|
else
|
||||||
Cost += TTI.getMemoryOpCost(I->getOpcode(), VectorTy, Alignment, AS,
|
Cost += TTI.getMemoryOpCost(I->getOpcode(), VectorTy, Alignment, AS,
|
||||||
CostKind, I);
|
CostKind, I);
|
||||||
|
|
Loading…
Reference in New Issue