[PATCH] D62981: [DomTreeUpdater] Add all insert before all delete updates to reduce compile time.

Alina Sbirlea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 7 13:43:31 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL362839: [DomTreeUpdater] Add all insert before all delete updates to reduce compileā€¦ (authored by asbirlea, committed by ).

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62981/new/

https://reviews.llvm.org/D62981

Files:
  llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp


Index: llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -212,13 +212,19 @@
   std::vector<DominatorTree::UpdateType> Updates;
   if (DTU) {
     Updates.reserve(1 + (2 * succ_size(BB)));
-    Updates.push_back({DominatorTree::Delete, PredBB, BB});
-    for (auto I = succ_begin(BB), E = succ_end(BB); I != E; ++I) {
-      Updates.push_back({DominatorTree::Delete, BB, *I});
+    // Add insert edges first. Experimentally, for the particular case of two
+    // blocks that can be merged, with a single successor and single predecessor
+    // respectively, it is beneficial to have all insert updates first. Deleting
+    // edges first may lead to unreachable blocks, followed by inserting edges
+    // making the blocks reachable again. Such DT updates lead to high compile
+    // times. We add inserts before deletes here to reduce compile time.
+    for (auto I = succ_begin(BB), E = succ_end(BB); I != E; ++I)
       // This successor of BB may already have PredBB as a predecessor.
       if (llvm::find(successors(PredBB), *I) == succ_end(PredBB))
         Updates.push_back({DominatorTree::Insert, PredBB, *I});
-    }
+    for (auto I = succ_begin(BB), E = succ_end(BB); I != E; ++I)
+      Updates.push_back({DominatorTree::Delete, BB, *I});
+    Updates.push_back({DominatorTree::Delete, PredBB, BB});
   }
 
   if (MSSAU)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62981.203617.patch
Type: text/x-patch
Size: 1523 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190607/cb91678e/attachment.bin>


More information about the llvm-commits mailing list