[llvm] r346682 - [MachineOutliner][NFC] Early exit pruning when candidates don't share an MBB

Jessica Paquette via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 12 09:50:56 PST 2018


Author: paquette
Date: Mon Nov 12 09:50:56 2018
New Revision: 346682

URL: http://llvm.org/viewvc/llvm-project?rev=346682&view=rev
Log:
[MachineOutliner][NFC] Early exit pruning when candidates don't share an MBB

There's no way they can overlap in this case.

This can save a few iterations when the candidate is close to the beginning
of a MachineBasicBlock. It's particularly useful when the average length of
a MachineBasicBlock in the program is small.

Modified:
    llvm/trunk/lib/CodeGen/MachineOutliner.cpp

Modified: llvm/trunk/lib/CodeGen/MachineOutliner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineOutliner.cpp?rev=346682&r1=346681&r2=346682&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineOutliner.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineOutliner.cpp Mon Nov 12 09:50:56 2018
@@ -1215,12 +1215,20 @@ void MachineOutliner::pruneOverlaps(
     if (C1.getStartIdx() > MaxCandidateLen)
       FarthestPossibleIdx = C1.getStartIdx() - MaxCandidateLen;
 
+    MachineBasicBlock *C1MBB = C1.getMBB();
+
     // Compare against the candidates in the list that start at most
     // FarthestPossibleIdx indices away from C1. There are at most
     // MaxCandidateLen of these.
     for (auto Sit = It + 1; Sit != Et; Sit++) {
       Candidate &C2 = **Sit;
 
+      // If the two candidates don't belong to the same MBB, then we're done.
+      // Because we sorted the candidates, there's no way that we'd find a
+      // candidate in C1MBB after this point.
+      if (C2.getMBB() != C1MBB)
+        break;
+
       // Is this candidate too far away to overlap?
       if (C2.getStartIdx() < FarthestPossibleIdx)
         break;




More information about the llvm-commits mailing list