<div class="gmail_quote">On 4 June 2010 10:43, Daniel Berlin <span dir="ltr"><<a href="mailto:dberlin@dberlin.org">dberlin@dberlin.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">On Fri, Jun 4, 2010 at 8:18 AM, Pekka Nikander<br>
<<a href="mailto:pekka.nikander@nomadiclab.com">pekka.nikander@nomadiclab.com</a>> wrote:<br>
</div><div class="im">> I am working on heavily optimising unusually static C++ code, and have encountered a situation where I basically want an optimiser that would speculatively unroll a loop to see if the first round of the loop could be optimised further.  (I happen to know that it is possible.)  The previous optimisations that produce the loop in the first place already do a magical job (relying heavily on constant propagation), transforming cross-class tail recursion into the loop that I am now addressing. Hence, there is probably little than can be done in the previous optimisations.<br>


><br>
> So, has anyone worked on an optimisation where the optimiser unrolls a loop so a way that allows it to speculatively try if the first round can be further simplified?<br>
><br>
> In my case, the loop actually calls a C++ virtual method, but since the instance object is a *constant* on the first round of the loop, it is possible to resolve the method call into a static function, and then inline the static function, which in this case essentially eliminates the first round of the loop.<br>


<br>
</div>The combination of GVN-PRE and SCCVN in GCC will do this, and we<br>
actually block it from doing this in a lot of cases.<br>
<br>
Basically, it can discover some value is constant on the first run<br>
through a loop, and will create additional phi nodes to represent<br>
those values.<br>
<br>
In most cases, this is not that valuable (IE it would discover i = i +<br>
1 is 2 on the first run through the loop, and replace it with a phi of<br>
(2, <new calculation>) , and in fact, was significantly confusing to<br>
SCEV analysis. So we blocked it. In your case, it would be valuable<br>
however.<br></blockquote><div><br></div><div>I would suggest trying to do this on any pointer-typed const-expr. Thoughts?</div><div><br></div><div>Nick</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">


<br>
--Dan<br>
<div><div></div><div class="h5"><br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br>