summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryroux <yroux@138bc75d-0d04-0410-961f-82ee72b054a4>2014-04-07 13:31:40 +0000
committeryroux <yroux@138bc75d-0d04-0410-961f-82ee72b054a4>2014-04-07 13:31:40 +0000
commit20655f2f615cb56da9992b7f1b67bdab9abadaf1 (patch)
tree0cadaccd45e6139cede9887db55907a8f8f59f9d
parentb9f403cfe8ecb76e7819ec8e9ae1e653adaff339 (diff)
downloadgcc-20655f2f615cb56da9992b7f1b67bdab9abadaf1.tar.gz
2014-04-07 Michael Collison <michael.collison@linaro.org>
gcc/ Backport from trunk r202663 2013-09-17 Cong Hou <congh@google.com> * 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 <congh@google.com> * 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
-rw-r--r--gcc/ChangeLog.linaro9
-rw-r--r--gcc/testsuite/ChangeLog.linaro9
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-reduc-dot-s16c.c73
-rw-r--r--gcc/tree-vect-patterns.c2
4 files changed, 92 insertions, 1 deletions
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 <michael.collison@linaro.org>
+
+ Backport from trunk r202663
+ 2013-09-17 Cong Hou <congh@google.com>
+
+ * 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 <zhenqiang.chen@linaro.org>
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 <michael.collison@linaro.org>
+
+ Backport from trunk r202663
+ 2013-09-17 Cong Hou <congh@google.com>
+
+ * 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 <zhenqiang.chen@linaro.org>
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 <stdarg.h>
+#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<gimple> *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;