<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div class="moz-cite-prefix">On 08/03/2021 16:50, Florian Hahn wrote:<br>
</div>
<blockquote type="cite" cite="mid:CC876F6D-9DE8-4C60-8446-0AA86CCB45DA@apple.com">
<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><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>
<br class="Apple-interchange-newline">
<div class="">
<div class="">
<div class="moz-cite-prefix">Hi,<br class="">
</div>
<div class="moz-cite-prefix"><br class="">
</div>
<div class="moz-cite-prefix">On 04/03/2021 13:32, Florian Hahn wrote:<br class="">
</div>
<blockquote type="cite" cite="mid:3B0E6BD6-C71E-4203-9909-D4430B4ACA67@apple.com" class="">
<div class=""><br class="">
</div>
<div class="">1. Only peel if the PHI that becomes invariant has any concrete users; if the only users of a phi that becomes invariant are things like llvm.assume, peeling should be very unlikely to be beneficial (note that currently peeling also seems to happily
peel for completely unused phis)</div>
</blockquote>
<p class=""><br class="">
</p>
<p class="">In my example the %34 phi is used in a getelementptr that's used for a load. No assume involved. That phi alone would still cause the issue.</p>
<p class=""><br class="">
</p>
</div>
</div>
</blockquote>
<div><br class="">
</div>
Oh right, there are multiple redundant phis! So that does indeed not apply in this case. It might still be beneficial in general.</div>
</div>
</div>
</blockquote>
<p><br>
</p>
<p>Certainly</p>
<p><br>
</p>
<blockquote type="cite" cite="mid:CC876F6D-9DE8-4C60-8446-0AA86CCB45DA@apple.com">
<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><br class="">
<blockquote type="cite" class="">
<div class="">
<div class="">
<div class=""><br class="webkit-block-placeholder">
</div>
<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><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><br>
</p>
<p>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>
<p><br>
</p>
<p>Thanks for the help. Best regards,</p>
<p><br>
</p>
<p>Thomas<br>
</p>
</body>
</html>