From 158beb4ab3f6adace5f3c328cba3470eb1cc6357 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 6 Jun 2016 20:35:03 +0200 Subject: [PATCH] re PR tree-optimization/71259 (GCC trunk emits wrong code) 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 | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/vect/pr71259.c | 28 ++++++++++++++++++++++++++++ gcc/tree-vect-slp.c | 10 ++++++++-- 4 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/vect/pr71259.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 68a7b78f4b6..ccabd6f6f42 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2016-06-06 Jakub Jelinek + + 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 * Makefile.in (OBJS): Add function-tests.o, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 15a77167943..fa5d7009d16 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-06-06 Jakub Jelinek + + PR tree-optimization/71259 + * gcc.dg/vect/pr71259.c: New test. + 2016-06-06 David Malcolm * 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 index 00000000000..eefa2433225 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr71259.c @@ -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; +} diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 3de53d1188c..91120948114 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -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 { -- 2.30.2