[PATCH] D10825: Improvement on computing edge probabilities when choosing the best successor in machine block placement.

Cong Hou congh at google.com
Thu Jul 23 17:08:03 PDT 2015

congh added inline comments.

Comment at: lib/CodeGen/MachineBlockPlacement.cpp:373
@@ +372,3 @@
+    bool SkipSucc = false;
+    if (BlockFilter && !BlockFilter->count(Succ)) {
+      SkipSucc = true;
davidxl wrote:
> This is the case where Succ is in the outer loop of the current loop being laid out. In such a case,  Succ can still be a viable layout successor of BB if BB ends up being the end of the current chain. This is tricky to handle as loop rotation may also change that -- so it seems to good to add this skipping condition, but I'd like to see test cases that can validate it.
Given the following example:

|  / \
| B   C
|  \ / \
----D   E
Assume the weights of A->B and A->C are 1 and 99, and the weights of C->D and C->E are 50 and 50. Without this patch, after A->C is chosen, C->D could not be chosen due to CFG constraint and the probability of it is only 50%. So the generated layout for the loop is A C B D. With this patch, the layout will be A C D B, which is better than before. (Note that with loop rotation the latter may suffer some issue but it isn't the problem of this patch; I will deal with it alter).

I will add such a test case.


More information about the llvm-commits mailing list