<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Mar 9, 2021, at 13:13, Thomas Preud'homme <<a href="mailto:thomasp@graphcore.ai" class="">thomasp@graphcore.ai</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" class="">

<div class="">
<div class="moz-cite-prefix">On 08/03/2021 16:50, Florian Hahn wrote:<br class="">
</div>
<blockquote type="cite" cite="mid:CC876F6D-9DE8-4C60-8446-0AA86CCB45DA@apple.com" class="">
<div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode:
        space; line-break: after-white-space;" class="">
<div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode:
          space; line-break: after-white-space;" class="">
<br class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On Mar 4, 2021, at 15:53, Thomas Preud'homme <<a href="mailto:thomasp@graphcore.ai" class="" moz-do-not-send="true">thomasp@graphcore.ai</a>> wrote:</div></blockquote></div></div></div></blockquote><blockquote type="cite" cite="mid:CC876F6D-9DE8-4C60-8446-0AA86CCB45DA@apple.com" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode:
        space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode:
          space; line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div class=""><div class="">
<blockquote type="cite" cite="mid:3B0E6BD6-C71E-4203-9909-D4430B4ACA67@apple.com" class="">
<div class="">2. Instcombine before peeling already simplifies the IR so that both incoming values are bit casts of the same value. It probably would be trivial to also have instcombine simplify pointer phis if the incoming values striped by pointer casts are
 equal. (There might be some other reason why we are not doing this at the moment though).</div>
</blockquote><p class=""><br class="">
</p><p class="">As mentioned above, it's not as simple as bitcast of the same pointer so this would not work here. One would have to go look at whether the loads are equivalent which is a more involved check.</p><p class=""><br class="">
</p>
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
That’s true, but I think instcombine already CSE’d the loads. So if we simplify such phis, the unnecessary peeling should not happen <a href="https://reviews.llvm.org/D98058" class="" moz-do-not-send="true">https://reviews.llvm.org/D98058</a><br class="">
</div>
</div>
</div>
</blockquote><p class=""><br class="">
</p><p class="">I tried the patch (thanks) but that did not remove any of the PHI (the 2 loads are still there and thus the bitcast don't appear to have the same source). I'll try tolook at InstCombine to see why loads are not CSE'd.</p><div class=""><br class=""></div></div></div></blockquote><br class=""></div><div><br class=""></div><div>I’m not sure I follow here. For your example (spurious_loop_peeling.cpp), it looks like there’s no peeling happening any more after the patch landed, at least when building for ARM64: <a href="https://godbolt.org/z/q6d6Kn" class="">https://godbolt.org/z/q6d6Kn</a> . Is there anything else that’s going wrong?</div><div><br class=""></div><div>Cheers,</div><div>Florian</div><br class=""></body></html>