[Bug tree-optimization/41019] Variate_generator with mt19937 and normal_distribution produces wrong sequence for "-O3".
--- Comment #12 from irar at il dot ibm dot com 2009-08-13 11:37 --- Created an attachment (id=18351) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18351&action=view) The assembly for the int version (correct) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41019
[Bug tree-optimization/41019] Variate_generator with mt19937 and normal_distribution produces wrong sequence for "-O3".
--- Comment #11 from irar at il dot ibm dot com 2009-08-13 11:36 --- Created an attachment (id=18350) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18350&action=view) The assembly for the long int version (wrong code) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41019
[Bug tree-optimization/41019] Variate_generator with mt19937 and normal_distribution produces wrong sequence for "-O3".
--- Comment #10 from irar at il dot ibm dot com 2009-08-13 11:34 --- Reduced testcase: #include #include #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
[Bug tree-optimization/41019] Variate_generator with mt19937 and normal_distribution produces wrong sequence for "-O3".
--- Comment #9 from rguenth at gcc dot gnu dot org 2009-08-13 08:56 --- >From a look at the sources it seems that _M_x is at offset zero. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41019
[Bug tree-optimization/41019] Variate_generator with mt19937 and normal_distribution produces wrong sequence for "-O3".
--- Comment #8 from irar at il dot ibm dot com 2009-08-13 05:40 --- (In reply to comment #7) > Oh. Did you manage to reduce or reproduce with a smaller testcase? No, I just looked at the vectorized loops. The guilty one is bin/../lib/gcc/x86_64-unknown-linux-gnu/4.5.0/../../../../include/c++/4.5.0/tr1/random.tcc:231 Ira -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41019
[Bug tree-optimization/41019] Variate_generator with mt19937 and normal_distribution produces wrong sequence for "-O3".
--- Comment #7 from rguenther at suse dot de 2009-08-12 12:37 --- Subject: Re: Variate_generator with mt19937 and normal_distribution produces wrong sequence for "-O3". On Wed, 12 Aug 2009, irar at il dot ibm dot com wrote: > --- Comment #6 from irar at il dot ibm dot com 2009-08-12 12:14 --- > Looks like a problem in data-ref analysis: > > Creating dr for this_6(D)->_M_x[__k_87] > ... > base_address: this_6(D) > offset from base address: 0 > constant offset from base address: 0 > step: 8 > aligned to: 128 > base_object: this_6(D)->_M_x[0] > > And the vectorizer creates accesses relatively to this_6(D) (base_address > above) with zero offset (instead of this_6(D)->_M_x[0] or with an offset of > _M_x). Oh. Did you manage to reduce or reproduce with a smaller testcase? Thanks, Richard. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41019
[Bug tree-optimization/41019] Variate_generator with mt19937 and normal_distribution produces wrong sequence for "-O3".
--- Comment #6 from irar at il dot ibm dot com 2009-08-12 12:14 --- Looks like a problem in data-ref analysis: Creating dr for this_6(D)->_M_x[__k_87] ... base_address: this_6(D) offset from base address: 0 constant offset from base address: 0 step: 8 aligned to: 128 base_object: this_6(D)->_M_x[0] And the vectorizer creates accesses relatively to this_6(D) (base_address above) with zero offset (instead of this_6(D)->_M_x[0] or with an offset of _M_x). Ira -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41019
[Bug tree-optimization/41019] Variate_generator with mt19937 and normal_distribution produces wrong sequence for "-O3".
--- Comment #5 from afoglia at gmail dot com 2009-08-11 20:17 --- (In reply to comment #4) > Disabling vectorization fixes the problem (-fno-tree-vectorize), happens on > trunk as well. 4.3 doesn't like the testcase, so it's not yet a regression. > 4.3 may not like the test case, but if you use Boost's variate_generator with 4.3, which can hold references to engines, you get the same results, implying it's the use the mt19937 engine via reference that causes the problem. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41019
[Bug tree-optimization/41019] Variate_generator with mt19937 and normal_distribution produces wrong sequence for "-O3".
--- Comment #4 from rguenth at gcc dot gnu dot org 2009-08-11 15:24 --- Disabling vectorization fixes the problem (-fno-tree-vectorize), happens on trunk as well. 4.3 doesn't like the testcase, so it's not yet a regression. -- rguenth at gcc dot gnu dot org changed: What|Removed |Added CC||irar at il dot ibm dot com, ||rguenth at gcc dot gnu dot ||org Status|UNCONFIRMED |NEW Component|c++ |tree-optimization Ever Confirmed|0 |1 GCC host triplet|x86_64-unknown-linux-gnu| |Core2 Q9550 | GCC target triplet||x86-*-* Keywords||wrong-code Known to fail||4.4.1 4.5.0 Last reconfirmed|-00-00 00:00:00 |2009-08-11 15:24:24 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41019