pr45241 give up dot_prod pattern searching if stmt is outside the loop.
authorChangpeng Fang <changpeng.fang@amd.com>
Thu, 12 Aug 2010 22:18:32 +0000 (22:18 +0000)
committerChangpeng Fang <cfang@gcc.gnu.org>
Thu, 12 Aug 2010 22:18:32 +0000 (22:18 +0000)
* tree-vect-patterns.c (vect_recog_dot_prod_pattern): Give
up dot_prod pattern searching if a stmt is outside the loop.

* gcc.dg/vect/no-tree-pre-pr45241.c: New.

From-SVN: r163207

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/no-tree-pre-pr45241.c [new file with mode: 0644]
gcc/tree-vect-patterns.c

index 39b2e75..e5d92f0 100644 (file)
@@ -1,3 +1,8 @@
+2010-08-12  Changpeng Fang  <changpeng.fang@amd.com>
+
+       * 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  <hongjiu.lu@intel.com>
            Uros Bizjak  <ubizjak@gmail.com>
 
index 0f2a7cc..e0a2b96 100644 (file)
@@ -1,3 +1,8 @@
+2010-08-12  Changpeng Fang  <changpeng.fang@amd.com>
+
+       PR tree-optimization/45241
+       * gcc.dg/vect/no-tree-pre-pr45241.c: New test.
+
 2010-08-12  Uros Bizjak  <ubizjak@gmail.com>
 
        * 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 (file)
index 0000000..289a930
--- /dev/null
@@ -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" } } */
index 19f0ae6..19df13f 100644 (file)
@@ -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))