[PATCH] D31704: [BPI] NFC: reorder ifs to bail out earlier

Serguei Katkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 5 03:38:55 PDT 2017


skatkov created this revision.

This is non-functional change to re-order if statements to bail out earlier
from unreachable and ColdCall heuristics.


https://reviews.llvm.org/D31704

Files:
  lib/Analysis/BranchProbabilityInfo.cpp


Index: lib/Analysis/BranchProbabilityInfo.cpp
===================================================================
--- lib/Analysis/BranchProbabilityInfo.cpp
+++ lib/Analysis/BranchProbabilityInfo.cpp
@@ -187,6 +187,15 @@
   if (TI->getNumSuccessors() == 0)
     return false;
 
+  // Skip probabilities if this block has a single successor.
+  if (TI->getNumSuccessors() == 1)
+    return false;
+
+  // Return false here so that edge weights for InvokeInst could be decided
+  // in calcInvokeHeuristics().
+  if (isa<InvokeInst>(TI))
+    return false;
+
   SmallVector<unsigned, 4> UnreachableEdges;
   SmallVector<unsigned, 4> ReachableEdges;
 
@@ -196,14 +205,8 @@
     else
       ReachableEdges.push_back(I.getSuccessorIndex());
 
-  // Skip probabilities if this block has a single successor or if all were
-  // reachable.
-  if (TI->getNumSuccessors() == 1 || UnreachableEdges.empty())
-    return false;
-
-  // Return false here so that edge weights for InvokeInst could be decided
-  // in calcInvokeHeuristics().
-  if (isa<InvokeInst>(TI))
+  // Skip probabilities if all were reachable.
+  if (UnreachableEdges.empty())
     return false;
 
   if (ReachableEdges.empty()) {
@@ -334,6 +337,15 @@
   if (TI->getNumSuccessors() == 0)
     return false;
 
+  // Skip probabilities if this block has a single successor.
+  if (TI->getNumSuccessors() == 1)
+    return false;
+
+  // Return false here so that edge weights for InvokeInst could be decided
+  // in calcInvokeHeuristics().
+  if (isa<InvokeInst>(TI))
+    return false;
+
   // Determine which successors are post-dominated by a cold block.
   SmallVector<unsigned, 4> ColdEdges;
   SmallVector<unsigned, 4> NormalEdges;
@@ -343,13 +355,8 @@
     else
       NormalEdges.push_back(I.getSuccessorIndex());
 
-  // Return false here so that edge weights for InvokeInst could be decided
-  // in calcInvokeHeuristics().
-  if (isa<InvokeInst>(TI))
-    return false;
-
-  // Skip probabilities if this block has a single successor.
-  if (TI->getNumSuccessors() == 1 || ColdEdges.empty())
+  // Skip probabilities if no cold edges.
+  if (ColdEdges.empty())
     return false;
 
   if (NormalEdges.empty()) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31704.94186.patch
Type: text/x-patch
Size: 2181 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170405/135898ab/attachment.bin>


More information about the llvm-commits mailing list