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

David Li via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 14 13:10:13 PDT 2016

davidxl added inline comments.

Comment at: lib/CodeGen/MachineBlockPlacement.cpp:596
@@ -595,2 +595,3 @@
-  BranchProbability HotProb = getLayoutSuccessorProbThreshold();
+  BranchProbability HotProb = getLayoutSuccessorProbThreshold(
+      BB->getParent()->getFunction()->getEntryCount().hasValue());
There is no need to pass this parameter -- MachineFunction  is now a member field in the class.

Comment at: lib/CodeGen/MachineBlockPlacement.cpp:621
@@ +620,3 @@
+    // be added to PredEdgeFrequency to compare with CandidateEdgeFreq.
+    if (BB->isSuccessor(Pred))
+      PredEdgeFreq +=
It is probably not a good idea to bump the frequency of the alternate edge. Instead we should adjust the HotProb threshold computed by:

HotProb = getLayoutSuccessorProbThreshold(BB, Succ);

For instance

 |    \
 |    Pred
 |    /

When Edge BB->Succ is examined, with PGO, the thresold should be adjusted to ~66% (compared to 50% default).  In order words, in this shape, in order for BB->Succ to be considered, it needs at least 66% likely.

We should not change the non-PGO default (80%) now (can be done later -- but since it requires 'guessing' probbaility, a lot more perf testing is needed in order to change that)


More information about the llvm-commits mailing list