[PATCH] D20017: Aggressive choosing best loop top
Ehsan Amiri via llvm-commits
llvm-commits at lists.llvm.org
Mon May 9 08:22:20 PDT 2016
amehsan added inline comments.
================
Comment at: lib/CodeGen/MachineBlockPlacement.cpp:726-742
@@ -719,2 +725,19 @@
/// header is always profitable.
+///
+/// a latch block with conditional exit, and similar to following cfg:
+///
+/// entry original better
+/// | layout layout
+/// ------> loop.header (body) -------- ------
+/// |97% / \ entry entry
+/// | /50% \50% loop.header latch
+/// --- latch <--- if.then if.then loop.header
+/// \ 97% / latch if.then
+/// \3% /3% loop.end loop.end
+/// loop.end
+///
+/// "original layout" cause latch needs a branch jumping back to loop.header
+/// when condition is true, but in "better layout", latch can fall through
+/// loop.header without this jump.
+
MachineBasicBlock *
----------------
amehsan wrote:
> Could this hurt performance for the following example
>
> ```
>
> --------->entry
> | | |
> | | loop header
> | | | \
> | | | \
> | ---- --Latch1<----- if.then
> | | |
> ----------Latch2 <------
>
> Probabilities that matter: loop.heaer--->if.then 99%, if then->Latch 1 99%, Latch1 ---> header 80%
> ```
>
> The problem is that before your change the branch from if.then to Latch 1 is fall thru. After your change it is a jump back. If we have a single latch this shouldn't hurt the performance, but with multiple latches, the number of fall-thrus that your code, removes is more than those that it creates. I am not sure how important this is.
>
> Checking for a single latch should be straightforward using LoopInfo API if this is really a problematic edge case.
>
In the graph that I have drawn, arrows from Latch1 and Latch2 should go back to loop header. I hope it was not confusing.
http://reviews.llvm.org/D20017
More information about the llvm-commits
mailing list