re PR tree-optimization/46785 (Doesn't vectorize reduction x += y*y)

2010-12-06  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/46785
	* tree-vect-loop.c (vect_is_simple_reduction_1): Also allow
	call statements as operand definition.

	* gcc.dg/vect/fast-math-vect-reduc-9.c: New testcase.

From-SVN: r167486
This commit is contained in:
Richard Guenther 2010-12-06 10:05:07 +00:00 committed by Richard Biener
parent 64ad7c99ae
commit 4fc7469aba
4 changed files with 43 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2010-12-06 Richard Guenther <rguenther@suse.de>
PR tree-optimization/46785
* tree-vect-loop.c (vect_is_simple_reduction_1): Also allow
call statements as operand definition.
2010-12-06 Mingjie Xing <mingjie.xing@gmail.com>
* doc/tm.texi.in: Fix typo.

View File

@ -1,3 +1,8 @@
2010-12-06 Richard Guenther <rguenther@suse.de>
PR tree-optimization/46785
* gcc.dg/vect/fast-math-vect-reduc-9.c: New testcase.
2010-12-06 Dave Korn <dave.korn.cygwin@gmail.com>
* gcc.dg/pr46674.c (LABEL3): New macro definition.

View File

@ -0,0 +1,30 @@
/* { dg-require-effective-target vect_float } */
#include "tree-vect.h"
float x[1024];
float
test (void)
{
int i;
float gosa = 0.0;
for (i = 0; i < 1024; ++i)
{
float tem = x[i];
gosa += tem * tem;
}
return gosa;
}
int main (void)
{
check_vect ();
if (test () != 0.0)
abort ();
return 0;
}
/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */
/* { dg-final { cleanup-tree-dump "vect" } } */

View File

@ -1970,6 +1970,7 @@ vect_is_simple_reduction_1 (loop_vec_info loop_info, gimple phi,
&& (code == COND_EXPR
|| (def1 && flow_bb_inside_loop_p (loop, gimple_bb (def1))
&& (is_gimple_assign (def1)
|| is_gimple_call (def1)
|| STMT_VINFO_DEF_TYPE (vinfo_for_stmt (def1))
== vect_induction_def
|| (gimple_code (def1) == GIMPLE_PHI
@ -1985,6 +1986,7 @@ vect_is_simple_reduction_1 (loop_vec_info loop_info, gimple phi,
&& (code == COND_EXPR
|| (def2 && flow_bb_inside_loop_p (loop, gimple_bb (def2))
&& (is_gimple_assign (def2)
|| is_gimple_call (def2)
|| STMT_VINFO_DEF_TYPE (vinfo_for_stmt (def2))
== vect_induction_def
|| (gimple_code (def2) == GIMPLE_PHI