Hi all,<div><br></div><div>I have tried to use the loop-unroll pass on a large example, but without success. So I have tried on smaller examples, and I did not get more success.</div><div><br></div><div>My simplest example is attached. It comes from this C code (using llvm-gcc, but similar result with clang):</div>
<div><div><br></div><div>int main (int argc, char *argv[]) {</div><div>  int i;</div><div>  for (i = 0; i!=5; ++i) {}</div><div>  return 0;</div><div>}</div></div><div><br></div><div>I use this command (version 2.8svn, from July 1st)</div>
<div>~/Build/llvm-trunk/Release/bin/opt -mem2reg -indvars -loop-unroll -stats loop.ll | llvm-dis</div><div><br></div><div>Whereas ScalarEvolution can compute the loop count, LoopInfo fails because the conditional branch is not in the expected block. If I provide the loop count with -unroll-count=5, then the function UnrollLoop fails form the same reason. The pass "-loopsimplify" has no effect.</div>
<div><br></div><div>If I add the pass "-loop-rotate" before "-indvars", then the loop is successfully unrolled. However, I think this pass may increase the size of the code for all loops, including the loops that cannot be unrolled.</div>
<div><br></div><div>Is this a bug? Or is there any other pass that can help UnrollLoop?</div><div><br clear="all"><br>-- <br>Claude Helmstetter<br>+86 186 0895 4884 / +33 6 32 99 06 00<br><a href="http://formes.asia/people/Claude.Helmstetter/" target="_blank">http://formes.asia/people/Claude.Helmstetter/</a><br>

<br>
</div>