title: GCC can't vectorize this simple loop ('number of iterations cannot be computed') yet managed a similar one in the same code?
body: <p>So, I have C++ code with this loop:</p>
  <pre class="lang-c prettyprint-override"><code>for(i=0;i&lt;(m-1);i++)    N4[i]=(i+m-1-Rigta[i]-1-N3[i])/N0;
  </code></pre>
  <p>All the quantitiy involved are <code>int</code>'s. From GCC's vectorization report I get:</p>
  <pre><code>babar.cpp:233: note: ===== analyze_loop_nest =====
  babar.cpp:233: note: === vect_analyze_loop_form ===
  babar.cpp:233: note: === get_loop_niters ===
  babar.cpp:233: note: not vectorized: number of iterations cannot be computed.
  babar.cpp:233: note: bad loop form.
  </code></pre>
  <p>I wondering why 'the number of iteration cannot be computed'!? FWIW, <code>m</code> is declared as
  <code>const int&amp; m</code>. What makes this even more puzzling is that just above in the same code I have:</p>
  <pre class="lang-c prettyprint-override"><code>for(i=1;i&lt;(m-1);i++)    a2[i]=(x[i]+x[i+m-1])*0.5f;
  </code></pre>
  <p>and the loop above gets vectorized just fine (here <code>a2</code> and <code>x</code> are <code>floats</code>). I'm compiling with the</p>
  <pre><code>-Ofast -ftree-vectorizer-verbose=10 -mtune=native -march=native
  </code></pre>
  <p>flags on GCC 4.8.1 on a i7.</p>
  <p>Thanks in advance,</p>
  <h1>Edit:</h1>
  <p>After @nodakai idea, I tried this:</p>
  <pre class="lang-c prettyprint-override"><code>const int mm = m;
  for(i=0;i&lt;(m-1);i++)    N4[i]=(i+m-1-Rigta[i]-1-N3[i])/N0;
  </code></pre>
  <p>this didn't get me quiet there:</p>
  <pre><code>babar.cpp:234: note: not vectorized: relevant stmt not supported: D.55255_812 = D.55254_811 / N0_34;
  babar.cpp:234: note: bad operation or unsupported loop bound.
  </code></pre>
  <p>so of course, I tried:</p>
  <pre class="lang-c prettyprint-override"><code>const int mm=m;
  const float G0=1.0f/(float)N0;
  for(i=0;i&lt;(mm-1);i++)   N4[i]=(i+mm-1-Rigta[i]-1-N3[i])*G0;
  </code></pre>
  <p>which then produced:</p>
  <pre><code>babar.cpp:235: note: LOOP VECTORIZED.
  </code></pre>
  <p>(e.g. success). Oddly enough, the <code>mm</code> seems necessary(?!).</p>