Skip to content

Commit abd2c07

Browse files
authored
[CostModel] Make Op0 and Op1 const in getVectorInstrCost. NFC (llvm#137631)
This does not alter much at the moment, but allows const pointers to be passed as Op0 and Op1, simplifying later patches
1 parent 4768173 commit abd2c07

24 files changed

+53
-47
lines changed

llvm/include/llvm/Analysis/TargetTransformInfo.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,8 +1455,9 @@ class TargetTransformInfo {
14551455
/// vectorizer passes.
14561456
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
14571457
TTI::TargetCostKind CostKind,
1458-
unsigned Index = -1, Value *Op0 = nullptr,
1459-
Value *Op1 = nullptr) const;
1458+
unsigned Index = -1,
1459+
const Value *Op0 = nullptr,
1460+
const Value *Op1 = nullptr) const;
14601461

14611462
/// \return The expected cost of vector Insert and Extract.
14621463
/// Use -1 to indicate that there is no information on the index value.

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,8 +781,8 @@ class TargetTransformInfoImplBase {
781781

782782
virtual InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
783783
TTI::TargetCostKind CostKind,
784-
unsigned Index, Value *Op0,
785-
Value *Op1) const {
784+
unsigned Index, const Value *Op0,
785+
const Value *Op1) const {
786786
return 1;
787787
}
788788

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,8 +1410,8 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
14101410

14111411
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
14121412
TTI::TargetCostKind CostKind,
1413-
unsigned Index, Value *Op0,
1414-
Value *Op1) const override {
1413+
unsigned Index, const Value *Op0,
1414+
const Value *Op1) const override {
14151415
return getRegUsageForType(Val->getScalarType());
14161416
}
14171417

