<div dir="ltr">On 3 June 2013 16:33, Nadav Rotem <span dir="ltr"><<a href="mailto:nrotem@apple.com" target="_blank">nrotem@apple.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div style="word-wrap:break-word"><div>Hi Nick, </div><div><br></div><div>Thanks for working on this.  I am glad you got it in, and like you said, I think that it can improve the vector code generation. </div><div class="im">

<div><br><blockquote type="cite"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">So I've updated it to 5 as you asked, but two points. LLVM has made a trade-off in many places (loop unrolling and the inliner's cost analysis for instance) that we spend more compile time optimizing code which uses vectors. Second, in order for this 2^n to ever happen, the function needs to have 2^n instructions in it. Reduced to a mere chain of five instructions, I hope the optimization still fires on real-world code, such as your backwards-iterating example where the loop vectorizer emits redundant shuffles. I don't want to lose the point of this optimization.</span></blockquote>

</div><br></div><div>Consider this code:</div><div><br></div><div>   A</div><div> /    \</div><div> \    /</div><div>   B</div><div> /    \</div><div> \    /</div><div>   C</div><div><div> /    \</div><div> \    /</div><div>

   D</div></div><div><div> /    \</div><div> \    /</div><div>   E</div></div><div><br></div><div>Assume that A-E are all binary operators and that both LHS and RHS use the same value.  If you start scanning E recursively then you will scan D twice, C 4 times, B 8 times, etc. </div>

</div></blockquote><div><br></div><div style>No, it checks for X->hasOneUse() at each step.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">

<div>If you think that 5 is too conservative then you can increase it, assuming that this is a fatal case. But I still care about the worse case scenario. <br></div></div></blockquote><div><br></div><div style>I don't know right now, some time in the future I may revisit this if I discover it's causing a missed optimization problem.</div>

<div style><br></div><div style>Nick</div></div></div></div>