<div dir="ltr">ok. Can you add a FIXME comment for limitations here? After that we probably good to go with this.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 21, 2018 at 10:09 AM, John Brawn <span dir="ltr"><<a href="mailto:John.Brawn@arm.com" target="_blank">John.Brawn@arm.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-GB" link="blue" vlink="purple">
<div class="m_-5967009692989250310WordSection1"><span class="">
<p class="MsoNormal">> The problem I mentioned are in two different directions. In one direction, if MAX/step is really large, the BP computed in this<u></u><u></u></p>
<p class="MsoNormal">> 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<u></u><u></u></p>
<p class="MsoNormal">> 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<u></u><u></u></p>
<p class="MsoNormal">> already known.<u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
</span><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">We do know that the value on one side of the comparison is a constant, but we don’t know exactly (without some more work) what kind<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">of comparison it is or how it relates to the loop iteration, e.g. we could have a down-counting loop where the constant being compared<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">against is zero, or there’s the test11 in the tests that are added where a value is being flipped and there’s no incrementing happening at<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">all.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">John<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Xinliang David Li [mailto:<a href="mailto:davidxl@google.com" target="_blank">davidxl@google.com</a>]
<br>
<b>Sent:</b> 20 February 2018 17:05<br>
<b>To:</b> <a href="mailto:reviews%2BD35804%2Bpublic%2B89d09923a0755f84@reviews.llvm.org" target="_blank">reviews+D35804+public+<wbr>89d09923a0755f84@reviews.llvm.<wbr>org</a><br>
<b>Cc:</b> John Brawn; <a href="mailto:serguei.katkov@azul.com" target="_blank">serguei.katkov@azul.com</a>; Chandler Carruth; Vedant Kumar; Junbum Lim; Hal Finkel; llvm-commits; wmi; Florian Hahn<br>
<b>Subject:</b> Re: [PATCH] D35804: [BPI] Detect branches in loops that make themselves not taken<u></u><u></u></span></p>
</div>
</div><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Tue, Feb 20, 2018 at 8:51 AM, John Brawn via Phabricator <<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>> wrote:<u></u><u></u></p>
<p class="MsoNormal">john.brawn added a comment.<br>
<br>
In <a href="https://reviews.llvm.org/D35804#1002438" 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>
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).<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">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.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">David<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
<br>
Repository:<br>
rL LLVM<br>
<br>
<a href="https://reviews.llvm.org/D35804" target="_blank">https://reviews.llvm.org/<wbr>D35804</a><br>
<br>
<br>
<u></u><u></u></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div></div></div>
</div>
</div>
</blockquote></div><br></div>