<div dir="ltr">Hi,<br><br>Aditya, I took a look but I was hoping for a simpler example. And something that is more "usual". As Florian mentioned, these branches are on undefs.<br>But thank you.<br><br>Best,<br>Stefanos</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Στις Δευ, 23 Μαρ 2020 στις 1:16 μ.μ., ο/η Florian Hahn <<a href="mailto:florian_hahn@apple.com">florian_hahn@apple.com</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"><br>
<br>
> On Mar 21, 2020, at 23:13, Aditya K via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
> <br>
> Hi Stefanos,<br>
> <br>
> Thanks for your comments. I added both as reviewer.<br>
> <br>
>> One question though. Are you sure that this:<br>
>> This helps with LICM when instructions inside a conditional is loop invariant <br>
>> is not achieved with the current LoopRotate pass? Because AFAIK, it does. Basically it inserts<br>
>> a guard (that branches to the preheader) and then passes like LICM hoist invariant instructions to the preheader.<br>
>> Also, it does itself host some invariant instructions but only on the header and very limited ones.<br>
> <br>
> Currently LICM does some of it but not all. If there are more than 2 conditionals,<br>
> LICM would fail to move loop invariant from the second conditional because loop rotation didn't peel all the conditionals.<br>
> My observation is from a while ago so happy to be corrected.<br>
<br>
<br>
<br>
Have you considered using the existing LoopPeeling infrastructure (part of loop unrolling) to do the peeling? It already peels off iterations from the start up to a threshold, if it makes a condition in the loop body invariant. <br>
<br>
I am not entirely sure about the exact cases/conditions that the patch targets (the test you mentioned seems to only contain branches on undef), but it might be relatively straight forward to teach the loop peeler to peel of an iteration in those cases.<br>
<br>
Cheers,<br>
Florian</blockquote></div>