Commit f5709183 by Ira Rosen Committed by Ulrich Weigand

tree-vectorizer.h (vect_pattern_recog): Add new argument.

ChangeLog:

	* tree-vectorizer.h (vect_pattern_recog): Add new argument.
	* tree-vect-loop.c (vect_analyze_loop_2): Update call to
	vect_pattern_recog.
	* tree-vect-patterns.c (widened_name_p): Pass basic block
	info to vect_is_simple_use.
	(vect_recog_dot_prod_pattern): Fail for basic blocks.
	(vect_recog_widen_sum_pattern): Likewise.
	(vect_handle_widen_op_by_const): Support basic blocks.
	(vect_operation_fits_smaller_type,
	vect_recog_over_widening_pattern): Likewise.
	(vect_recog_vector_vector_shift_pattern): Support basic blocks.
	Update call to vect_is_simple_use.
	(vect_recog_mixed_size_cond_pattern): Support basic blocks.
	Add printing.
	(check_bool_pattern): Add an argument, update call to
	vect_is_simple_use and the recursive calls.
	(vect_recog_bool_pattern): Update relevant function calls.
	Add printing.
	(vect_mark_pattern_stmts): Update calls to new_stmt_vec_info.
	(vect_pattern_recog_1): Check for reduction only in loops.
	(vect_pattern_recog): Add new argument.  Support basic blocks.
	* tree-vect-stmts.c (vectorizable_conversion): Pass basic block
	info to vect_is_simple_use_1.
	* tree-vect-slp.c (vect_get_and_check_slp_defs): Support basic
	blocks.
	(vect_slp_analyze_bb_1): Call vect_pattern_recog.

testsuite/ChangeLog:

	* gcc.dg/vect/bb-slp-pattern-1.c: New test.
	* gcc.dg/vect/bb-slp-pattern-2.c: New test.

Co-Authored-By: Ulrich Weigand <ulrich.weigand@linaro.org>

