Skip to content

Commit 01fac67

Browse files
authored
[TTI] Add cost kind to getAddressComputationCost(). NFC. (#153342)
This patch add cost kind to `getAddressComputationCost()` for #149955. Note that this patch also remove all the default value in `getAddressComputationCost()`.
1 parent 18782db commit 01fac67

16 files changed

+53
-39
lines changed

llvm/include/llvm/Analysis/TargetTransformInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,8 +1681,8 @@ class TargetTransformInfo {
16811681
/// was used in order to get the Ptr step value. \p Ptr holds the SCEV of the
16821682
/// access pointer.
16831683
LLVM_ABI InstructionCost
1684-
getAddressComputationCost(Type *PtrTy, ScalarEvolution *SE = nullptr,
1685-
const SCEV *Ptr = nullptr) const;
1684+
getAddressComputationCost(Type *PtrTy, ScalarEvolution *SE, const SCEV *Ptr,
1685+
TTI::TargetCostKind CostKind) const;
16861686

16871687
/// \returns The cost, if any, of keeping values of the given types alive
16881688
/// over a callsite.

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,8 @@ class TargetTransformInfoImplBase {
939939

940940
virtual InstructionCost getAddressComputationCost(Type *PtrTy,
941941
ScalarEvolution *,
942-
const SCEV *) const {
942+
const SCEV *,
943+
TTI::TargetCostKind) const {
943944
return 0;
944945
}
945946

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3026,8 +3026,9 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
30263026
return LT.first.getValue();
30273027
}
30283028

3029-
InstructionCost getAddressComputationCost(Type *PtrTy, ScalarEvolution *,
3030-
const SCEV *) const override {
3029+
InstructionCost
3030+
getAddressComputationCost(Type *PtrTy, ScalarEvolution *, const SCEV *,
3031+
TTI::TargetCostKind) const override {
30313032
return 0;
30323033
}
30333034

llvm/lib/Analysis/TargetTransformInfo.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,10 +1230,11 @@ unsigned TargetTransformInfo::getNumberOfParts(Type *Tp) const {
12301230
return TTIImpl->getNumberOfParts(Tp);
12311231
}
12321232

1233-
InstructionCost
1234-
TargetTransformInfo::getAddressComputationCost(Type *PtrTy, ScalarEvolution *SE,
1235-
const SCEV *Ptr) const {
1236-
InstructionCost Cost = TTIImpl->getAddressComputationCost(PtrTy, SE, Ptr);
1233+
InstructionCost TargetTransformInfo::getAddressComputationCost(
1234+
Type *PtrTy, ScalarEvolution *SE, const SCEV *Ptr,
1235+
TTI::TargetCostKind CostKind) const {
1236+
InstructionCost Cost =
1237+
TTIImpl->getAddressComputationCost(PtrTy, SE, Ptr, CostKind);
12371238
assert(Cost >= 0 && "TTI should not produce negative costs!");
12381239
return Cost;
12391240
}

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4337,7 +4337,8 @@ InstructionCost AArch64TTIImpl::getArithmeticInstrCost(
43374337

43384338
InstructionCost
43394339
AArch64TTIImpl::getAddressComputationCost(Type *PtrTy, ScalarEvolution *SE,
4340-
const SCEV *Ptr) const {
4340+
const SCEV *Ptr,
4341+
TTI::TargetCostKind CostKind) const {
43414342
// Address computations in vectorized code with non-consecutive addresses will
43424343
// likely result in more instructions compared to scalar code where the
43434344
// computation can more often be merged into the index mode. The resulting

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,9 @@ class AArch64TTIImpl final : public BasicTTIImplBase<AArch64TTIImpl> {
238238
ArrayRef<const Value *> Args = {},
239239
const Instruction *CxtI = nullptr) const override;
240240

241-
InstructionCost getAddressComputationCost(Type *PtrTy, ScalarEvolution *SE,
242-
const SCEV *Ptr) const override;
241+
InstructionCost
242+
getAddressComputationCost(Type *PtrTy, ScalarEvolution *SE, const SCEV *Ptr,
243+
TTI::TargetCostKind CostKind) const override;
243244

244245
InstructionCost getCmpSelInstrCost(
245246
unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred,

llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,9 +1084,10 @@ InstructionCost ARMTTIImpl::getCmpSelInstrCost(
10841084
CostKind, Op1Info, Op2Info, I);
10851085
}
10861086

1087-
InstructionCost ARMTTIImpl::getAddressComputationCost(Type *PtrTy,
1088-
ScalarEvolution *SE,
1089-
const SCEV *Ptr) const {
1087+
InstructionCost
1088+
ARMTTIImpl::getAddressComputationCost(Type *PtrTy, ScalarEvolution *SE,
1089+
const SCEV *Ptr,
1090+
TTI::TargetCostKind CostKind) const {
10901091
// Address computations in vectorized code with non-consecutive addresses will
10911092
// likely result in more instructions compared to scalar code where the
10921093
// computation can more often be merged into the index mode. The resulting
@@ -1103,7 +1104,7 @@ InstructionCost ARMTTIImpl::getAddressComputationCost(Type *PtrTy,
11031104
// addressing mode.
11041105
return 1;
11051106
}
1106-
return BaseT::getAddressComputationCost(PtrTy, SE, Ptr);
1107+
return BaseT::getAddressComputationCost(PtrTy, SE, Ptr, CostKind);
11071108
}
11081109

11091110
bool ARMTTIImpl::isProfitableLSRChainElement(Instruction *I) const {

llvm/lib/Target/ARM/ARMTargetTransformInfo.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,9 @@ class ARMTTIImpl final : public BasicTTIImplBase<ARMTTIImpl> {
257257
unsigned Index, const Value *Op0,
258258
const Value *Op1) const override;
259259

260-
InstructionCost getAddressComputationCost(Type *Val, ScalarEvolution *SE,
261-
const SCEV *Ptr) const override;
260+
InstructionCost
261+
getAddressComputationCost(Type *Val, ScalarEvolution *SE, const SCEV *Ptr,
262+
TTI::TargetCostKind CostKind) const override;
262263

263264
InstructionCost getArithmeticInstrCost(
264265
unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,

llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,10 @@ HexagonTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
156156
return BaseT::getIntrinsicInstrCost(ICA, CostKind);
157157
}
158158

159-
InstructionCost HexagonTTIImpl::getAddressComputationCost(Type *PtrTy,
160-
ScalarEvolution *SE,
161-
const SCEV *S) const {
159+
InstructionCost
160+
HexagonTTIImpl::getAddressComputationCost(Type *PtrTy, ScalarEvolution *SE,
161+
const SCEV *S,
162+
TTI::TargetCostKind CostKind) const {
162163
return 0;
163164
}
164165

llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ class HexagonTTIImpl final : public BasicTTIImplBase<HexagonTTIImpl> {
111111
InstructionCost
112112
getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
113113
TTI::TargetCostKind CostKind) const override;
114-
InstructionCost getAddressComputationCost(Type *PtrTy, ScalarEvolution *SE,
115-
const SCEV *S) const override;
114+
InstructionCost
115+
getAddressComputationCost(Type *PtrTy, ScalarEvolution *SE, const SCEV *S,
116+
TTI::TargetCostKind CostKind) const override;
116117
InstructionCost getMemoryOpCost(
117118
unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,
118119
TTI::TargetCostKind CostKind,

0 commit comments

Comments
 (0)