title: Why does gcc4 not unroll this loop?
body: <p>In the <code>gcc 4.4.6</code> docs it is stated:</p>
  
  <blockquote>
  <pre><code>-funroll-all-loops:
  Unroll all loops, even if their number of iterations is uncertain 
  when the loop isentered. 
  </code></pre>
  </blockquote>
  
  <p>I am compiling this code: </p>
  
  <pre><code>int unroll(){
    int i = 0;
    int array[1000];
    do {
      use(i,array);
      i++;
    }while(i&lt;1000);
    return(0);
  }
  
  void use(int i, int *array){
     int x = i*5;
     array[i] = x;
  }
  </code></pre>
  
  <p>...once with the <code>funroll-all-loops</code> optimizations, once without:</p>
  
  <pre><code>OPT = -funroll-all-loops
  NOOPT = -O0
  </code></pre>
  
  <p>Then I use <code>diff</code> to compare the assembly code of each (produced using <code>-S -fverbose-asm</code>). </p>
  
  <p>The produced code is identical. </p>
  
  <p>Tried changing the loop to a <code>do while</code>; 
  adjusting the loop counter (up to 100);
  changing the statements within the loop body. </p>
  
  <p>What could I be missing? Why is this loop not being unrolled?  </p>
  
  <p><strong>Update</strong></p>
  
  <p><a href="https://stackoverflow.com/users/856199/nikos-c">Nikos C</a> suggested to raise the loop enroll parameter using <code>--param max-unroll-times=N</code> where N is the upper limit. 
  While that was a sensible suggestion, it did not change behaviour. 
  I also lowered the loop iterations to only 10. 
  Also updated the code to actually 'do' something, no change.</p>