From-SVN: r185436
parent 37b659dd
2012-03-15 Ira Rosen <irar@il.ibm.com>
Ulrich Weigand <ulrich.weigand@linaro.org>
* tree-vectorizer.h (vect_pattern_recog): Add new argument.
* tree-vect-loop.c (vect_analyze_loop_2): Update call to
vect_pattern_recog.
* tree-vect-patterns.c (widened_name_p): Pass basic block
info to vect_is_simple_use.
(vect_recog_dot_prod_pattern): Fail for basic blocks.
(vect_recog_widen_sum_pattern): Likewise.
(vect_handle_widen_op_by_const): Support basic blocks.
(vect_operation_fits_smaller_type,
vect_recog_over_widening_pattern): Likewise.
(vect_recog_vector_vector_shift_pattern): Support basic blocks.
Update call to vect_is_simple_use.
(vect_recog_mixed_size_cond_pattern): Support basic blocks.
Add printing.
(check_bool_pattern): Add an argument, update call to
vect_is_simple_use and the recursive calls.
(vect_recog_bool_pattern): Update relevant function calls.
Add printing.
(vect_mark_pattern_stmts): Update calls to new_stmt_vec_info.
(vect_pattern_recog_1): Check for reduction only in loops.
(vect_pattern_recog): Add new argument. Support basic blocks.
* tree-vect-stmts.c (vectorizable_conversion): Pass basic block
info to vect_is_simple_use_1.
* tree-vect-slp.c (vect_get_and_check_slp_defs): Support basic
blocks.
(vect_slp_analyze_bb_1): Call vect_pattern_recog.
2012-03-15 Jakub Jelinek <jakub@redhat.com> 2012-03-15 Jakub Jelinek <jakub@redhat.com>
Andrew Pinski <apinski@cavium.com> Andrew Pinski <apinski@cavium.com>
......
2012-03-15 Ira Rosen <irar@il.ibm.com>
Ulrich Weigand <ulrich.weigand@linaro.org>
* gcc.dg/vect/bb-slp-pattern-1.c: New test.
* gcc.dg/vect/bb-slp-pattern-2.c: New test.
2012-03-15 Janne Blomqvist <jb@gcc.gnu.org> 2012-03-15 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/52434 PR libfortran/52434
......
/* { dg-require-effective-target vect_int } */
#include <stdarg.h>
#include "tree-vect.h"
#define N 8
unsigned short X[N];
unsigned short Y[N];
unsigned int result[N];
/* unsigned short->unsigned int widening-mult. */
__attribute__ ((noinline, noclone)) void
foo (void)
{
result[0] = (unsigned int) (X[0] * Y[0]);
result[1] = (unsigned int) (X[1] * Y[1]);
result[2] = (unsigned int) (X[2] * Y[2]);
result[3] = (unsigned int) (X[3] * Y[3]);
result[4] = (unsigned int) (X[4] * Y[4]);
result[5] = (unsigned int) (X[5] * Y[5]);
result[6] = (unsigned int) (X[6] * Y[6]);
result[7] = (unsigned int) (X[7] * Y[7]);
}
int main (void)
{
int i, tmp;
check_vect ();
for (i = 0; i < N; i++)
{
X[i] = i;
Y[i] = 64-i;
}
foo ();
for (i = 0; i < N; i++)
{
__asm__ volatile ("");
tmp = X[i] * Y[i];
if (result[i] != tmp)
abort ();
}
return 0;
}
/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "slp" { target { vect_widen_mult_hi_to_si || vect_unpack } } } } */
/* { dg-final { scan-tree-dump-times "vect_recog_widen_mult_pattern: detected" 8 "slp" { target vect_widen_mult_hi_to_si_pattern } } } */
/* { dg-final { scan-tree-dump-times "pattern recognized" 8 "slp" { target vect_widen_mult_hi_to_si_pattern } } } */
/* { dg-final { cleanup-tree-dump "slp" } } */
/* { dg-require-effective-target vect_condition } */
#include "tree-vect.h"
#define N 128
__attribute__((noinline, noclone)) void
foo (short * __restrict__ a, int * __restrict__ b, int stride)
{
int i;
for (i = 0; i < N/stride; i++, a += stride, b += stride)
{
a[0] = b[0] ? 1 : 7;
a[1] = b[1] ? 2 : 0;
a[2] = b[2] ? 3 : 0;
a[3] = b[3] ? 4 : 0;
a[4] = b[4] ? 5 : 0;
a[5] = b[5] ? 6 : 0;
a[6] = b[6] ? 7 : 0;
a[7] = b[7] ? 8 : 0;
}
}
short a[N];
int b[N];
int main ()
{
int i;
check_vect ();
for (i = 0; i < N; i++)
{
a[i] = i;
b[i] = -i;
}
foo (a, b, 8);
for (i = 1; i < N; i++)
if (a[i] != i%8 + 1)
abort ();
if (a[0] != 7)
abort ();
return 0;
}
/* { dg-final { scan-tree-dump-times "basic block vectorized using SLP" 1 "slp" { target { vect_element_align && vect_pack_trunc } } } } */
/* { dg-final { cleanup-tree-dump "slp" } } */
...@@ -1514,7 +1514,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo) ...@@ -1514,7 +1514,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
vect_analyze_scalar_cycles (loop_vinfo); vect_analyze_scalar_cycles (loop_vinfo);
vect_pattern_recog (loop_vinfo); vect_pattern_recog (loop_vinfo, NULL);
/* Data-flow analysis to detect stmts that do not need to be vectorized. */ /* Data-flow analysis to detect stmts that do not need to be vectorized. */
......
...@@ -249,12 +249,14 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo, ...@@ -249,12 +249,14 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo,
/* Check if DEF_STMT is a part of a pattern in LOOP and get the def stmt /* Check if DEF_STMT is a part of a pattern in LOOP and get the def stmt
from the pattern. Check that all the stmts of the node are in the from the pattern. Check that all the stmts of the node are in the
pattern. */ pattern. */
if (loop && def_stmt && gimple_bb (def_stmt) if (def_stmt && gimple_bb (def_stmt)
&& flow_bb_inside_loop_p (loop, gimple_bb (def_stmt)) && ((loop && flow_bb_inside_loop_p (loop, gimple_bb (def_stmt)))
|| (!loop && gimple_bb (def_stmt) == BB_VINFO_BB (bb_vinfo)
&& gimple_code (def_stmt) != GIMPLE_PHI))
&& vinfo_for_stmt (def_stmt) && vinfo_for_stmt (def_stmt)
&& STMT_VINFO_IN_PATTERN_P (vinfo_for_stmt (def_stmt)) && STMT_VINFO_IN_PATTERN_P (vinfo_for_stmt (def_stmt))
&& !STMT_VINFO_RELEVANT (vinfo_for_stmt (def_stmt)) && !STMT_VINFO_RELEVANT (vinfo_for_stmt (def_stmt))
&& !STMT_VINFO_LIVE_P (vinfo_for_stmt (def_stmt))) && !STMT_VINFO_LIVE_P (vinfo_for_stmt (def_stmt)))
{ {
pattern = true; pattern = true;
if (!first && !oprnd_info->first_pattern) if (!first && !oprnd_info->first_pattern)
...@@ -2015,7 +2017,9 @@ vect_slp_analyze_bb_1 (basic_block bb) ...@@ -2015,7 +2017,9 @@ vect_slp_analyze_bb_1 (basic_block bb)
return NULL; return NULL;
} }
if (!vect_analyze_data_ref_dependences (NULL, bb_vinfo, &max_vf) vect_pattern_recog (NULL, bb_vinfo);
if (!vect_analyze_data_ref_dependences (NULL, bb_vinfo, &max_vf)
|| min_vf > max_vf) || min_vf > max_vf)
{ {
if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS)) if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
......
...@@ -2271,10 +2271,10 @@ vectorizable_conversion (gimple stmt, gimple_stmt_iterator *gsi, ...@@ -2271,10 +2271,10 @@ vectorizable_conversion (gimple stmt, gimple_stmt_iterator *gsi,
/* For WIDEN_MULT_EXPR, if OP0 is a constant, use the type of /* For WIDEN_MULT_EXPR, if OP0 is a constant, use the type of
OP1. */ OP1. */
if (CONSTANT_CLASS_P (op0)) if (CONSTANT_CLASS_P (op0))
ok = vect_is_simple_use_1 (op1, stmt, loop_vinfo, NULL, ok = vect_is_simple_use_1 (op1, stmt, loop_vinfo, bb_vinfo,
&def_stmt, &def, &dt[1], &vectype_in); &def_stmt, &def, &dt[1], &vectype_in);
else else
ok = vect_is_simple_use (op1, stmt, loop_vinfo, NULL, &def_stmt, ok = vect_is_simple_use (op1, stmt, loop_vinfo, bb_vinfo, &def_stmt,
&def, &dt[1]); &def, &dt[1]);
if (!ok) if (!ok)
......
...@@ -933,7 +933,7 @@ extern void vect_slp_transform_bb (basic_block); ...@@ -933,7 +933,7 @@ extern void vect_slp_transform_bb (basic_block);
in the future. */ in the future. */
typedef gimple (* vect_recog_func_ptr) (VEC (gimple, heap) **, tree *, tree *); typedef gimple (* vect_recog_func_ptr) (VEC (gimple, heap) **, tree *, tree *);
#define NUM_PATTERNS 10 #define NUM_PATTERNS 10
void vect_pattern_recog (loop_vec_info); void vect_pattern_recog (loop_vec_info, bb_vec_info);
/* In tree-vectorizer.c. */ /* In tree-vectorizer.c. */
unsigned vectorize_loops (void); unsigned vectorize_loops (void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment