From: Ilya Enkovich Date: Fri, 18 Dec 2015 10:01:02 +0000 (+0000) Subject: re PR tree-optimization/68956 (Vectorizer miscompilation of 416.gamess) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b3d51f238b954ccab35dfcbebf5321bc91106a40;p=gcc.git re PR tree-optimization/68956 (Vectorizer miscompilation of 416.gamess) gcc/ PR tree-optimization/68956 * tree-vect-stmts.c (vect_init_vector): Fix constants used for boolean vectors. gcc/testsuite PR tree-optimization/68956 * gcc.target/i386/pr68956.c: New test. From-SVN: r231811 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 69e2d3c631b..32a94eb7c32 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-12-18 Ilya Enkovich + + PR tree-optimization/68956 + * tree-vect-stmts.c (vect_init_vector): Fix constants + used for boolean vectors. + 2015-12-18 Kyrylo Tkachov PR rtl-optimization/68796 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c902f9d740f..6120ed1b2f3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-12-18 Ilya Enkovich + + PR tree-optimization/68956 + * gcc.target/i386/pr68956.c: New test. + 2015-12-18 Kyrylo Tkachov PR rtl-optimization/68796 diff --git a/gcc/testsuite/gcc.target/i386/pr68956.c b/gcc/testsuite/gcc.target/i386/pr68956.c new file mode 100644 index 00000000000..4fb2ced9dac --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr68956.c @@ -0,0 +1,67 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -ffast-math -mfpmath=sse -mavx2 -ftree-vectorize" } */ +/* { dg-require-effective-target avx2 } */ + +#include "avx2-check.h" + +extern void abort (void); + +int l; + +static void __attribute__((noclone,noinline)) +test1 (double *in1, double *in2, double *out, + int l1, int l2, int *n) +{ + double sum; + int na = n[0]; + int nb = n[1]; + int i; + _Bool ic, jc; + + jc = (l > na) && (l > nb); + for (int i = 0; i < l2; i++) + { + ic = (i <= na) && (i <= nb); + sum = 0; + if (ic && jc) + sum = in1[i] + in2[i]; + out[i] = sum; + } +} + +static void +avx2_test (void) +{ + double in1[40], in2[40], out[40], sum; + int n[2],l1,l2,i,na,nb; + _Bool ic, jc; + + l = 0; + l1 = 8; + l2 = 40; + n[0] = 14; + n[1] = 13; + + for (i = 0; i < l2; i++) + { + in1[i] = i; + in2[i] = i; + out[i] = 0; + } + + test1 (in1, in2, out, l1, l2, n); + + na = n[0]; + nb = n[1]; + + jc = (l > na) && (l > nb); + for (int i = 0; i < l2; i++) + { + ic = (i <= na) && (i <= nb); + sum = 0; + if (ic && jc) + sum = in1[i] + in2[i]; + if (out[i] != sum) + abort (); + } +} diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index b1342fb477a..7c6fa73ff48 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -1304,8 +1304,8 @@ vect_init_vector (gimple *stmt, tree val, tree type, gimple_stmt_iterator *gsi) all zeros or all ones value before building a vector. */ if (VECTOR_BOOLEAN_TYPE_P (type)) { - tree true_val = build_zero_cst (TREE_TYPE (type)); - tree false_val = build_all_ones_cst (TREE_TYPE (type)); + tree true_val = build_all_ones_cst (TREE_TYPE (type)); + tree false_val = build_zero_cst (TREE_TYPE (type)); if (CONSTANT_CLASS_P (val)) val = integer_zerop (val) ? false_val : true_val;