[CostModel] Make Op0 and Op1 const in getVectorInstrCost. NFC (#137631)
This does not alter much at the moment, but allows const pointers to be passed as Op0 and Op1, simplifying later patches
This commit is contained in:
@@ -1455,8 +1455,9 @@ public:
|
||||
/// vectorizer passes.
|
||||
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
|
||||
TTI::TargetCostKind CostKind,
|
||||
unsigned Index = -1, Value *Op0 = nullptr,
|
||||
Value *Op1 = nullptr) const;
|
||||
unsigned Index = -1,
|
||||
const Value *Op0 = nullptr,
|
||||
const Value *Op1 = nullptr) const;
|
||||
|
||||
/// \return The expected cost of vector Insert and Extract.
|
||||
/// Use -1 to indicate that there is no information on the index value.
|
||||
|
||||
@@ -781,8 +781,8 @@ public:
|
||||
|
||||
virtual InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
|
||||
TTI::TargetCostKind CostKind,
|
||||
unsigned Index, Value *Op0,
|
||||
Value *Op1) const {
|
||||
unsigned Index, const Value *Op0,
|
||||
const Value *Op1) const {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1410,8 +1410,8 @@ public:
|
||||
|
||||
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
|
||||
TTI::TargetCostKind CostKind,
|
||||
unsigned Index, Value *Op0,
|
||||
Value *Op1) const override {
|
||||
unsigned Index, const Value *Op0,
|
||||
const Value *Op1) const override {
|
||||
return getRegUsageForType(Val->getScalarType());
|
||||
}
|
||||
|
||||
|
||||
@@ -1085,7 +1085,7 @@ InstructionCost TargetTransformInfo::getCmpSelInstrCost(
|
||||
|
||||
InstructionCost TargetTransformInfo::getVectorInstrCost(
|
||||
unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index,
|
||||
Value *Op0, Value *Op1) const {
|
||||
const Value *Op0, const Value *Op1) const {
|
||||
assert((Opcode == Instruction::InsertElement ||
|
||||
Opcode == Instruction::ExtractElement) &&
|
||||
"Expecting Opcode to be insertelement/extractelement.");
|
||||
|
||||
@@ -3857,8 +3857,9 @@ InstructionCost AArch64TTIImpl::getVectorInstrCostHelper(
|
||||
|
||||
InstructionCost AArch64TTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
|
||||
TTI::TargetCostKind CostKind,
|
||||
unsigned Index, Value *Op0,
|
||||
Value *Op1) const {
|
||||
unsigned Index,
|
||||
const Value *Op0,
|
||||
const Value *Op1) const {
|
||||
bool HasRealUse =
|
||||
Opcode == Instruction::InsertElement && Op0 && !isa<UndefValue>(Op0);
|
||||
return getVectorInstrCostHelper(Opcode, Val, CostKind, Index, HasRealUse);
|
||||
|
||||
@@ -205,8 +205,8 @@ public:
|
||||
|
||||
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
|
||||
TTI::TargetCostKind CostKind,
|
||||
unsigned Index, Value *Op0,
|
||||
Value *Op1) const override;
|
||||
unsigned Index, const Value *Op0,
|
||||
const Value *Op1) const override;
|
||||
|
||||
/// \param ScalarUserAndIdx encodes the information about extracts from a
|
||||
/// vector with 'Scalar' being the value being extracted,'User' being the user
|
||||
|
||||
@@ -834,8 +834,8 @@ GCNTTIImpl::getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty,
|
||||
|
||||
InstructionCost GCNTTIImpl::getVectorInstrCost(unsigned Opcode, Type *ValTy,
|
||||
TTI::TargetCostKind CostKind,
|
||||
unsigned Index, Value *Op0,
|
||||
Value *Op1) const {
|
||||
unsigned Index, const Value *Op0,
|
||||
const Value *Op1) const {
|
||||
switch (Opcode) {
|
||||
case Instruction::ExtractElement:
|
||||
case Instruction::InsertElement: {
|
||||
|
||||
@@ -170,8 +170,8 @@ public:
|
||||
using BaseT::getVectorInstrCost;
|
||||
InstructionCost getVectorInstrCost(unsigned Opcode, Type *ValTy,
|
||||
TTI::TargetCostKind CostKind,
|
||||
unsigned Index, Value *Op0,
|
||||
Value *Op1) const override;
|
||||
unsigned Index, const Value *Op0,
|
||||
const Value *Op1) const override;
|
||||
|
||||
bool isReadRegisterSourceOfDivergence(const IntrinsicInst *ReadReg) const;
|
||||
bool isSourceOfDivergence(const Value *V) const override;
|
||||
|
||||
@@ -110,8 +110,9 @@ InstructionCost R600TTIImpl::getCFInstrCost(unsigned Opcode,
|
||||
|
||||
InstructionCost R600TTIImpl::getVectorInstrCost(unsigned Opcode, Type *ValTy,
|
||||
TTI::TargetCostKind CostKind,
|
||||
unsigned Index, Value *Op0,
|
||||
Value *Op1) const {
|
||||
unsigned Index,
|
||||
const Value *Op0,
|
||||
const Value *Op1) const {
|
||||
switch (Opcode) {
|
||||
case Instruction::ExtractElement:
|
||||
case Instruction::InsertElement: {
|
||||
|
||||
@@ -64,8 +64,8 @@ public:
|
||||
using BaseT::getVectorInstrCost;
|
||||
InstructionCost getVectorInstrCost(unsigned Opcode, Type *ValTy,
|
||||
TTI::TargetCostKind CostKind,
|
||||
unsigned Index, Value *Op0,
|
||||
Value *Op1) const override;
|
||||
unsigned Index, const Value *Op0,
|
||||
const Value *Op1) const override;
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
@@ -901,8 +901,8 @@ InstructionCost ARMTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
|
||||
|
||||
InstructionCost ARMTTIImpl::getVectorInstrCost(unsigned Opcode, Type *ValTy,
|
||||
TTI::TargetCostKind CostKind,
|
||||
unsigned Index, Value *Op0,
|
||||
Value *Op1) const {
|
||||
unsigned Index, const Value *Op0,
|
||||
const Value *Op1) const {
|
||||
// Penalize inserting into an D-subregister. We end up with a three times
|
||||
// lower estimated throughput on swift.
|
||||
if (ST->hasSlowLoadDSubregister() && Opcode == Instruction::InsertElement &&
|
||||
|
||||
@@ -255,8 +255,8 @@ public:
|
||||
using BaseT::getVectorInstrCost;
|
||||
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
|
||||
TTI::TargetCostKind CostKind,
|
||||
unsigned Index, Value *Op0,
|
||||
Value *Op1) const override;
|
||||
unsigned Index, const Value *Op0,
|
||||
const Value *Op1) const override;
|
||||
|
||||
InstructionCost getAddressComputationCost(Type *Val, ScalarEvolution *SE,
|
||||
const SCEV *Ptr) const override;
|
||||
|
||||
@@ -316,8 +316,9 @@ InstructionCost HexagonTTIImpl::getCastInstrCost(unsigned Opcode, Type *DstTy,
|
||||
|
||||
InstructionCost HexagonTTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
|
||||
TTI::TargetCostKind CostKind,
|
||||
unsigned Index, Value *Op0,
|
||||
Value *Op1) const {
|
||||
unsigned Index,
|
||||
const Value *Op0,
|
||||
const Value *Op1) const {
|
||||
Type *ElemTy = Val->isVectorTy() ? cast<VectorType>(Val)->getElementType()
|
||||
: Val;
|
||||
if (Opcode == Instruction::InsertElement) {
|
||||
|
||||
@@ -155,8 +155,8 @@ public:
|
||||
using BaseT::getVectorInstrCost;
|
||||
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
|
||||
TTI::TargetCostKind CostKind,
|
||||
unsigned Index, Value *Op0,
|
||||
Value *Op1) const override;
|
||||
unsigned Index, const Value *Op0,
|
||||
const Value *Op1) const override;
|
||||
|
||||
InstructionCost
|
||||
getCFInstrCost(unsigned Opcode, TTI::TargetCostKind CostKind,
|
||||
|
||||
@@ -674,8 +674,8 @@ InstructionCost PPCTTIImpl::getCmpSelInstrCost(
|
||||
|
||||
InstructionCost PPCTTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
|
||||
TTI::TargetCostKind CostKind,
|
||||
unsigned Index, Value *Op0,
|
||||
Value *Op1) const {
|
||||
unsigned Index, const Value *Op0,
|
||||
const Value *Op1) const {
|
||||
assert(Val->isVectorTy() && "This must be a vector type");
|
||||
|
||||
int ISD = TLI->InstructionOpcodeToISD(Opcode);
|
||||
|
||||
@@ -130,8 +130,8 @@ public:
|
||||
using BaseT::getVectorInstrCost;
|
||||
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
|
||||
TTI::TargetCostKind CostKind,
|
||||
unsigned Index, Value *Op0,
|
||||
Value *Op1) const override;
|
||||
unsigned Index, const Value *Op0,
|
||||
const Value *Op1) const override;
|
||||
InstructionCost getMemoryOpCost(
|
||||
unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,
|
||||
TTI::TargetCostKind CostKind,
|
||||
|
||||
@@ -2189,8 +2189,9 @@ InstructionCost RISCVTTIImpl::getCFInstrCost(unsigned Opcode,
|
||||
|
||||
InstructionCost RISCVTTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
|
||||
TTI::TargetCostKind CostKind,
|
||||
unsigned Index, Value *Op0,
|
||||
Value *Op1) const {
|
||||
unsigned Index,
|
||||
const Value *Op0,
|
||||
const Value *Op1) const {
|
||||
assert(Val->isVectorTy() && "This must be a vector type");
|
||||
|
||||
if (Opcode != Instruction::ExtractElement &&
|
||||
|
||||
@@ -238,8 +238,8 @@ public:
|
||||
using BaseT::getVectorInstrCost;
|
||||
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
|
||||
TTI::TargetCostKind CostKind,
|
||||
unsigned Index, Value *Op0,
|
||||
Value *Op1) const override;
|
||||
unsigned Index, const Value *Op0,
|
||||
const Value *Op1) const override;
|
||||
|
||||
InstructionCost getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
|
||||
|
||||
@@ -497,7 +497,7 @@ bool SystemZTTIImpl::hasDivRemOp(Type *DataType, bool IsSigned) const {
|
||||
return (VT.isScalarInteger() && TLI->isTypeLegal(VT));
|
||||
}
|
||||
|
||||
static bool isFreeEltLoad(Value *Op) {
|
||||
static bool isFreeEltLoad(const Value *Op) {
|
||||
if (isa<LoadInst>(Op) && Op->hasOneUse()) {
|
||||
const Instruction *UserI = cast<Instruction>(*Op->user_begin());
|
||||
return !isa<StoreInst>(UserI); // Prefer MVC
|
||||
@@ -1194,8 +1194,9 @@ InstructionCost SystemZTTIImpl::getCmpSelInstrCost(
|
||||
|
||||
InstructionCost SystemZTTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
|
||||
TTI::TargetCostKind CostKind,
|
||||
unsigned Index, Value *Op0,
|
||||
Value *Op1) const {
|
||||
unsigned Index,
|
||||
const Value *Op0,
|
||||
const Value *Op1) const {
|
||||
if (Opcode == Instruction::InsertElement) {
|
||||
// Vector Element Load.
|
||||
if (Op1 != nullptr && isFreeEltLoad(Op1))
|
||||
|
||||
@@ -123,8 +123,8 @@ public:
|
||||
using BaseT::getVectorInstrCost;
|
||||
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
|
||||
TTI::TargetCostKind CostKind,
|
||||
unsigned Index, Value *Op0,
|
||||
Value *Op1) const override;
|
||||
unsigned Index, const Value *Op0,
|
||||
const Value *Op1) const override;
|
||||
bool isFoldableLoad(const LoadInst *Ld,
|
||||
const Instruction *&FoldedValue) const;
|
||||
InstructionCost getMemoryOpCost(
|
||||
|
||||
@@ -184,7 +184,7 @@ InstructionCost WebAssemblyTTIImpl::getMemoryOpCost(
|
||||
|
||||
InstructionCost WebAssemblyTTIImpl::getVectorInstrCost(
|
||||
unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index,
|
||||
Value *Op0, Value *Op1) const {
|
||||
const Value *Op0, const Value *Op1) const {
|
||||
InstructionCost Cost = BasicTTIImplBase::getVectorInstrCost(
|
||||
Opcode, Val, CostKind, Index, Op0, Op1);
|
||||
|
||||
|
||||
@@ -81,8 +81,8 @@ public:
|
||||
using BaseT::getVectorInstrCost;
|
||||
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
|
||||
TTI::TargetCostKind CostKind,
|
||||
unsigned Index, Value *Op0,
|
||||
Value *Op1) const override;
|
||||
unsigned Index, const Value *Op0,
|
||||
const Value *Op1) const override;
|
||||
InstructionCost getPartialReductionCost(
|
||||
unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType,
|
||||
ElementCount VF, TTI::PartialReductionExtendKind OpAExtend,
|
||||
|
||||
@@ -4767,8 +4767,8 @@ X86TTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
|
||||
InstructionCost X86TTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
|
||||
TTI::TargetCostKind CostKind,
|
||||
unsigned Index, Value *Op0,
|
||||
Value *Op1) const {
|
||||
unsigned Index, const Value *Op0,
|
||||
const Value *Op1) const {
|
||||
static const CostTblEntry SLMCostTbl[] = {
|
||||
{ ISD::EXTRACT_VECTOR_ELT, MVT::i8, 4 },
|
||||
{ ISD::EXTRACT_VECTOR_ELT, MVT::i16, 4 },
|
||||
|
||||
@@ -166,8 +166,8 @@ public:
|
||||
using BaseT::getVectorInstrCost;
|
||||
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
|
||||
TTI::TargetCostKind CostKind,
|
||||
unsigned Index, Value *Op0,
|
||||
Value *Op1) const override;
|
||||
unsigned Index, const Value *Op0,
|
||||
const Value *Op1) const override;
|
||||
InstructionCost getScalarizationOverhead(
|
||||
VectorType *Ty, const APInt &DemandedElts, bool Insert, bool Extract,
|
||||
TTI::TargetCostKind CostKind, bool ForPoisonSrc = true,
|
||||
|
||||
Reference in New Issue
Block a user