llvm/lib/Analysis/TargetTransformInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ InstructionCost TargetTransformInfo::getCmpSelInstrCost(
10851085

10861086
InstructionCost TargetTransformInfo::getVectorInstrCost(
10871087
unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index,
1088-
Value *Op0, Value *Op1) const {
1088+
const Value *Op0, const Value *Op1) const {
10891089
assert((Opcode == Instruction::InsertElement ||
10901090
Opcode == Instruction::ExtractElement) &&
10911091
"Expecting Opcode to be insertelement/extractelement.");

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3857,8 +3857,9 @@ InstructionCost AArch64TTIImpl::getVectorInstrCostHelper(
38573857

38583858
InstructionCost AArch64TTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
38593859
TTI::TargetCostKind CostKind,
3860-
unsigned Index, Value *Op0,
3861-
Value *Op1) const {
3860+
unsigned Index,
3861+
const Value *Op0,
3862+
const Value *Op1) const {
38623863
bool HasRealUse =
38633864
Opcode == Instruction::InsertElement && Op0 && !isa<UndefValue>(Op0);
38643865
return getVectorInstrCostHelper(Opcode, Val, CostKind, Index, HasRealUse);

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ class AArch64TTIImpl : public BasicTTIImplBase<AArch64TTIImpl> {
205205

206206
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
207207
TTI::TargetCostKind CostKind,
208-
unsigned Index, Value *Op0,
209-
Value *Op1) const override;
208+
unsigned Index, const Value *Op0,
209+
const Value *Op1) const override;
210210

211211
/// \param ScalarUserAndIdx encodes the information about extracts from a
212212
/// vector with 'Scalar' being the value being extracted,'User' being the user

llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,8 +834,8 @@ GCNTTIImpl::getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty,
834834

835835
InstructionCost GCNTTIImpl::getVectorInstrCost(unsigned Opcode, Type *ValTy,
836836
TTI::TargetCostKind CostKind,
837-
unsigned Index, Value *Op0,
838-
Value *Op1) const {
837+
unsigned Index, const Value *Op0,
838+
const Value *Op1) const {
839839
switch (Opcode) {
840840
case Instruction::ExtractElement:
841841
case Instruction::InsertElement: {

llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ class GCNTTIImpl final : public BasicTTIImplBase<GCNTTIImpl> {
170170
using BaseT::getVectorInstrCost;
171171
InstructionCost getVectorInstrCost(unsigned Opcode, Type *ValTy,
172172
TTI::TargetCostKind CostKind,
173-
unsigned Index, Value *Op0,
174-
Value *Op1) const override;
173+
unsigned Index, const Value *Op0,
174+
const Value *Op1) const override;
175175

176176
bool isReadRegisterSourceOfDivergence(const IntrinsicInst *ReadReg) const;
177177
bool isSourceOfDivergence(const Value *V) const override;

llvm/lib/Target/AMDGPU/R600TargetTransformInfo.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ InstructionCost R600TTIImpl::getCFInstrCost(unsigned Opcode,
110110

111111
InstructionCost R600TTIImpl::getVectorInstrCost(unsigned Opcode, Type *ValTy,
112112
TTI::TargetCostKind CostKind,
113-
unsigned Index, Value *Op0,
114-
Value *Op1) const {
113+
unsigned Index,
114+
const Value *Op0,
115+
const Value *Op1) const {
115116
switch (Opcode) {
116117
case Instruction::ExtractElement:
117118
case Instruction::InsertElement: {

llvm/lib/Target/AMDGPU/R600TargetTransformInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ class R600TTIImpl final : public BasicTTIImplBase<R600TTIImpl> {
6464
using BaseT::getVectorInstrCost;
6565
InstructionCost getVectorInstrCost(unsigned Opcode, Type *ValTy,
6666
TTI::TargetCostKind CostKind,
67-
unsigned Index, Value *Op0,
68-
Value *Op1) const override;
67+
unsigned Index, const Value *Op0,
68+
const Value *Op1) const override;
6969
};
7070

7171
} // end namespace llvm

llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -901,8 +901,8 @@ InstructionCost ARMTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
901901

902902
InstructionCost ARMTTIImpl::getVectorInstrCost(unsigned Opcode, Type *ValTy,
903903
TTI::TargetCostKind CostKind,
904-
unsigned Index, Value *Op0,
905-
Value *Op1) const {
904+
unsigned Index, const Value *Op0,
905+
const Value *Op1) const {
906906
// Penalize inserting into an D-subregister. We end up with a three times
907907
// lower estimated throughput on swift.
908908
if (ST->hasSlowLoadDSubregister() && Opcode == Instruction::InsertElement &&

llvm/lib/Target/ARM/ARMTargetTransformInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ class ARMTTIImpl : public BasicTTIImplBase<ARMTTIImpl> {
255255
using BaseT::getVectorInstrCost;
256256
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
257257
TTI::TargetCostKind CostKind,
258-
unsigned Index, Value *Op0,
259-
Value *Op1) const override;
258+
unsigned Index, const Value *Op0,
259+
const Value *Op1) const override;
260260

261261
InstructionCost getAddressComputationCost(Type *Val, ScalarEvolution *SE,
262262
const SCEV *Ptr) const override;

llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,9 @@ InstructionCost HexagonTTIImpl::getCastInstrCost(unsigned Opcode, Type *DstTy,
316316

317317
InstructionCost HexagonTTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
318318
TTI::TargetCostKind CostKind,
319-
unsigned Index, Value *Op0,
320-
Value *Op1) const {
319+
unsigned Index,
320+
const Value *Op0,
321+
const Value *Op1) const {
321322
Type *ElemTy = Val->isVectorTy() ? cast<VectorType>(Val)->getElementType()
322323
: Val;
323324
if (Opcode == Instruction::InsertElement) {

llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ class HexagonTTIImpl : public BasicTTIImplBase<HexagonTTIImpl> {
155155
using BaseT::getVectorInstrCost;
156156
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
157157
TTI::TargetCostKind CostKind,
158-
unsigned Index, Value *Op0,
159-
Value *Op1) const override;
158+
unsigned Index, const Value *Op0,
159+
const Value *Op1) const override;
160160

161161
InstructionCost
162162
getCFInstrCost(unsigned Opcode, TTI::TargetCostKind CostKind,

llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,8 @@ InstructionCost PPCTTIImpl::getCmpSelInstrCost(
674674

675675
InstructionCost PPCTTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
676676
TTI::TargetCostKind CostKind,
677-
unsigned Index, Value *Op0,
678-
Value *Op1) const {
677+
unsigned Index, const Value *Op0,
678+
const Value *Op1) const {
679679
assert(Val->isVectorTy() && "This must be a vector type");
680680

681681
int ISD = TLI->InstructionOpcodeToISD(Opcode);

llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ class PPCTTIImpl : public BasicTTIImplBase<PPCTTIImpl> {
130130
using BaseT::getVectorInstrCost;
131131
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
132132
TTI::TargetCostKind CostKind,
133-
unsigned Index, Value *Op0,
134-
Value *Op1) const override;
133+
unsigned Index, const Value *Op0,
134+
const Value *Op1) const override;
135135
InstructionCost getMemoryOpCost(
136136
unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,
137137
TTI::TargetCostKind CostKind,

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,8 +2189,9 @@ InstructionCost RISCVTTIImpl::getCFInstrCost(unsigned Opcode,
21892189

21902190
InstructionCost RISCVTTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
21912191
TTI::TargetCostKind CostKind,
2192-
unsigned Index, Value *Op0,
2193-
Value *Op1) const {
2192+
unsigned Index,
2193+
const Value *Op0,
2194+
const Value *Op1) const {
21942195
assert(Val->isVectorTy() && "This must be a vector type");
21952196

21962197
if (Opcode != Instruction::ExtractElement &&

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ class RISCVTTIImpl : public BasicTTIImplBase<RISCVTTIImpl> {
238238
using BaseT::getVectorInstrCost;
239239
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
240240
TTI::TargetCostKind CostKind,
241-
unsigned Index, Value *Op0,
242-
Value *Op1) const override;
241+
unsigned Index, const Value *Op0,
242+
const Value *Op1) const override;
243243

244244
InstructionCost getArithmeticInstrCost(
245245
unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,

llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ bool SystemZTTIImpl::hasDivRemOp(Type *DataType, bool IsSigned) const {
497497
return (VT.isScalarInteger() && TLI->isTypeLegal(VT));
498498
}
499499

500-
static bool isFreeEltLoad(Value *Op) {
500+
static bool isFreeEltLoad(const Value *Op) {
501501
if (isa<LoadInst>(Op) && Op->hasOneUse()) {
502502
const Instruction *UserI = cast<Instruction>(*Op->user_begin());
503503
return !isa<StoreInst>(UserI); // Prefer MVC
@@ -1194,8 +1194,9 @@ InstructionCost SystemZTTIImpl::getCmpSelInstrCost(
11941194

11951195
InstructionCost SystemZTTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
11961196
TTI::TargetCostKind CostKind,
1197-
unsigned Index, Value *Op0,
1198-
Value *Op1) const {
1197+
unsigned Index,
1198+
const Value *Op0,
1199+
const Value *Op1) const {
11991200
if (Opcode == Instruction::InsertElement) {
12001201
// Vector Element Load.
12011202
if (Op1 != nullptr && isFreeEltLoad(Op1))

llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ class SystemZTTIImpl : public BasicTTIImplBase<SystemZTTIImpl> {
123123
using BaseT::getVectorInstrCost;
124124
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
125125
TTI::TargetCostKind CostKind,
126-
unsigned Index, Value *Op0,
127-
Value *Op1) const override;
126+
unsigned Index, const Value *Op0,
127+
const Value *Op1) const override;
128128
bool isFoldableLoad(const LoadInst *Ld,
129129
const Instruction *&FoldedValue) const;
130130
InstructionCost getMemoryOpCost(

llvm/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ InstructionCost WebAssemblyTTIImpl::getMemoryOpCost(
184184

185185
InstructionCost WebAssemblyTTIImpl::getVectorInstrCost(
186186
unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index,
187-
Value *Op0, Value *Op1) const {
187+
const Value *Op0, const Value *Op1) const {
188188
InstructionCost Cost = BasicTTIImplBase::getVectorInstrCost(
189189
Opcode, Val, CostKind, Index, Op0, Op1);
190190

llvm/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ class WebAssemblyTTIImpl final : public BasicTTIImplBase<WebAssemblyTTIImpl> {
8181
using BaseT::getVectorInstrCost;
8282
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
8383
TTI::TargetCostKind CostKind,
84-
unsigned Index, Value *Op0,
85-
Value *Op1) const override;
84+
unsigned Index, const Value *Op0,
85+
const Value *Op1) const override;
8686
InstructionCost getPartialReductionCost(
8787
unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType,
8888
ElementCount VF, TTI::PartialReductionExtendKind OpAExtend,

llvm/lib/Target/X86/X86TargetTransformInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4767,8 +4767,8 @@ X86TTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
47674767

47684768
InstructionCost X86TTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
47694769
TTI::TargetCostKind CostKind,
4770-
unsigned Index, Value *Op0,
4771-
Value *Op1) const {
4770+
unsigned Index, const Value *Op0,
4771+
const Value *Op1) const {
47724772
static const CostTblEntry SLMCostTbl[] = {
47734773
{ ISD::EXTRACT_VECTOR_ELT, MVT::i8, 4 },
47744774
{ ISD::EXTRACT_VECTOR_ELT, MVT::i16, 4 },

llvm/lib/Target/X86/X86TargetTransformInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ class X86TTIImpl : public BasicTTIImplBase<X86TTIImpl> {
166166
using BaseT::getVectorInstrCost;
167167
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
168168
TTI::TargetCostKind CostKind,
169-
unsigned Index, Value *Op0,
170-
Value *Op1) const override;
169+
unsigned Index, const Value *Op0,
170+
const Value *Op1) const override;
171171
InstructionCost getScalarizationOverhead(
172172
VectorType *Ty, const APInt &DemandedElts, bool Insert, bool Extract,
173173
TTI::TargetCostKind CostKind, bool ForPoisonSrc = true,

0 commit comments

Comments
 (0)