<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 12, 2017 at 2:02 PM, Xin Tong <span dir="ltr"><<a href="mailto:trent.xin.tong@gmail.com" target="_blank">trent.xin.tong@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Thu, Jan 12, 2017 at 1:34 PM, Dehao Chen <<a href="mailto:danielcdh@gmail.com">danielcdh@gmail.com</a>> wrote:<br>
> If we assume that the trip count will always be the same, then if back edge<br>
> taken probability falls in the range of (0, 0.5), then it already broke this<br>
> assumption. So we do not have enough info to infer both branch<br>
> probabilities. So probably we should simply set the inner probability as<br>
> "0". And when we estimate loop trip count, we will always return 0 if the<br>
> latch probability is 0. Something like:<br>
><br>
> rotate_update_probability(<wbr>float orig_prob) {<br>
>   branch_prob_outside = orig_prob;<br>
>   if (orig_prob >= 0 && orig_prob < 0.5) {<br>
>     branch_prob_inside = 0;<br>
>   } else {<br>
>     branch_prob_inside = 2 - 1/orig_prob;<br>
>   }<br>
> }<br>
><br>
> int estimate_trip_count(float latch_probability) {<br>
>    if (latch_probability == 0)<br>
>      return 0;<br>
>    else<br>
>      return 1/(1-latch_probability)<br>
> }<br>
<br>
</span>We assume the trip count will be close to each other, they do not have<br>
to be identical =). And that assumption has implications, I addressed<br>
the implications when we have polarized loop tripcounts in an earlier<br>
response. I feel we need to make assumptions and also reason about the<br>
fallouts if that assumption turns out to be not true as Michael said.<br></blockquote><div><br></div><div>Yes, the above code is trying to address one case where the assumption is untrue.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Back to your example, I am not sure i understand it fully, is<br>
orig_prob the probability of branching outside before rotation ?<br></blockquote><div><br></div><div>Yes, orig_prob is the original probability of the branch before loop rotation.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thanks,<br>
-Xin<br>
<div class="HOEnZb"><div class="h5"><br>
><br>
><br>
> On Thu, Jan 12, 2017 at 12:59 PM, Michael Kuperstein via Phabricator<br>
> <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br>
>><br>
>> mkuper added inline comments.<br>
>><br>
>><br>
>> ================<br>
>> Comment at: lib/Transforms/Scalar/<wbr>LoopRotation.cpp:476<br>
>> +  // data.<br>
>> +  if (!<wbr>updateLoopEstimatedBranchWeigh<wbr>t(L, GBI, BI /* OrigHeader BR */)) {<br>
>> +    BI->setMetadata(LLVMContext::<wbr>MD_prof, nullptr);<br>
>> ----------------<br>
>> Also, regardless of the rest of the discussion - I don't think we should<br>
>> drop the metadata on the floor if we fail.<br>
>><br>
>> I don't think "No data is better than imprecise data" is right in the<br>
>> general case, but that's arguable. Specifically here, though, we're<br>
>> imprecise even if updateLoopEstimatedBranchWeigh<wbr>t() succeeds, because of the<br>
>> assumptions we make on the distribution.<br>
>><br>
>><br>
>> <a href="https://reviews.llvm.org/D28593" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D28593</a><br>
>><br>
>><br>
>><br>
><br>
</div></div></blockquote></div><br></div></div>