From 20655f2f615cb56da9992b7f1b67bdab9abadaf1 Mon Sep 17 00:00:00 2001 From: yroux Date: Mon, 7 Apr 2014 13:31:40 +0000 Subject: 2014-04-07 Michael Collison gcc/ Backport from trunk r202663 2013-09-17 Cong Hou * tree-vect-patterns.c (vect_recog_dot_prod_pattern): Fix a bug when checking the dot production pattern. The type of rhs operand of multiply is now checked correctly. testsuite/ Backport from trunk r202663 2013-09-17 Cong Hou * gcc.dg/vect/vect-reduc-dot-s16c.c: Add a test case with dot product on two arrays with short and int types. This should not be recognized as a dot product pattern. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/linaro/gcc-4_8-branch@209188 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog.linaro | 9 +++ gcc/testsuite/ChangeLog.linaro | 9 +++ gcc/testsuite/gcc.dg/vect/vect-reduc-dot-s16c.c | 73 +++++++++++++++++++++++++ gcc/tree-vect-patterns.c | 2 +- 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/vect/vect-reduc-dot-s16c.c diff --git a/gcc/ChangeLog.linaro b/gcc/ChangeLog.linaro index d6e53a5380e..d2e1d219ed7 100644 --- a/gcc/ChangeLog.linaro +++ b/gcc/ChangeLog.linaro @@ -1,3 +1,12 @@ +2014-04-07 Michael Collison + + Backport from trunk r202663 + 2013-09-17 Cong Hou + + * tree-vect-patterns.c (vect_recog_dot_prod_pattern): Fix a bug + when checking the dot production pattern. The type of rhs operand + of multiply is now checked correctly. + 2014-04-02 Zhenqiang Chen Backport from trunk r208511 diff --git a/gcc/testsuite/ChangeLog.linaro b/gcc/testsuite/ChangeLog.linaro index 6c0bc429c10..e82380c5954 100644 --- a/gcc/testsuite/ChangeLog.linaro +++ b/gcc/testsuite/ChangeLog.linaro @@ -1,3 +1,12 @@ +2014-04-07 Michael Collison + + Backport from trunk r202663 + 2013-09-17 Cong Hou + + * gcc.dg/vect/vect-reduc-dot-s16c.c: Add a test case with dot product + on two arrays with short and int types. This should not be recognized + as a dot product pattern. + 2014-04-02 Zhenqiang Chen Backport from trunk r208511 diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-s16c.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-s16c.c new file mode 100644 index 00000000000..8ba823b044c --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-s16c.c @@ -0,0 +1,73 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 64 +#define DOT 43680 + +signed short X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +signed int Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +/* (short, int)->int->int dot product. + Not detected as a dot-product pattern. */ + +__attribute__ ((noinline)) int +foo (int len) +{ + int i; + int result = 0; + + for (i = 0; i < len; i++) + { + result += (X[i] * Y[i]); + } + return result; +} + + +/* (int, short)->int->int dot product. + Not detected as a dot-product pattern. */ + +__attribute__ ((noinline)) int +bar (int len) +{ + int i; + int result = 0; + + for (i = 0; i < len; i++) + { + result += (Y[i] * X[i]); + } + return result; +} + +int +main (void) +{ + int i; + int dot; + + check_vect (); + + for (i = 0; i < N; i++) + { + X[i] = i; + Y[i] = N - i; + __asm__ volatile (""); + } + + dot = foo (N); + if (dot != DOT) + abort (); + + dot = bar (N); + if (dot != DOT) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target vect_unpack } } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ + diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c index 554e18661a1..c5331367012 100644 --- a/gcc/tree-vect-patterns.c +++ b/gcc/tree-vect-patterns.c @@ -395,7 +395,7 @@ vect_recog_dot_prod_pattern (vec *stmts, tree *type_in, || !promotion) return NULL; oprnd00 = gimple_assign_rhs1 (def_stmt); - if (!type_conversion_p (oprnd0, stmt, true, &half_type1, &def_stmt, + if (!type_conversion_p (oprnd1, stmt, true, &half_type1, &def_stmt, &promotion) || !promotion) return NULL; -- cgit v1.2.1