re PR tree-optimization/71259 (GCC trunk emits wrong code)
authorJakub Jelinek <jakub@redhat.com>
Mon, 6 Jun 2016 18:35:03 +0000 (20:35 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 6 Jun 2016 18:35:03 +0000 (20:35 +0200)
PR tree-optimization/71259
* tree-vect-slp.c (vect_get_constant_vectors): For
VECTOR_BOOLEAN_TYPE_P, return all ones constant instead of
one for constant op, and use COND_EXPR for non-constant.

* gcc.dg/vect/pr71259.c: New test.

From-SVN: r237147

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/pr71259.c [new file with mode: 0644]
gcc/tree-vect-slp.c

index 68a7b78f4b658dd73774fe0ed531402f4c370730..ccabd6f6f42ef9c6335c7be7d2721f297fbab0c6 100644 (file)
@@ -1,3 +1,10 @@
+2016-06-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/71259
+       * tree-vect-slp.c (vect_get_constant_vectors): For
+       VECTOR_BOOLEAN_TYPE_P, return all ones constant instead of
+       one for constant op, and use COND_EXPR for non-constant.
+
 2016-06-06  David Malcolm  <dmalcolm@redhat.com>
 
        * Makefile.in (OBJS): Add function-tests.o,
index 15a771679439c31f8742924c56b6ad86ae695164..fa5d7009d16c2ebfe32334fa99d7259647fbd0f3 100644 (file)
@@ -1,3 +1,8 @@
+2016-06-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/71259
+       * gcc.dg/vect/pr71259.c: New test.
+
 2016-06-06  David Malcolm  <dmalcolm@redhat.com>
 
        * gcc.dg/plugin/levenshtein-test-1.c: Delete.
diff --git a/gcc/testsuite/gcc.dg/vect/pr71259.c b/gcc/testsuite/gcc.dg/vect/pr71259.c
new file mode 100644 (file)
index 0000000..eefa243
--- /dev/null
@@ -0,0 +1,28 @@
+/* PR tree-optimization/71259 */
+/* { dg-do run } */
+/* { dg-options "-O3" } */
+/* { dg-additional-options "-mavx" { target avx_runtime } } */
+
+#include "tree-vect.h"
+
+long a, b[1][44][2];
+long long c[44][17][2];
+
+int
+main ()
+{
+  int i, j, k;
+  check_vect ();
+  asm volatile ("" : : : "memory");
+  for (i = 0; i < 44; i++)
+    for (j = 0; j < 17; j++)
+      for (k = 0; k < 2; k++)
+       c[i][j][k] = (30995740 >= *(k + *(j + *b)) != (a != 8)) - 5105075050047261684;
+  asm volatile ("" : : : "memory");
+  for (i = 0; i < 44; i++) 
+    for (j = 0; j < 17; j++)
+      for (k = 0; k < 2; k++)
+       if (c[i][j][k] != -5105075050047261684)
+         __builtin_abort ();
+  return 0;
+}
index 3de53d1188c690cddc2a95ee4d0dde7628fde004..91120948114527af98620c13825ec00108fafd12 100644 (file)
@@ -3056,7 +3056,7 @@ vect_get_constant_vectors (tree op, slp_tree slp_node,
                      if (integer_zerop (op))
                        op = build_int_cst (TREE_TYPE (vector_type), 0);
                      else if (integer_onep (op))
-                       op = build_int_cst (TREE_TYPE (vector_type), 1);
+                       op = build_all_ones_cst (TREE_TYPE (vector_type));
                      else
                        gcc_unreachable ();
                    }
@@ -3071,8 +3071,14 @@ vect_get_constant_vectors (tree op, slp_tree slp_node,
                  gimple *init_stmt;
                  if (VECTOR_BOOLEAN_TYPE_P (vector_type))
                    {
+                     tree true_val
+                       = build_all_ones_cst (TREE_TYPE (vector_type));
+                     tree false_val
+                       = build_zero_cst (TREE_TYPE (vector_type));
                      gcc_assert (INTEGRAL_TYPE_P (TREE_TYPE (op)));
-                     init_stmt = gimple_build_assign (new_temp, NOP_EXPR, op);
+                     init_stmt = gimple_build_assign (new_temp, COND_EXPR,
+                                                      op, true_val,
+                                                      false_val);
                    }
                  else
                    {