[PATCH] D22772: GVN-hoist: limit hoisting depth (PR28670)

Sebastian Pop via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 25 17:22:45 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL276713: GVN-hoist: limit hoisting depth (PR28670) (authored by spop).

Changed prior to commit:
  https://reviews.llvm.org/D22772?vs=65400&id=65451#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22772

Files:
  llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp

Index: llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
+++ llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
@@ -48,6 +48,11 @@
     cl::desc("Max number of basic blocks on the path between "
              "hoisting locations (default = 4, unlimited = -1)"));
 
+static cl::opt<int> MaxDepthInBB(
+    "gvn-hoist-max-depth", cl::Hidden, cl::init(100),
+    cl::desc("Hoist instructions from the beginning of the BB up to the "
+             "maximum specified depth (default = 100, unlimited = -1)"));
+
 namespace {
 
 // Provides a sorting function based on the execution order of two instructions.
@@ -765,7 +770,13 @@
     StoreInfo SI;
     CallInfo CI;
     for (BasicBlock *BB : depth_first(&F.getEntryBlock())) {
+      int InstructionNb = 0;
       for (Instruction &I1 : *BB) {
+        // Only hoist the first instructions in BB up to MaxDepthInBB. Hoisting
+        // deeper may increase the register pressure and compilation time.
+        if (MaxDepthInBB != -1 && InstructionNb++ >= MaxDepthInBB)
+          break;
+
         if (auto *Load = dyn_cast<LoadInst>(&I1))
           LI.insert(Load, VN);
         else if (auto *Store = dyn_cast<StoreInst>(&I1))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22772.65451.patch
Type: text/x-patch
Size: 1286 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160726/f84d74fc/attachment.bin>


More information about the llvm-commits mailing list