[llvm] r277651 - GVN-hoist: limit the length of dependent instructions

Sebastian Pop via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 3 13:54:38 PDT 2016


Author: spop
Date: Wed Aug  3 15:54:38 2016
New Revision: 277651

URL: http://llvm.org/viewvc/llvm-project?rev=277651&view=rev
Log:
GVN-hoist: limit the length of dependent instructions

Limit the number of times the while(1) loop is executed. With this restriction
the number of hoisted instructions does not change in a significant way on the
test-suite.

Differential Revision: https://reviews.llvm.org/D23028

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

Modified: llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp?rev=277651&r1=277650&r2=277651&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp Wed Aug  3 15:54:38 2016
@@ -53,6 +53,11 @@ static cl::opt<int> MaxDepthInBB(
     cl::desc("Hoist instructions from the beginning of the BB up to the "
              "maximum specified depth (default = 100, unlimited = -1)"));
 
+static cl::opt<int> MaxChainLength(
+    "gvn-hoist-max-chain-length", cl::Hidden, cl::init(10),
+    cl::desc("Maximum length of dependent chains to hoist "
+             "(default = 10, unlimited = -1)"));
+
 namespace {
 
 // Provides a sorting function based on the execution order of two instructions.
@@ -212,8 +217,13 @@ public:
         DFSNumber[&Inst] = ++I;
     }
 
+    int ChainLength = 0;
+
     // FIXME: use lazy evaluation of VN to avoid the fix-point computation.
     while (1) {
+      if (MaxChainLength != -1 && ++ChainLength >= MaxChainLength)
+        return Res;
+
       auto HoistStat = hoistExpressions(F);
       if (HoistStat.first + HoistStat.second == 0)
         return Res;




More information about the llvm-commits mailing list