<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Apr 26, 2013, at 7:32 AM, Jeroen Dobbelaere <<a href="mailto:Jeroen.Dobbelaere@synopsys.com">Jeroen.Dobbelaere@synopsys.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: 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;">Hi Andrew, Shuxin,<br><br>Thanks for the explanation about 'Reassociate'.<br><br>The problem is indeed that one of the variables, becomes loop invariant after<br>some of the loop transformations.<br></div></blockquote><div><br></div><div>I imagine LoopSimplify is enough to fix your loop invariant phi so it's an obvious constant. At least obvious enough for InstCombine to remove it from the loop. Unless LoopSimplify is being defeated by an indirect branch, which is just silly in the case of a loop where the back edge is not indirect.</div><div><br></div><blockquote type="cite"><div style="letter-spacing: 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;"><blockquote type="cite">-----Original Message-----<br>From: Andrew Trick [<a href="mailto:atrick@apple.com">mailto:atrick@apple.com</a>]<br></blockquote>[...]<br><blockquote type="cite">Right. Reassociate ranks expressions by their order in the IR, so shouldn't<br>make matters worse, but it doesn't know about loops so can't expose more<br>of these opportunities AFAIK.<br><br>Jeroen, it may be worth filing a bug. I'm not sure why LSR isn't handling it<br>later.<br><br>For cases that LSR doesn't handle, we've been wanting an MI reassociate<br>pass in the backend anyway to expose ILP. That could clean up cases like this<br>when it's actually on the critical path and we don't mind the regpressure.<br><br></blockquote><br>I inserted a small optimization pass to recognize and fix this exact sequence.<br>This did indeed improve the performance (good ;) ), but not to the amount that I hoped..<br>I'll try to come up with a reduced file that shows this problem and file a bugreport for it.<br></div></blockquote></div><br><div>A bug would be nice. It maybe something to consider if we decide to reorder passes.</div><div><br></div><div>-Andy</div></body></html>