@@ -1365,43 +1365,6 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
13651365  InstructionCost
13661366  getCFInstrCost (unsigned  Opcode, TTI::TargetCostKind CostKind,
13671367                 const  Instruction *I = nullptr ) const  override  {
1368-     if  (Opcode == Instruction::Switch && CostKind == TTI::TCK_CodeSize && I) {
1369-       const  SwitchInst *SI = cast<SwitchInst>(I);
1370-       unsigned  JumpTableSize, NumSuccs = I->getNumSuccessors ();
1371-       auto  BrCost = thisT ()->getCFInstrCost (Instruction::Br, CostKind);
1372-       if  (SI->defaultDestUnreachable ())
1373-         NumSuccs--;
1374- 
1375-       //  An unreachable switch
1376-       if  (NumSuccs == 0 )
1377-         return  TTI::TCC_Free;
1378- 
1379-       //  A trivial unconditional branch.
1380-       if  (NumSuccs == 1 )
1381-         return  BrCost;
1382- 
1383-       thisT ()->getEstimatedNumberOfCaseClusters (*SI, JumpTableSize, nullptr ,
1384-                                                 nullptr );
1385-       Type *BoolTy = IntegerType::get (SI->getContext (), 1 );
1386-       Type *CondTy = SI->getCondition ()->getType ();
1387-       auto  CmpCost = thisT ()->getCmpSelInstrCost (
1388-           BinaryOperator::ICmp, BoolTy, CondTy, CmpInst::ICMP_UGT, CostKind);
1389- 
1390-       //  Assume that lowering the switch block is implemented by binary search
1391-       //  if no jump table is generated.
1392-       if  (JumpTableSize == 0 )
1393-         return  llvm::Log2_32_Ceil (NumSuccs) * (CmpCost + BrCost);
1394- 
1395-       //  Cost for jump table: load + jump + default compare + default jump
1396-       Type *EntryTy = PointerType::get (SI->getContext (), 0 );
1397-       Align Alignment = thisT ()->DL .getABITypeAlign (EntryTy);
1398-       auto  LoadCost = thisT ()->getMemoryOpCost (Instruction::Load, EntryTy,
1399-                                                Alignment, 0 , CostKind);
1400- 
1401-       return  LoadCost + BrCost +
1402-              (SI->defaultDestUnreachable () ? 0  : (CmpCost + BrCost));
1403-     }
1404- 
14051368    return  BaseT::getCFInstrCost (Opcode, CostKind, I);
14061369  }
14071370
0 commit comments