[PATCH] D81636: [PowerPC][CostModel] remove getUserCost

Sam Parker via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 11 02:26:11 PDT 2020


samparker created this revision.
samparker added reviewers: nemanjai, jonpa, hfinkel.
Herald added subscribers: shchenz, kbarton, hiraditya.
Herald added a project: LLVM.

All the current functionality of the backend implementation should now be managed via the generic implementation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81636

Files:
  llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
  llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h


Index: llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h
===================================================================
--- llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h
+++ llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h
@@ -53,9 +53,6 @@
   int getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
                           Type *Ty, TTI::TargetCostKind CostKind);
 
-  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands,
-                       TTI::TargetCostKind CostKind);
-
   TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth);
   bool isHardwareLoopProfitable(Loop *L, ScalarEvolution &SE,
                                 AssumptionCache &AC,
Index: llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
+++ llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
@@ -209,23 +209,6 @@
   return PPCTTIImpl::getIntImmCost(Imm, Ty, CostKind);
 }
 
-unsigned
-PPCTTIImpl::getUserCost(const User *U, ArrayRef<const Value *> Operands,
-                        TTI::TargetCostKind CostKind) {
-  // We already implement getCastInstrCost and getMemoryOpCost where we perform
-  // the vector adjustment there.
-  if (isa<CastInst>(U) || isa<LoadInst>(U) || isa<StoreInst>(U))
-    return BaseT::getUserCost(U, Operands, CostKind);
-
-  if (U->getType()->isVectorTy()) {
-    // Instructions that need to be split should cost more.
-    std::pair<int, MVT> LT = TLI->getTypeLegalizationCost(DL, U->getType());
-    return LT.first * BaseT::getUserCost(U, Operands, CostKind);
-  }
-
-  return BaseT::getUserCost(U, Operands, CostKind);
-}
-
 bool PPCTTIImpl::mightUseCTR(BasicBlock *BB, TargetLibraryInfo *LibInfo,
                              SmallPtrSetImpl<const Value *> &Visited) {
   const PPCTargetMachine &TM = ST->getTargetMachine();
@@ -741,10 +724,17 @@
                                        const Instruction *CxtI) {
   assert(TLI->InstructionOpcodeToISD(Opcode) && "Invalid opcode");
   // TODO: Handle more cost kinds.
-  if (CostKind != TTI::TCK_RecipThroughput)
-    return BaseT::getArithmeticInstrCost(Opcode, Ty, CostKind, Op1Info,
-                                         Op2Info, Opd1PropInfo,
-                                         Opd2PropInfo, Args, CxtI);
+  if (CostKind != TTI::TCK_RecipThroughput) {
+    int Cost = BaseT::getArithmeticInstrCost(Opcode, Ty, CostKind, Op1Info,
+                                             Op2Info, Opd1PropInfo,
+                                             Opd2PropInfo, Args, CxtI);
+    if (Ty->isVectorTy()) {
+      // Instructions that need to be split should cost more.
+      std::pair<int, MVT> LT = TLI->getTypeLegalizationCost(DL, Ty);
+      return LT.first * Cost;
+    }
+    return Cost;
+  }
 
   // Fallback to the default implementation.
   int Cost = BaseT::getArithmeticInstrCost(Opcode, Ty, CostKind, Op1Info,
@@ -785,8 +775,14 @@
                                    const Instruction *I) {
   int Cost = BaseT::getCmpSelInstrCost(Opcode, ValTy, CondTy, CostKind, I);
   // TODO: Handle other cost kinds.
-  if (CostKind != TTI::TCK_RecipThroughput)
+  if (CostKind != TTI::TCK_RecipThroughput) {
+    if (ValTy->isVectorTy()) {
+      // Instructions that need to be split should cost more.
+      std::pair<int, MVT> LT = TLI->getTypeLegalizationCost(DL, ValTy);
+      return LT.first * Cost;
+    }
     return Cost;
+  }
   return vectorCostAdjustment(Cost, Opcode, ValTy, nullptr);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81636.270071.patch
Type: text/x-patch
Size: 3553 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200611/3b736fbd/attachment.bin>


More information about the llvm-commits mailing list