Skip to content

Commit 1b4c37f

Browse files
committed
[TTI][X86] getGSVectorCost/getGSScalarCost - add CostKind to the function arguments.
Initial refactor - only getGSScalarCost can actually use CostKind so far, and currently both are only ever set to TCK_RecipThroughput.
1 parent 9a16c12 commit 1b4c37f

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

llvm/lib/Target/X86/X86TargetTransformInfo.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5698,8 +5698,10 @@ int X86TTIImpl::getScatterOverhead() const {
56985698

56995699
// Return an average cost of Gather / Scatter instruction, maybe improved later.
57005700
// FIXME: Add TargetCostKind support.
5701-
InstructionCost X86TTIImpl::getGSVectorCost(unsigned Opcode, Type *SrcVTy,
5702-
const Value *Ptr, Align Alignment,
5701+
InstructionCost X86TTIImpl::getGSVectorCost(unsigned Opcode,
5702+
TTI::TargetCostKind CostKind,
5703+
Type *SrcVTy, const Value *Ptr,
5704+
Align Alignment,
57035705
unsigned AddressSpace) {
57045706

57055707
assert(isa<VectorType>(SrcVTy) && "Unexpected type in getGSVectorCost");
@@ -5750,8 +5752,8 @@ InstructionCost X86TTIImpl::getGSVectorCost(unsigned Opcode, Type *SrcVTy,
57505752
// Handle splitting of vector of pointers
57515753
auto *SplitSrcTy =
57525754
FixedVectorType::get(SrcVTy->getScalarType(), VF / SplitFactor);
5753-
return SplitFactor * getGSVectorCost(Opcode, SplitSrcTy, Ptr, Alignment,
5754-
AddressSpace);
5755+
return SplitFactor * getGSVectorCost(Opcode, CostKind, SplitSrcTy, Ptr,
5756+
Alignment, AddressSpace);
57555757
}
57565758

57575759
// The gather / scatter cost is given by Intel architects. It is a rough
@@ -5771,15 +5773,14 @@ InstructionCost X86TTIImpl::getGSVectorCost(unsigned Opcode, Type *SrcVTy,
57715773
/// VariableMask - The mask is non-constant at compile time.
57725774
/// Alignment - Alignment for one element.
57735775
/// AddressSpace - pointer[s] address space.
5774-
///
5775-
/// FIXME: Add TargetCostKind support.
5776-
InstructionCost X86TTIImpl::getGSScalarCost(unsigned Opcode, Type *SrcVTy,
5777-
bool VariableMask, Align Alignment,
5776+
InstructionCost X86TTIImpl::getGSScalarCost(unsigned Opcode,
5777+
TTI::TargetCostKind CostKind,
5778+
Type *SrcVTy, bool VariableMask,
5779+
Align Alignment,
57785780
unsigned AddressSpace) {
57795781
Type *ScalarTy = SrcVTy->getScalarType();
57805782
unsigned VF = cast<FixedVectorType>(SrcVTy)->getNumElements();
57815783
APInt DemandedElts = APInt::getAllOnes(VF);
5782-
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
57835784

57845785
InstructionCost MaskUnpackCost = 0;
57855786
if (VariableMask) {
@@ -5848,10 +5849,11 @@ InstructionCost X86TTIImpl::getGatherScatterOpCost(
58485849
(!isLegalMaskedScatter(SrcVTy, Align(Alignment)) ||
58495850
forceScalarizeMaskedScatter(cast<VectorType>(SrcVTy),
58505851
Align(Alignment)))))
5851-
return getGSScalarCost(Opcode, SrcVTy, VariableMask, Alignment,
5852+
return getGSScalarCost(Opcode, CostKind, SrcVTy, VariableMask, Alignment,
58525853
AddressSpace);
58535854

5854-
return getGSVectorCost(Opcode, SrcVTy, Ptr, Alignment, AddressSpace);
5855+
return getGSVectorCost(Opcode, CostKind, SrcVTy, Ptr, Alignment,
5856+
AddressSpace);
58555857
}
58565858

58575859
bool X86TTIImpl::isLSRCostLess(const TargetTransformInfo::LSRCost &C1,

llvm/lib/Target/X86/X86TargetTransformInfo.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,12 @@ class X86TTIImpl : public BasicTTIImplBase<X86TTIImpl> {
294294

295295
private:
296296
bool supportsGather() const;
297-
InstructionCost getGSScalarCost(unsigned Opcode, Type *DataTy,
298-
bool VariableMask, Align Alignment,
299-
unsigned AddressSpace);
300-
InstructionCost getGSVectorCost(unsigned Opcode, Type *DataTy,
301-
const Value *Ptr, Align Alignment,
302-
unsigned AddressSpace);
297+
InstructionCost getGSScalarCost(unsigned Opcode, TTI::TargetCostKind CostKind,
298+
Type *DataTy, bool VariableMask,
299+
Align Alignment, unsigned AddressSpace);
300+
InstructionCost getGSVectorCost(unsigned Opcode, TTI::TargetCostKind CostKind,
301+
Type *DataTy, const Value *Ptr,
302+
Align Alignment, unsigned AddressSpace);
303303

304304
int getGatherOverhead() const;
305305
int getScatterOverhead() const;

0 commit comments

Comments
 (0)