From 07b87b7fcb73a27a489c209747c61b79a088563a Mon Sep 17 00:00:00 2001 From: irar Date: Mon, 11 Oct 2010 12:18:47 +0000 Subject: [PATCH] PR tree-optimization/45902 * tree-vect-slp.c (vect_get_constant_vectors): Use statement's vector type for constants, unless it's a pointer. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165302 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/vect/pr45902.c | 43 +++++++++++++++++++++++++++++++++++++ gcc/tree-vect-slp.c | 15 +++++++++---- 4 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/vect/pr45902.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 594946d..fd0bc367 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2010-10-11 Ira Rosen + + PR tree-optimization/45902 + * tree-vect-slp.c (vect_get_constant_vectors): Use statement's + vector type for constants, unless it's a pointer. + 2010-10-11 Andreas Krebbel * config/s390/s390.md (*movcc): lgoc -> locg and stgoc -> stocg. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 46b7174..315e688 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-10-11 Ira Rosen + + PR tree-optimization/45902 + * gcc.dg/vect/45902.c: New test. + 2010-10-11 Jakub Jelinek PR target/45870 diff --git a/gcc/testsuite/gcc.dg/vect/pr45902.c b/gcc/testsuite/gcc.dg/vect/pr45902.c new file mode 100644 index 0000000..1690b3a --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr45902.c @@ -0,0 +1,43 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include +#include "tree-vect.h" + +#define N 128 + +short res[N]; +short a[N]; + +int +main1 () +{ + int i; + + for (i = 0; i < N/4; i+=4) + { + res[i] = a[i] >> 8; + res[i+1] = a[i+1] >> 8; + res[i+2] = a[i+2] >> 8; + res[i+3] = a[i+3] >> 8; + } +} + +int +main () +{ + int i; + + for (i = 0; i < N; i++) + a[i] = i; + + main1 (); + + for (i = 0; i < N; i++) + if (res[i] != a[i] >> 8) + abort (); + + return 0; +} + +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 2dbe328..784db84 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -1895,13 +1895,20 @@ vect_get_constant_vectors (slp_tree slp_node, VEC(tree,heap) **vec_oprnds, } if (CONSTANT_CLASS_P (op)) - constant_p = true; + { + constant_p = true; + if (POINTER_TYPE_P (TREE_TYPE (gimple_assign_lhs (stmt)))) + vector_type = get_vectype_for_scalar_type (TREE_TYPE (op)); + else + vector_type = STMT_VINFO_VECTYPE (stmt_vinfo); + } else - constant_p = false; + { + constant_p = false; + vector_type = get_vectype_for_scalar_type (TREE_TYPE (op)); + } - vector_type = get_vectype_for_scalar_type (TREE_TYPE (op)); gcc_assert (vector_type); - nunits = TYPE_VECTOR_SUBPARTS (vector_type); /* NUMBER_OF_COPIES is the number of times we need to use the same values in -- 2.7.4