<div dir="ltr">What is the use-case that makes this better than the following?<div><br></div><div><div>WHILE (condition) DO</div><div>          action</div><div>          IF (condition) THEN</div><div>               action</div><div>               IF (condition) THEN</div><div>                    action</div><div>               ENDIF</div><div>          ENDIF</div><div>ENDWHILE</div></div><div><br></div><div><br></div><div>If your loop normally gets executed a lot of times, then even this should be better, with one fewer duplication of "action"?</div><div><br></div><div><div>WHILE (condition) DO</div><div>          action</div><div>          IF (condition) THEN</div><div>               action</div><div>          ENDIF<br></div><div>ENDWHILE</div></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jun 7, 2015 at 8:24 PM, Zhoulai <span dir="ltr"><<a href="mailto:zell08v@gmail.com" target="_blank">zell08v@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Hello, <br><br></div>I am looking for a loop unfolding procedure implemented in LLVM that helps to transform a while-loop to n-layer If-statements. The transformation should be on IR,  although the example below is illustrated on the source level.  <br><br></div>original loop:<br><pre><i> WHILE (condition) DO
         action
 ENDWHILE</i><br><br></pre><pre>Expected unfolded loop (2-layer):<br><i><br> IF (condition) THEN<br></i></pre><pre><i>          action<br></i></pre><pre><i>          IF (condition) THEN<br></i></pre><pre><i>               action<br></i></pre><pre><i>               WHILE (condition) DO
                    action
               ENDWHILE
</i></pre><i>                      ENDIF<br></i></div><i>  ENDIF</i><br clear="all"><div><div><div><div><div><div><div><br><br></div><div>(I thought such transformation is somewhat standard but do not find it the related API of LLVM:loop:   <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_docs_doxygen_html_classllvm-5F1-5F1Loop.html&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=yM0Vi5USSIlDTpHDzlYOLQJuCxxBQnb1HDijbKLUPIA&s=kcfE20E9Tv_peJ2EC7XSVgW0btFfF-joP8HfqPyWes4&e=" target="_blank">http://llvm.org/docs/doxygen/html/classllvm_1_1Loop.html</a>)<br><br>Thanks for your help.<br><br></div><div>Sincerely,<br clear="all"></div><div><div><div>Zhoulai</div></div>
</div>
</div></div></div></div></div></div></div>
<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>
<br></blockquote></div><br></div>