diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 39b2e75ca82..e5d92f01ec7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2010-08-12 Changpeng Fang + + * tree-vect-patterns.c (vect_recog_dot_prod_pattern): Give + up dot_prod pattern searching if a stmt is outside the loop. + 2010-08-12 H.J. Lu Uros Bizjak diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0f2a7cc0ef3..e0a2b96e6dc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-08-12 Changpeng Fang + + PR tree-optimization/45241 + * gcc.dg/vect/no-tree-pre-pr45241.c: New test. + 2010-08-12 Uros Bizjak * gcc.target/i386/pr40906-1.c: Add -fno-asynchronous-unwind-tables diff --git a/gcc/testsuite/gcc.dg/vect/no-tree-pre-pr45241.c b/gcc/testsuite/gcc.dg/vect/no-tree-pre-pr45241.c new file mode 100644 index 00000000000..289a930cd7b --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/no-tree-pre-pr45241.c @@ -0,0 +1,20 @@ +/* PR tree-optimization/45241 */ +/* { dg-do compile } */ +/* { dg-options "-ftree-vectorize" } */ + +int +foo (short x) +{ + short i, y; + int sum; + + for (i = 0; i < x; i++) + y = x * i; + + for (i = x; i > 0; i--) + sum += y; + + return sum; +} + +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c index 19f0ae67a88..19df13f63a4 100644 --- a/gcc/tree-vect-patterns.c +++ b/gcc/tree-vect-patterns.c @@ -255,6 +255,11 @@ vect_recog_dot_prod_pattern (gimple last_stmt, tree *type_in, tree *type_out) prod_type = half_type; stmt = SSA_NAME_DEF_STMT (oprnd0); + + /* It could not be the dot_prod pattern if the stmt is outside the loop. */ + if (!flow_bb_inside_loop_p (loop, gimple_bb (stmt))) + return NULL; + /* FORNOW. Can continue analyzing the def-use chain when this stmt in a phi inside the loop (in case we are analyzing an outer-loop). */ if (!is_gimple_assign (stmt))