<div dir="ltr">Hi John,<br><br>I hadn't seen alive2, amazing program, thank you! Keep up the good work.<br><br>> I'm not sure that I've captured what you mean here<br><br>To be more specific for everyone:<br>- First of all, I hope it's clear that in the original (C) code, the region - 0x8 > 1000 branch should<br>be eliminated. That is because it is inside a block that has ensured that 8 < region < 12. But for some reason,<br>it is not eliminated. I'm trying to find that reason. :)<br>- I understand that in the -O2 .ll output, we take %0 and do it a right shift. That means that we don't have<br>any range info about %0 or %0 >>= 1, so we can't eliminate the branch. What I don't understand<br>is why we chose to reuse %0 and do it a right shift and instead we didn't have a phi there.<br>- Finally, I saw that putting nuw in the addition with -8 eliminates the branch. This makes sense since,<br>we know probably know from the code above that %0 >>= 1 is less than 12. Although, I don't understand<br>why the right shift was translated to an add with -16.<br><br>I hope this made some sense. You may ignore the last 2 and focus on the first, i.e. what optimization<br>should have been done but it's not and what we can do about it.<br><br>A clearer version of the .ll: <a href="https://godbolt.org/z/2t4RU5">https://godbolt.org/z/2t4RU5</a><br><br>Best,<br>Stefanos<br><br>p.s. John I had sent you an e-mail regarding loop rotation some time ago. I'm not sure if it was intentional<br>on your part to be skipped, if so, sorry to bother you. :) But there's the alternative that it was just lost.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Στις Κυρ, 5 Απρ 2020 στις 7:12 π.μ., ο/η John Regehr via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> έγραψε:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I'm not sure that I've captured what you mean here, but you can explore <br>
these sorts of things using Alive2:<br>
<br>
   <a href="http://volta.cs.utah.edu:8080/z/b7Yj7j" rel="noreferrer" target="_blank">http://volta.cs.utah.edu:8080/z/b7Yj7j</a><br>
<br>
John<br>
<br>
<br>
<br>
On 4/4/20 6:29 PM, Stefanos Baziotis via llvm-dev wrote:<br>
> Hi everyone,<br>
> <br>
> In a twitch chat someone redirected me to an example that is not <br>
> optimized: <a href="https://godbolt.org/z/BL-4jL" rel="noreferrer" target="_blank">https://godbolt.org/z/BL-4jL</a><br>
> <br>
> I included the original source code and this is after -O2. We both <br>
> thought that the -8 branch could be optimized out. I added a nuw in the <br>
> subtraction and it actually does it.<br>
> <br>
> Any thoughts on why that doesn't happen already?<br>
> <br>
> Best,<br>
> Stefanos Baziotis<br>
> <br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
> <br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>