Patchwork [PR,45241] : CPU2006 465.tonto ICE in the vectorizer with -fno-tree-pre

login
register
mail settings
Submitter Fang, Changpeng
Date Aug. 12, 2010, 5:12 p.m.
Message ID <D4C76825A6780047854A11E93CDE84D03F2850B4@SAUSEXMBP01.amd.com>
Download mbox | patch
Permalink /patch/61630/
State New
Headers show

Comments

Fang, Changpeng - Aug. 12, 2010, 5:12 p.m.
Hi, Ira:

Thanks for your reviews. Attached is the updated patch.
It passed bootstrapping  on x86_64-unknown-linux-gnu and
the gcc regression tests (fixed PR 45241).

Since bug 45241 is a [4.5/4.6] regression, is it ok to 
commit to 4.5 branch and 4.6 trunk?

Thanks,

Changpeng

Patch

From 075b88a514233e5c0ff877ddb27e756641b330d1 Mon Sep 17 00:00:00 2001
From: Changpeng Fang <chfang@houghton.(none)>
Date: Thu, 12 Aug 2010 10:08:54 -0700
Subject: [PATCH] pr45241 give up dot_prod pattern searching if stmt is outside the loop.

	* 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.
---
 gcc/testsuite/gcc.dg/vect/no-tree-pre-pr45241.c |   20 ++++++++++++++++++++
 gcc/tree-vect-patterns.c                        |    5 +++++
 2 files changed, 25 insertions(+), 0 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/vect/no-tree-pre-pr45241.c

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 0000000..7a4ad9d
--- /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 "-O3 -fno-tree-pre" } */
+
+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 19f0ae6..19df13f 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))
-- 
1.6.3.3