From 274f86e7a6d5468b38be7a4a4008a883a27ce008 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Mon, 22 Aug 2022 10:41:28 -0700 Subject: [PATCH] [TTI] Remove OperandValueKind/Properties from getArithmeticInstrCost interface [nfc] This completes the client side transition to the OperandValueInfo version of this routine. Backend TTI implementations still use the prior versions for now. --- llvm/include/llvm/Analysis/TargetTransformInfo.h | 14 ++------------ llvm/lib/Analysis/TargetTransformInfo.cpp | 12 ------------ llvm/lib/CodeGen/CodeGenPrepare.cpp | 17 ++++++++--------- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 8 ++++++-- 4 files changed, 16 insertions(+), 35 deletions(-) diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h index 590ac70..ece6550 100644 --- a/llvm/include/llvm/Analysis/TargetTransformInfo.h +++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h @@ -904,8 +904,8 @@ public: // of migrating uses of OperandValueKind and OperandValueProperties // to use this class, and then will change the internal representation. struct OperandValueInfo { - OperandValueKind Kind; - OperandValueProperties Properties; + OperandValueKind Kind = OK_AnyValue; + OperandValueProperties Properties = OP_None; }; /// \return the number of registers in the target-provided register class. @@ -1061,16 +1061,6 @@ public: /// provide even more information. InstructionCost getArithmeticInstrCost( unsigned Opcode, Type *Ty, - TTI::TargetCostKind CostKind, - OperandValueKind Opd1Info, - OperandValueKind Opd2Info = OK_AnyValue, - OperandValueProperties Opd1PropInfo = OP_None, - OperandValueProperties Opd2PropInfo = OP_None, - ArrayRef Args = ArrayRef(), - const Instruction *CxtI = nullptr) const; - - InstructionCost getArithmeticInstrCost( - unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput, TTI::OperandValueInfo Opd1Info = {TTI::OK_AnyValue, TTI::OP_None}, TTI::OperandValueInfo Opd2Info = {TTI::OK_AnyValue, TTI::OP_None}, diff --git a/llvm/lib/Analysis/TargetTransformInfo.cpp b/llvm/lib/Analysis/TargetTransformInfo.cpp index 85caa59..7ec968f1 100644 --- a/llvm/lib/Analysis/TargetTransformInfo.cpp +++ b/llvm/lib/Analysis/TargetTransformInfo.cpp @@ -767,18 +767,6 @@ TargetTransformInfo::getOperandInfo(const Value *V) { InstructionCost TargetTransformInfo::getArithmeticInstrCost( unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, - OperandValueKind Opd1Info, OperandValueKind Opd2Info, - OperandValueProperties Opd1PropInfo, OperandValueProperties Opd2PropInfo, - ArrayRef Args, const Instruction *CxtI) const { - InstructionCost Cost = - TTIImpl->getArithmeticInstrCost(Opcode, Ty, CostKind, Opd1Info, Opd2Info, - Opd1PropInfo, Opd2PropInfo, Args, CxtI); - assert(Cost >= 0 && "TTI should not produce negative costs!"); - return Cost; -} - -InstructionCost TargetTransformInfo::getArithmeticInstrCost( - unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, OperandValueInfo Op1Info, OperandValueInfo Op2Info, ArrayRef Args, const Instruction *CxtI) const { InstructionCost Cost = diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 099be15..88c01c3 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -7273,17 +7273,16 @@ class VectorPromoteHelper { Value *Arg0 = Inst->getOperand(0); bool IsArg0Constant = isa(Arg0) || isa(Arg0) || isa(Arg0); - TargetTransformInfo::OperandValueKind Arg0OVK = - IsArg0Constant ? TargetTransformInfo::OK_UniformConstantValue - : TargetTransformInfo::OK_AnyValue; - TargetTransformInfo::OperandValueKind Arg1OVK = - !IsArg0Constant ? TargetTransformInfo::OK_UniformConstantValue - : TargetTransformInfo::OK_AnyValue; + TargetTransformInfo::OperandValueInfo Arg0Info, Arg1Info; + if (IsArg0Constant) + Arg0Info.Kind = TargetTransformInfo::OK_UniformConstantValue; + else + Arg1Info.Kind = TargetTransformInfo::OK_UniformConstantValue; + ScalarCost += TTI.getArithmeticInstrCost( - Inst->getOpcode(), Inst->getType(), CostKind, Arg0OVK, Arg1OVK); + Inst->getOpcode(), Inst->getType(), CostKind, Arg0Info, Arg1Info); VectorCost += TTI.getArithmeticInstrCost(Inst->getOpcode(), PromotedType, - CostKind, - Arg0OVK, Arg1OVK); + CostKind, Arg0Info, Arg1Info); } LLVM_DEBUG( dbgs() << "Estimated cost of computation to be promoted:\nScalar: " diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index aedae33..7d84c26 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -6443,13 +6443,17 @@ InstructionCost BoUpSLP::getEntryCost(const TreeEntry *E, : TargetTransformInfo::OK_UniformConstantValue; InstructionCost ScalarEltCost = TTI->getArithmeticInstrCost( - Instruction::Add, ScalarTy, CostKind, Op1VK, Op2VK); + Instruction::Add, ScalarTy, CostKind, + {Op1VK, TargetTransformInfo::OP_None}, + {Op2VK, TargetTransformInfo::OP_None}); if (NeedToShuffleReuses) { CommonCost -= (EntryVF - VL.size()) * ScalarEltCost; } InstructionCost ScalarCost = VecTy->getNumElements() * ScalarEltCost; InstructionCost VecCost = TTI->getArithmeticInstrCost( - Instruction::Add, VecTy, CostKind, Op1VK, Op2VK); + Instruction::Add, VecTy, CostKind, + {Op1VK, TargetTransformInfo::OP_None}, + {Op2VK, TargetTransformInfo::OP_None}); LLVM_DEBUG(dumpTreeCosts(E, CommonCost, VecCost, ScalarCost)); return CommonCost + VecCost - ScalarCost; } -- 2.7.4