[PATCH] D43256: [MBP] Move a latch block with conditional exit and multi predecessors to top of loop

Guozhi Wei via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 27 13:27:23 PST 2018

Carrot added inline comments.

Comment at: lib/CodeGen/MachineBlockPlacement.cpp:1864
           MBFI->printBlockFreq(dbgs(), Pred) << " freq\n");
-    if (Pred->succ_size() > 1)
+    if (Pred->succ_size() > 2)
davidxl wrote:
> Why is this check needed?
Only two patterns are handled, none of the cases has more than 2 successors.

Comment at: lib/CodeGen/MachineBlockPlacement.cpp:1880
+      // Move the candidate to top must reduce taken branches.
+      if (hasRarePredecessors(Pred, OutBB))
+        continue;
davidxl wrote:
> It makes assumption that there is an existing fall through to the exit bb. If not, it is always beneficial to rotate.
But layout the loop body and rotate loop occur after this function, it is difficult to guess which BB will be put at the bottom of the loop. So to be conservative, assume the current candidate BB can be layout at the bottom, and fall through to the exit bb.


More information about the llvm-commits mailing list