[llvm] b994f87 - [Analysis] CostModel.cpp - merge isa<IntrinsicInst> and dyn_cast<IntrinsicInst> checks

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 18 02:44:03 PDT 2022


Author: Simon Pilgrim
Date: 2022-08-18T10:43:29+01:00
New Revision: b994f8718409e13607063fd394edd2ef9f7d5e68

URL: https://github.com/llvm/llvm-project/commit/b994f8718409e13607063fd394edd2ef9f7d5e68
DIFF: https://github.com/llvm/llvm-project/commit/b994f8718409e13607063fd394edd2ef9f7d5e68.diff

LOG: [Analysis] CostModel.cpp - merge isa<IntrinsicInst> and dyn_cast<IntrinsicInst> checks

Pulled out of D79483

Added: 
    

Modified: 
    llvm/lib/Analysis/CostModel.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/CostModel.cpp b/llvm/lib/Analysis/CostModel.cpp
index 2b4499636400b..c6a68522993b8 100644
--- a/llvm/lib/Analysis/CostModel.cpp
+++ b/llvm/lib/Analysis/CostModel.cpp
@@ -100,8 +100,8 @@ void CostModelAnalysis::print(raw_ostream &OS, const Module*) const {
   for (BasicBlock &B : *F) {
     for (Instruction &Inst : B) {
       InstructionCost Cost;
-      if (TypeBasedIntrinsicCost && isa<IntrinsicInst>(&Inst)) {
-        auto *II = dyn_cast<IntrinsicInst>(&Inst);
+      auto *II = dyn_cast<IntrinsicInst>(&Inst);
+      if (II && TypeBasedIntrinsicCost) {
         IntrinsicCostAttributes ICA(II->getIntrinsicID(), *II,
                                     InstructionCost::getInvalid(), true);
         Cost = TTI->getIntrinsicInstrCost(ICA, CostKind);
@@ -128,8 +128,8 @@ PreservedAnalyses CostModelPrinterPass::run(Function &F,
       // TODO: Use a pass parameter instead of cl::opt CostKind to determine
       // which cost kind to print.
       InstructionCost Cost;
-      if (TypeBasedIntrinsicCost && isa<IntrinsicInst>(&Inst)) {
-        auto *II = dyn_cast<IntrinsicInst>(&Inst);
+      auto *II = dyn_cast<IntrinsicInst>(&Inst);
+      if (II && TypeBasedIntrinsicCost) {
         IntrinsicCostAttributes ICA(II->getIntrinsicID(), *II,
                                     InstructionCost::getInvalid(), true);
         Cost = TTI.getIntrinsicInstrCost(ICA, CostKind);


        


More information about the llvm-commits mailing list