[PATCH] D21663: [MBP] Enhance cost based branch prob threshold computation to handle general control flows

Dehao Chen via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 23 21:51:07 PDT 2016


For case C, if F1=50, F2=40, F3=20, it seems it's most beneficial to choose
BB->Succ as fall-through than Pred1->Succ or Pred2->Succ, or am I missing
something?

On Thu, Jun 23, 2016 at 8:38 PM, David Li <davidxl at google.com> wrote:

> davidxl added inline comments.
>
> ================
> Comment at: lib/CodeGen/MachineBlockPlacement.cpp:610
> @@ +609,3 @@
> +    //         (C)                 (D)
> +    //  (D) is a degenerated case of (C) where Pred1 does not exist. In
> (D),
> +    //  Let
> ----------------
> danielcdh wrote:
> > You mean in (C), right?
> yes.
>
> ================
> Comment at: lib/CodeGen/MachineBlockPlacement.cpp:624
> @@ +623,3 @@
> +    //  order for BB->Succ to be selected, we must have F1 > F2 + F3. So
> the
> +    //  backward probability threshold is (backward checking igores other
> +    //  predecessors other than Pred2):
> ----------------
> danielcdh wrote:
> > This is a little confusing, I think the condition should be:
> >
> > F1 > max(2*F3, F2)
> >
> > So when checking Pred1, the backward threhold should be 0.66, when
> checking Pred2, the backward threshold should be 0.5?
> >
> > But for the current implementation, I tried all testcase, and some other
> testcases with different triangle-diamond combination, and it always gives
> me optimal solution.
> It is F1 > F2 + F3.
>
> Basically, we are comparing selecting BB->Succ as fall through vs
> selecting BB->Pred1 and Pred2->Succ as fall throughs. In order for BB->Succ
> to succeed, the minimal min(F1) = F2 + F3.
>
> When computing backward probability, only BB->Succ and Pred2->Succ edges
> are considered, so the probability threshold
>   T = min(F1) /(min(F1) + F2) = (F2 + F3 )/(2*F2 + F3).
>
> I will update the comments.
>
>
> http://reviews.llvm.org/D21663
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160623/2d3363b7/attachment.html>


More information about the llvm-commits mailing list