title: Getting wrong results with using AVX instructions and -O3 compiling option
body: <p>I wrote very simple program with AVX instructions, but I am getting different results when I compile the code with -O3 option and -O1 options of g++ compiler, this is my code:</p>
  
  <pre><code>int main(int argc, char *argv[])
  {
  
      int d = 120;
      __m256i r = _mm256_set1_epi32(d);
      int * p = (int *) &amp;r;
  
      printf("r[0]: %d, ",p[0]);
      printf("r[1]: %d, ",p[1]);
      printf("r[2]: %d, ",p[2]);
      printf("r[3]: %d, ",p[3]);
      printf("r[4]: %d, ",p[4]);
      printf("r[5]: %d, ",p[5]);
      printf("r[6]: %d, ",p[6]);
      printf("r[7]: %d \n",p[7]);                    
  
      return 0;
  }
  </code></pre>
  
  <p>This is the output when I compile with these options (g++ test1.c -o test1 -m64 -O3 -ffast-math -march=native -mavx):</p>
  
  <p>r[0]: 0, r[1]: 0, r[2]: 4195520, r[3]: 0, r[4]: -1880829792, r[5]: 32767, r[6]: 0, r[7]: 0</p>
  
  <p>And this is the output when I compile with these options (g++ test1.c -o test1 -m64 -O1 -ffast-math -march=native -mavx):</p>
  
  <p>r[0]: 120, r[1]: 120, r[2]: 120, r[3]: 120, r[4]: 120, r[5]: 120, r[6]: 120, r[7]: 120</p>
  
  <p>The second results (-O1) is correct, but the first is wrong. I don't know why this is happening.</p>