<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 20, 2018 at 8:51 AM, John Brawn via Phabricator <span dir="ltr"><<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">john.brawn added a comment.<br>
<span class=""><br>
In <a href="https://reviews.llvm.org/D35804#1002438" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D35804#1002438</a>, @davidxl wrote:<br>
<br>
> The branch probability depends on other factors which is not considered here.<br>
><br>
> For instance<br>
><br>
> 1. the value of MAX. In the example, if MAX is 1, then the branch probablity should be 50%<br>
> 2. the step /increment of n<br>
><br>
>   More generally, the predicted probability should depend on MAX/step. The larger the value, the less likely the branch is taken.<br>
<br>
<br>
</span>That's true, but making the probability more precise would make the analysis here more complicated and I don't think it's worth it. 50% is a safe lower bound: we know the branch will be not taken at least 50% of the time and never less than that, assuming a large enough number of iterations (for small numbers of iterations whether the iteration count is even/odd will have an effect, e.g. for 1 iteration the branch may be always taken, but when the loop has a small number of iterations it won't be hot so it doesn't matter what we think the probability is).<br></blockquote><div><br></div><div>The problem I mentioned are in two different directions. In one direction, if MAX/step is really large, the BP computed in this analysis won't be biased enough. On the other hand, for very short trip count loops (which can also be very hot), the opposite can happen.  To avoid overcomplicate the analysis, I think it is fine to do a very simple 'step' analysis by looking at the phi. MAX is already known.</div><div><br></div><div>David</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
<br>
Repository:<br>
  rL LLVM<br>
<br>
<a href="https://reviews.llvm.org/D35804" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D35804</a><br>
<br>
<br>
<br>
</div></div></blockquote></div><br></div></div>