<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Oct 27, 2009, at 9:32 AM, Chris Lattner wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Oct 27, 2009, at 9:26 AM, Nick Lewycky wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="gmail_quote">2009/10/27 Marc Brünink <span dir="ltr"><<a href="mailto:marc@bruenink.de">marc@bruenink.de</a>></span><br><blockquote class="gmail_quote" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); margin-top: 0pt; margin-right: 0pt; margin-bottom: 0pt; margin-left: 0.8ex; padding-left: 1ex; position: static; z-index: auto; ">

Hi all,<br>
<br>
I just noticed that LICM does not hoist/sink the following store out of the loop:<br>
<br>
        int array[20];<br>
        int i;<br>
        for (i = 0; i<100; i++) {<br>
                array [0] = 0;<br>
        }<br>
<br>
The getElementPtr instruction is hoisted out of the loop; the store is not. Did I miss something obvious? Bitcode file attached.<br>
Generated using LLVM 2.5 and<br>
llvm-gcc -c -emit-llvm test_loop.c  -o - | opt  -licm -o test.bc -f<br></blockquote><div><br></div></div>Thanks for the report. Since this still happens with LLVM at the top of SVN, I filed it as <a href="http://llvm.org/PR5319">http://llvm.org/PR5319</a> . Please add yourself to the cc list there.<br></blockquote></div><br><div>This is expected behavior, you need to run loop rotate before licm to get this.   This is completely eliminate at -O3.</div></div></blockquote></div><br><div>So, while this is true, Nick has a good point in PR5319 that we're not catching this at O2 with a slightly more complex testcase.    LICM can definitely be improved here.</div><div><br></div><div>-Chris</div></body></html>