[NFC][SimplifyCFG] Formatting and variable rename
authorSam Parker <sam.parker@arm.com>
Fri, 21 Aug 2020 12:10:25 +0000 (13:10 +0100)
committerSam Parker <sam.parker@arm.com>
Fri, 21 Aug 2020 12:11:17 +0000 (13:11 +0100)
llvm/lib/Transforms/Utils/SimplifyCFG.cpp

index 1f9e73f..2e41ccc 100644 (file)
@@ -2043,22 +2043,23 @@ bool SimplifyCFGOpt::SpeculativelyExecuteBB(BranchInst *BI, BasicBlock *ThenBB,
   BasicBlock *EndBB = ThenBB->getTerminator()->getSuccessor(0);
 
   TargetTransformInfo::TargetCostKind CostKind =
-    BI->getFunction()->hasMinSize() ?
-    TargetTransformInfo::TCK_CodeSize :
-    TargetTransformInfo::TCK_SizeAndLatency;
+    BI->getFunction()->hasMinSize()
+    ? TargetTransformInfo::TCK_CodeSize
+    TargetTransformInfo::TCK_SizeAndLatency;
   // Check how expensive it will be to insert the necessary selects.
-  unsigned CostOfSelects = 0;
+  int BudgetRemaining =
+    PHINodeFoldingThreshold * TargetTransformInfo::TCC_Basic;
   for (PHINode &PN : EndBB->phis()) {
     unsigned OrigI = PN.getBasicBlockIndex(BB);
     unsigned ThenI = PN.getBasicBlockIndex(ThenBB);
     Value *OrigV = PN.getIncomingValue(OrigI);
     Value *ThenV = PN.getIncomingValue(ThenI);
     if (OrigV != ThenV)
-      CostOfSelects +=
+      BudgetRemaining -=
           TTI.getCmpSelInstrCost(Instruction::Select, PN.getType(), nullptr,
                                  CostKind);
   }
-  if (CostOfSelects > PHINodeFoldingThreshold * TargetTransformInfo::TCC_Basic)
+  if (BudgetRemaining < 0)
     return false;
 
   // If ThenBB is actually on the false edge of the conditional branch, remember