title: Auto vectorization not working
body: <p>I'm trying to get my code to auto vectorize, but it isn't working.</p>
  
  <pre><code>int _tmain(int argc, _TCHAR* argv[])
  {
      const int N = 4096;
      float x[N];
      float y[N];
      float sum = 0;
  
      //create random values for x and y 
      for (int i = 0; i &lt; N; i++)
      {
          x[i] = rand() &gt;&gt; 1;
          y[i] = rand() &gt;&gt; 1;
      }
  
      for (int i = 0; i &lt; N; i++){
          sum += x[i] * y[i];
      }
  }
  </code></pre>
  
  <p>Neither loop vectorizes here, but I'm really only interested in the second loop.</p>
  
  <p>I'm using visual studio express 2013 and am compiling with the <code>/O2</code> and <code>/Qvec-report:2</code>(To report whether or not the loop was vectorized) options. When I compile, I get the following message:</p>
  
  <pre><code>--- Analyzing function: main
  c:\users\...\documents\visual studio 2013\projects\intrin3\intrin3\intrin3.cpp(28) : info C5002: loop not vectorized due to reason '1200'
  c:\users\...\documents\visual studio 2013\projects\intrin3\intrin3\intrin3.cpp(41) : info C5002: loop not vectorized due to reason '1305'
  </code></pre>
  
  <p>Reason '1305', as can be seen <a href="http://msdn.microsoft.com/en-us/jj658585">HERE</a>, says that "the compiler can't discern proper vectorizable type information for this loop." I'm not really sure what this means. Any ideas?</p>
  
  <p>After splitting the second loop into two loops:</p>
  
  <pre><code>for (int i = 0; i &lt; N; i++){
      sumarray[i] = x[i] * y[i];
  }
  
  for (int i = 0; i &lt; N; i++){
      sum += sumarray[i];
  }
  </code></pre>
  
  <p>Now the first of the above loops vectorizes, but the second one does not, again with error code 1305.</p>