[PATCH] D20991: Set machine block placement hot prob threshold for both static and runtime profile.

Dehao Chen via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 3 15:21:34 PDT 2016


danielcdh created this revision.
danielcdh added reviewers: davidxl, djasper.
danielcdh added a subscriber: llvm-commits.

With runtime profile, we have more confidence in branch probability, thus during basic block layout, we set a lower hot prob threshold so that blocks can be layouted optimally.

http://reviews.llvm.org/D20991

Files:
  lib/CodeGen/MachineBlockPlacement.cpp

Index: lib/CodeGen/MachineBlockPlacement.cpp
===================================================================
--- lib/CodeGen/MachineBlockPlacement.cpp
+++ lib/CodeGen/MachineBlockPlacement.cpp
@@ -116,6 +116,16 @@
                                       cl::desc("Cost of jump instructions."),
                                       cl::init(1), cl::Hidden);
 
+static cl::opt<unsigned> StaticHotProb(
+    "static-hot-prob",
+    cl::desc("Hot branch probability when only static profile is available."),
+    cl::init(80), cl::Hidden);
+
+static cl::opt<unsigned> ProfileHotProb(
+    "profile-hot-prob",
+    cl::desc("Hot branch probability when only runtime profile is available."),
+    cl::init(50), cl::Hidden);
+
 namespace {
 class BlockChain;
 /// \brief Type for our function-wide basic block -> block chain mapping.
@@ -405,7 +415,10 @@
 MachineBlockPlacement::selectBestSuccessor(MachineBasicBlock *BB,
                                            BlockChain &Chain,
                                            const BlockFilterSet *BlockFilter) {
-  const BranchProbability HotProb(4, 5); // 80%
+  const BranchProbability HotProb(
+      BB->getParent()->getFunction()->getEntryCount() ? ProfileHotProb
+                                                      : StaticHotProb,
+      100);
 
   MachineBasicBlock *BestSucc = nullptr;
   auto BestProb = BranchProbability::getZero();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20991.59634.patch
Type: text/x-patch
Size: 1399 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160603/d9451f13/attachment.bin>


More information about the llvm-commits mailing list