Skip to content

Commit d4b565e

Browse files
committed
[CostModel] Make Op0 and Op1 const in getVectorInstrCost. NFC
This does not alter much at the moment, but allows const pointers to be passed as Op0 and Op1, simplifying later patches
1 parent 60b3a5b commit d4b565e

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
@@ -1454,8 +1454,9 @@ class TargetTransformInfo {
14541454
/// vectorizer passes.
14551455
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
14561456
TTI::TargetCostKind CostKind,
1457-
unsigned Index = -1, Value *Op0 = nullptr,
1458-
Value *Op1 = nullptr) const;
1457+
unsigned Index = -1,
1458+
const Value *Op0 = nullptr,
1459+
const Value *Op1 = nullptr) const;
14591460

14601461
/// \return The expected cost of vector Insert and Extract.
14611462
/// 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
@@ -780,8 +780,8 @@ class TargetTransformInfoImplBase {
780780

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

llvm/include/llvm/CodeGen/BasicTTIImpl.h

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

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

llvm/lib/Analysis/TargetTransformInfo.cpp

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

10851085
InstructionCost TargetTransformInfo::getVectorInstrCost(
10861086
unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index,
1087-
Value *Op0, Value *Op1) const {
1087+
const Value *Op0, const Value *Op1) const {
10881088
assert((Opcode == Instruction::InsertElement ||
10891089
Opcode == Instruction::ExtractElement) &&
10901090
"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
@@ -3829,8 +3829,9 @@ InstructionCost AArch64TTIImpl::getVectorInstrCostHelper(
38293829

38303830
InstructionCost AArch64TTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
38313831
TTI::TargetCostKind CostKind,
3832-
unsigned Index, Value *Op0,
3833-
Value *Op1) const {
3832+
unsigned Index,
3833+
const Value *Op0,
3834+
const Value *Op1) const {
38343835
bool HasRealUse =
38353836
Opcode == Instruction::InsertElement && Op0 && !isa<UndefValue>(Op0);
38363837
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

0 commit comments

Comments
 (0)