re PR tree-optimization/50328 (reduction with constant or invariant not vectorized)

2011-09-09  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/50328
	* tree-vect-loop.c (vect_is_simple_reduction_1): Allow one
	constant or default-def operand.

	* gcc.dg/vect/fast-math-vect-outer-7.c: New testcase.

From-SVN: r178728
This commit is contained in:
Richard Guenther 2011-09-09 12:35:11 +00:00 committed by Richard Biener
parent 0aa1658649
commit 107defbe86
4 changed files with 38 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2011-09-09 Richard Guenther <rguenther@suse.de>
PR tree-optimization/50328
* tree-vect-loop.c (vect_is_simple_reduction_1): Allow one
constant or default-def operand.
2011-09-09 Richard Guenther <rguenther@suse.de>
* tree-ssa-pre.c (create_expression_by_pieces): Fold the

View File

@ -1,3 +1,8 @@
2011-09-09 Richard Guenther <rguenther@suse.de>
PR tree-optimization/50328
* gcc.dg/vect/fast-math-vect-outer-7.c: New testcase.
2011-09-09 Richard Guenther <rguenther@suse.de>
PR middle-end/50333

View File

@ -0,0 +1,23 @@
/* { dg-do compile } */
/* { dg-require-effective-target vect_float } */
float dvec[256];
void test1 (float x)
{
long i, j;
for (i = 0; i < 256; ++i)
for (j = 0; j < 131072; ++j)
dvec[i] *= x;
}
void test2 (float x)
{
long i, j;
for (i = 0; i < 256; ++i)
for (j = 0; j < 131072; ++j)
dvec[i] *= 1.001f;
}
/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 2 "vect" } } */
/* { dg-final { cleanup-tree-dump "vect" } } */

View File

@ -2149,7 +2149,7 @@ vect_is_simple_reduction_1 (loop_vec_info loop_info, gimple phi,
op1 = gimple_assign_rhs1 (def_stmt);
op2 = gimple_assign_rhs2 (def_stmt);
if (TREE_CODE (op1) != SSA_NAME || TREE_CODE (op2) != SSA_NAME)
if (TREE_CODE (op1) != SSA_NAME && TREE_CODE (op2) != SSA_NAME)
{
if (vect_print_dump_info (REPORT_DETAILS))
report_vect_op (def_stmt, "reduction: uses not ssa_names: ");
@ -2255,7 +2255,7 @@ vect_is_simple_reduction_1 (loop_vec_info loop_info, gimple phi,
def2 = SSA_NAME_DEF_STMT (op2);
if (code != COND_EXPR
&& (!def1 || !def2 || gimple_nop_p (def1) || gimple_nop_p (def2)))
&& ((!def1 || gimple_nop_p (def1)) && (!def2 || gimple_nop_p (def2))))
{
if (vect_print_dump_info (REPORT_DETAILS))
report_vect_op (def_stmt, "reduction: no defs for operands: ");
@ -2268,6 +2268,7 @@ vect_is_simple_reduction_1 (loop_vec_info loop_info, gimple phi,
if (def2 && def2 == phi
&& (code == COND_EXPR
|| !def1 || gimple_nop_p (def1)
|| (def1 && flow_bb_inside_loop_p (loop, gimple_bb (def1))
&& (is_gimple_assign (def1)
|| is_gimple_call (def1)
@ -2285,6 +2286,7 @@ vect_is_simple_reduction_1 (loop_vec_info loop_info, gimple phi,
if (def1 && def1 == phi
&& (code == COND_EXPR
|| !def2 || gimple_nop_p (def2)
|| (def2 && flow_bb_inside_loop_p (loop, gimple_bb (def2))
&& (is_gimple_assign (def2)
|| is_gimple_call (def2)