[Bug tree-optimization/41019] Variate_generator with mt19937 and normal_distribution produces wrong sequence for "-O3".

irar at il dot ibm dot com gcc-bugzilla@gcc.gnu.org
Thu Aug 13 11:35:00 GMT 2009



------- Comment #10 from irar at il dot ibm dot com  2009-08-13 11:34 -------
Reduced testcase:

#include <stdlib.h>
#include <stdio.h>

#define N 4

long int a[N];
int main ()
{
  int k;

  for (k = 0; k < N; ++k)
    a[k] = a[k] != 5 ? 12 : 10;

  for (k = 0; k < N; ++k)
    printf ("%u ", a[k]);

  printf ("\n");

  return 0;
}

%gcc -O3 t.c
% ./a.out
0 0 0 0

%gcc -O2 t.c
% ./a.out
12 12 12 12

If the type of 'a' is int, there is no problem. The vectorizer produces almost
the same code in both cases (except for number of iterations and types).
I am attaching the assembly for int and long int versions.

Ira


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41019



More information about the Gcc-bugs mailing list