Skip to content

Commit d2060b0

Browse files
davemgreenGeorgeARM
authored andcommitted
[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 23fc363 commit d2060b0

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

0 commit comments

Comments
 (0)