<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><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><br class="Apple-interchange-newline"><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; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 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>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><br></div><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. </div><div><br></div><div>Thanks,</div><div>Nadav</div></body></html>