Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/include/llvm/Analysis/TargetTransformInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -2367,7 +2367,7 @@ class TargetTransformInfo::Concept {

template <typename T>
class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
T Impl;
const T Impl;

public:
Model(T Impl) : Impl(std::move(Impl)) {}
Expand Down
24 changes: 12 additions & 12 deletions llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ class TargetTransformInfoImplBase {
}

bool isLegalInterleavedAccessType(VectorType *VTy, unsigned Factor,
Align Alignment, unsigned AddrSpace) {
Align Alignment, unsigned AddrSpace) const {
return false;
}

Expand Down Expand Up @@ -440,7 +440,7 @@ class TargetTransformInfoImplBase {

bool enableSelectOptimize() const { return true; }

bool shouldTreatInstructionLikeSelect(const Instruction *I) {
bool shouldTreatInstructionLikeSelect(const Instruction *I) const {
// A select with two constant operands will usually be better left as a
// select.
using namespace llvm::PatternMatch;
Expand Down Expand Up @@ -747,7 +747,7 @@ class TargetTransformInfoImplBase {

unsigned getReplicationShuffleCost(Type *EltTy, int ReplicationFactor, int VF,
const APInt &DemandedDstElts,
TTI::TargetCostKind CostKind) {
TTI::TargetCostKind CostKind) const {
return 1;
}

Expand Down Expand Up @@ -1250,7 +1250,7 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
const Value *Base,
const TTI::PointersChainInfo &Info,
Type *AccessTy,
TTI::TargetCostKind CostKind) {
TTI::TargetCostKind CostKind) const {
InstructionCost Cost = TTI::TCC_Free;
// In the basic model we take into account GEP instructions only
// (although here can come alloca instruction, a value, constants and/or
Expand All @@ -1269,26 +1269,26 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
if (Info.isSameBase() && V != Base) {
if (GEP->hasAllConstantIndices())
continue;
Cost += static_cast<T *>(this)->getArithmeticInstrCost(
Cost += static_cast<const T *>(this)->getArithmeticInstrCost(
Instruction::Add, GEP->getType(), CostKind,
{TTI::OK_AnyValue, TTI::OP_None}, {TTI::OK_AnyValue, TTI::OP_None},
{});
} else {
SmallVector<const Value *> Indices(GEP->indices());
Cost += static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
GEP->getPointerOperand(),
Indices, AccessTy, CostKind);
Cost += static_cast<const T *>(this)->getGEPCost(
GEP->getSourceElementType(), GEP->getPointerOperand(), Indices,
AccessTy, CostKind);
}
}
return Cost;
}

InstructionCost getInstructionCost(const User *U,
ArrayRef<const Value *> Operands,
TTI::TargetCostKind CostKind) {
TTI::TargetCostKind CostKind) const {
using namespace llvm::PatternMatch;

auto *TargetTTI = static_cast<T *>(this);
auto *TargetTTI = static_cast<const T *>(this);
// Handle non-intrinsic calls, invokes, and callbr.
// FIXME: Unlikely to be true for anything but CodeSize.
auto *CB = dyn_cast<CallBase>(U);
Expand Down Expand Up @@ -1585,8 +1585,8 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
return CostKind == TTI::TCK_RecipThroughput ? -1 : TTI::TCC_Basic;
}

bool isExpensiveToSpeculativelyExecute(const Instruction *I) {
auto *TargetTTI = static_cast<T *>(this);
bool isExpensiveToSpeculativelyExecute(const Instruction *I) const {
auto *TargetTTI = static_cast<const T *>(this);
SmallVector<const Value *, 4> Ops(I->operand_values());
InstructionCost Cost = TargetTTI->getInstructionCost(
I, Ops, TargetTransformInfo::TCK_SizeAndLatency);
Expand Down
83 changes: 41 additions & 42 deletions llvm/include/llvm/CodeGen/BasicTTIImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,11 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
return (CallerBits & CalleeBits) == CalleeBits;
}

bool hasBranchDivergence(const Function *F = nullptr) { return false; }
bool hasBranchDivergence(const Function *F = nullptr) const { return false; }

bool isSourceOfDivergence(const Value *V) { return false; }
bool isSourceOfDivergence(const Value *V) const { return false; }

bool isAlwaysUniform(const Value *V) { return false; }
bool isAlwaysUniform(const Value *V) const { return false; }

bool isValidAddrSpaceCast(unsigned FromAS, unsigned ToAS) const {
return false;
Expand All @@ -393,7 +393,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
return true;
}

unsigned getFlatAddressSpace() {
unsigned getFlatAddressSpace() const {
// Return an invalid address space.
return -1;
}
Expand Down Expand Up @@ -426,22 +426,22 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
return nullptr;
}

bool isLegalAddImmediate(int64_t imm) {
bool isLegalAddImmediate(int64_t imm) const {
return getTLI()->isLegalAddImmediate(imm);
}

bool isLegalAddScalableImmediate(int64_t Imm) {
bool isLegalAddScalableImmediate(int64_t Imm) const {
return getTLI()->isLegalAddScalableImmediate(Imm);
}

bool isLegalICmpImmediate(int64_t imm) {
bool isLegalICmpImmediate(int64_t imm) const {
return getTLI()->isLegalICmpImmediate(imm);
}

bool isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset,
bool HasBaseReg, int64_t Scale, unsigned AddrSpace,
Instruction *I = nullptr,
int64_t ScalableOffset = 0) {
int64_t ScalableOffset = 0) const {
TargetLoweringBase::AddrMode AM;
AM.BaseGV = BaseGV;
AM.BaseOffs = BaseOffset;
Expand Down Expand Up @@ -487,25 +487,26 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
return getTLI()->isIndexedStoreLegal(getISDIndexedMode(M), VT);
}

bool isLSRCostLess(TTI::LSRCost C1, TTI::LSRCost C2) {
bool isLSRCostLess(TTI::LSRCost C1, TTI::LSRCost C2) const {
return TargetTransformInfoImplBase::isLSRCostLess(C1, C2);
}

bool isNumRegsMajorCostOfLSR() {
bool isNumRegsMajorCostOfLSR() const {
return TargetTransformInfoImplBase::isNumRegsMajorCostOfLSR();
}

bool shouldDropLSRSolutionIfLessProfitable() const {
return TargetTransformInfoImplBase::shouldDropLSRSolutionIfLessProfitable();
}

bool isProfitableLSRChainElement(Instruction *I) {
bool isProfitableLSRChainElement(Instruction *I) const {
return TargetTransformInfoImplBase::isProfitableLSRChainElement(I);
}

InstructionCost getScalingFactorCost(Type *Ty, GlobalValue *BaseGV,
StackOffset BaseOffset, bool HasBaseReg,
int64_t Scale, unsigned AddrSpace) {
int64_t Scale,
unsigned AddrSpace) const {
TargetLoweringBase::AddrMode AM;
AM.BaseGV = BaseGV;
AM.BaseOffs = BaseOffset.getFixed();
Expand All @@ -517,11 +518,11 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
return InstructionCost::getInvalid();
}

bool isTruncateFree(Type *Ty1, Type *Ty2) {
bool isTruncateFree(Type *Ty1, Type *Ty2) const {
return getTLI()->isTruncateFree(Ty1, Ty2);
}

bool isProfitableToHoist(Instruction *I) {
bool isProfitableToHoist(Instruction *I) const {
return getTLI()->isProfitableToHoist(I);
}

Expand All @@ -539,14 +540,14 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {

InstructionCost getGEPCost(Type *PointeeType, const Value *Ptr,
ArrayRef<const Value *> Operands, Type *AccessType,
TTI::TargetCostKind CostKind) {
TTI::TargetCostKind CostKind) const {
return BaseT::getGEPCost(PointeeType, Ptr, Operands, AccessType, CostKind);
}

unsigned getEstimatedNumberOfCaseClusters(const SwitchInst &SI,
unsigned &JumpTableSize,
ProfileSummaryInfo *PSI,
BlockFrequencyInfo *BFI) {
BlockFrequencyInfo *BFI) const {
/// Try to find the estimated number of clusters. Note that the number of
/// clusters identified in this function could be different from the actual
/// numbers found in lowering. This function ignore switches that are
Expand Down Expand Up @@ -602,7 +603,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
return N;
}

bool shouldBuildLookupTables() {
bool shouldBuildLookupTables() const {
const TargetLoweringBase *TLI = getTLI();
return TLI->isOperationLegalOrCustom(ISD::BR_JT, MVT::Other) ||
TLI->isOperationLegalOrCustom(ISD::BRIND, MVT::Other);
Expand Down Expand Up @@ -633,18 +634,16 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
return true;
}

bool haveFastSqrt(Type *Ty) {
bool haveFastSqrt(Type *Ty) const {
const TargetLoweringBase *TLI = getTLI();
EVT VT = TLI->getValueType(DL, Ty);
return TLI->isTypeLegal(VT) &&
TLI->isOperationLegalOrCustom(ISD::FSQRT, VT);
}

bool isFCmpOrdCheaperThanFCmpZero(Type *Ty) {
return true;
}
bool isFCmpOrdCheaperThanFCmpZero(Type *Ty) const { return true; }

InstructionCost getFPOpCost(Type *Ty) {
InstructionCost getFPOpCost(Type *Ty) const {
// Check whether FADD is available, as a proxy for floating-point in
// general.
const TargetLoweringBase *TLI = getTLI();
Expand Down Expand Up @@ -674,7 +673,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
}

unsigned getInliningThresholdMultiplier() const { return 1; }
unsigned adjustInliningThreshold(const CallBase *CB) { return 0; }
unsigned adjustInliningThreshold(const CallBase *CB) const { return 0; }
unsigned getCallerAllocaCost(const CallBase *CB, const AllocaInst *AI) const {
return 0;
}
Expand All @@ -683,7 +682,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {

void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
TTI::UnrollingPreferences &UP,
OptimizationRemarkEmitter *ORE) {
OptimizationRemarkEmitter *ORE) const {
// This unrolling functionality is target independent, but to provide some
// motivation for its intended use, for x86:

Expand Down Expand Up @@ -754,42 +753,41 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
}

void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
TTI::PeelingPreferences &PP) {
TTI::PeelingPreferences &PP) const {
PP.PeelCount = 0;
PP.AllowPeeling = true;
PP.AllowLoopNestsPeeling = false;
PP.PeelProfiledIterations = true;
}

bool isHardwareLoopProfitable(Loop *L, ScalarEvolution &SE,
AssumptionCache &AC,
TargetLibraryInfo *LibInfo,
HardwareLoopInfo &HWLoopInfo) {
AssumptionCache &AC, TargetLibraryInfo *LibInfo,
HardwareLoopInfo &HWLoopInfo) const {
return BaseT::isHardwareLoopProfitable(L, SE, AC, LibInfo, HWLoopInfo);
}

unsigned getEpilogueVectorizationMinVF() {
unsigned getEpilogueVectorizationMinVF() const {
return BaseT::getEpilogueVectorizationMinVF();
}

bool preferPredicateOverEpilogue(TailFoldingInfo *TFI) {
bool preferPredicateOverEpilogue(TailFoldingInfo *TFI) const {
return BaseT::preferPredicateOverEpilogue(TFI);
}

TailFoldingStyle
getPreferredTailFoldingStyle(bool IVUpdateMayOverflow = true) {
getPreferredTailFoldingStyle(bool IVUpdateMayOverflow = true) const {
return BaseT::getPreferredTailFoldingStyle(IVUpdateMayOverflow);
}

std::optional<Instruction *> instCombineIntrinsic(InstCombiner &IC,
IntrinsicInst &II) {
IntrinsicInst &II) const {
return BaseT::instCombineIntrinsic(IC, II);
}

std::optional<Value *>
simplifyDemandedUseBitsIntrinsic(InstCombiner &IC, IntrinsicInst &II,
APInt DemandedMask, KnownBits &Known,
bool &KnownBitsComputed) {
bool &KnownBitsComputed) const {
return BaseT::simplifyDemandedUseBitsIntrinsic(IC, II, DemandedMask, Known,
KnownBitsComputed);
}
Expand All @@ -798,7 +796,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
InstCombiner &IC, IntrinsicInst &II, APInt DemandedElts, APInt &UndefElts,
APInt &UndefElts2, APInt &UndefElts3,
std::function<void(Instruction *, unsigned, APInt, APInt &)>
SimplifyAndSetOp) {
SimplifyAndSetOp) const {
return BaseT::simplifyDemandedVectorEltsIntrinsic(
IC, II, DemandedElts, UndefElts, UndefElts2, UndefElts3,
SimplifyAndSetOp);
Expand Down Expand Up @@ -1015,7 +1013,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
}
}

unsigned getMaxInterleaveFactor(ElementCount VF) { return 1; }
unsigned getMaxInterleaveFactor(ElementCount VF) const { return 1; }

InstructionCost getArithmeticInstrCost(
unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
Expand Down Expand Up @@ -1337,7 +1335,8 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
}

InstructionCost getExtractWithExtendCost(unsigned Opcode, Type *Dst,
VectorType *VecTy, unsigned Index) {
VectorType *VecTy,
unsigned Index) const {
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
return thisT()->getVectorInstrCost(Instruction::ExtractElement, VecTy,
CostKind, Index, nullptr, nullptr) +
Expand Down Expand Up @@ -1417,14 +1416,14 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
InstructionCost getVectorInstrCost(
unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index,
Value *Scalar,
ArrayRef<std::tuple<Value *, User *, int>> ScalarUserAndIdx) {
ArrayRef<std::tuple<Value *, User *, int>> ScalarUserAndIdx) const {
return thisT()->getVectorInstrCost(Opcode, Val, CostKind, Index, nullptr,
nullptr);
}

InstructionCost getVectorInstrCost(const Instruction &I, Type *Val,
TTI::TargetCostKind CostKind,
unsigned Index) {
unsigned Index) const {
Value *Op0 = nullptr;
Value *Op1 = nullptr;
if (auto *IE = dyn_cast<InsertElementInst>(&I)) {
Expand Down Expand Up @@ -1554,7 +1553,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
InstructionCost getInterleavedMemoryOpCost(
unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
bool UseMaskForCond = false, bool UseMaskForGaps = false) {
bool UseMaskForCond = false, bool UseMaskForGaps = false) const {

// We cannot scalarize scalable vectors, so return Invalid.
if (isa<ScalableVectorType>(VecTy))
Expand Down Expand Up @@ -2886,7 +2885,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
}

InstructionCost getAddressComputationCost(Type *Ty, ScalarEvolution *,
const SCEV *) {
const SCEV *) const {
return 0;
}

Expand Down Expand Up @@ -3067,7 +3066,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
InstructionCost getExtendedReductionCost(unsigned Opcode, bool IsUnsigned,
Type *ResTy, VectorType *Ty,
std::optional<FastMathFlags> FMF,
TTI::TargetCostKind CostKind) {
TTI::TargetCostKind CostKind) const {
if (auto *FTy = dyn_cast<FixedVectorType>(Ty);
FTy && IsUnsigned && Opcode == Instruction::Add &&
FTy->getElementType() == IntegerType::getInt1Ty(Ty->getContext())) {
Expand Down Expand Up @@ -3095,7 +3094,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {

InstructionCost getMulAccReductionCost(bool IsUnsigned, Type *ResTy,
VectorType *Ty,
TTI::TargetCostKind CostKind) {
TTI::TargetCostKind CostKind) const {
// Without any native support, this is equivalent to the cost of
// vecreduce.add(mul(ext(Ty A), ext(Ty B))) or
// vecreduce.add(mul(A, B)).
Expand Down
Loading
Loading