tree-vect-patterns.c (vect_recog_dot_prod_pattern): Fix a bug when checking the dot production pattern.

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.

    * 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.

From-SVN: r202663
This commit is contained in:
Cong Hou 2013-09-17 14:20:08 -04:00 committed by Cong Hou
parent 783f0cfc8d
commit 181f5f3e37
4 changed files with 86 additions and 1 deletions

View File

@ -1,3 +1,9 @@
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.
2013-09-17 Jeff Law <law@redhat.com>
* tree-ssa-dom.c (cprop_into_successor_phis): Also propagate

View File

@ -1,3 +1,9 @@
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.
2013-09-17 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/58435

View File

@ -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" } } */

View File

@ -397,7 +397,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;