summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/GVNHoist.cpp
diff options
context:
space:
mode:
authorSebastian Pop <sebpop@gmail.com>2016-07-26 00:15:08 +0000
committerSebastian Pop <sebpop@gmail.com>2016-07-26 00:15:08 +0000
commit38422b135678b85d6a02d9a48e4375a9dcc1368c (patch)
treed28d99fa26fe8b59e909c73741ae19f0f21839de /llvm/lib/Transforms/Scalar/GVNHoist.cpp
parent906f6fb565e7bf6cf54fed8955e371d735b06d78 (diff)
downloadbcm5719-llvm-38422b135678b85d6a02d9a48e4375a9dcc1368c.tar.gz
bcm5719-llvm-38422b135678b85d6a02d9a48e4375a9dcc1368c.zip
GVN-hoist: limit hoisting depth (PR28670)
This patch adds an option to specify the maximum depth in a BB at which to consider hoisting instructions. Hoisting instructions from a deeper level is not profitable as it increases register pressure and compilation time. Differential Revision: https://reviews.llvm.org/D22772 llvm-svn: 276713
Diffstat (limited to 'llvm/lib/Transforms/Scalar/GVNHoist.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/GVNHoist.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVNHoist.cpp b/llvm/lib/Transforms/Scalar/GVNHoist.cpp
index 5a50f54cf5f..245fef986a3 100644
--- a/llvm/lib/Transforms/Scalar/GVNHoist.cpp
+++ b/llvm/lib/Transforms/Scalar/GVNHoist.cpp
@@ -48,6 +48,11 @@ static cl::opt<int> MaxNumberOfBBSInPath(
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 @@ private:
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))
OpenPOWER on IntegriCloud