summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirar <irar@138bc75d-0d04-0410-961f-82ee72b054a4>2008-12-30 06:58:57 +0000
committerirar <irar@138bc75d-0d04-0410-961f-82ee72b054a4>2008-12-30 06:58:57 +0000
commitd136c3636e7611ed95e958a866bfdf885a8a16bf (patch)
tree400c8e032ea4bf174b1c2f04975882457f9b370d
parent0a9bd6a3da757baa8b1e044d18eccd9b802baef9 (diff)
downloadgcc-d136c3636e7611ed95e958a866bfdf885a8a16bf.tar.gz
PR tree-optimization/38529
* tree-vect-transform (vect_transform_stmt): Handle inner-loop stmts whose DEF is used in the loop-nest that is being vectorized, but outside the immediately enclosing loop. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@142959 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr38529.c18
-rw-r--r--gcc/tree-vect-transform.c39
4 files changed, 71 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c55f3f8febb..603b68d0b4d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2008-12-30 Dorit Nuzman <dorit@il.ibm.com>
+ Ira Rosen <irar@il.ibm.com>
+
+ PR tree-optimization/38529
+ * tree-vect-transform (vect_transform_stmt): Handle inner-loop stmts
+ whose DEF is used in the loop-nest that is being vectorized, but
+ outside the immediately enclosing loop.
+
2008-12-29 Seongbae Park <seongbae.park@gmail.com>
* tree-profile.c (tree_init_ic_make_global_vars): Make static
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 24f7364d9c8..4f010a2782d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2008-12-29 Dorit Nuzman <dorit@il.ibm.com>
+ Ira Rosen <irar@il.ibm.com>
+
+ PR tree-optimization/38529
+ * gcc.dg/vect/pr38529.c: New test.
+
2008-12-29 Jakub Jelinek <jakub@redhat.com>
PR c++/38635
diff --git a/gcc/testsuite/gcc.dg/vect/pr38529.c b/gcc/testsuite/gcc.dg/vect/pr38529.c
new file mode 100644
index 00000000000..496aa43f39b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr38529.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_float } */
+
+float a[4];
+
+void foo()
+{
+ int i, j;
+
+ for (i = 0; i < 4; ++i)
+ for (j = 0; j < 17; ++j)
+ a[i] = 0;
+}
+
+/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
+
+
diff --git a/gcc/tree-vect-transform.c b/gcc/tree-vect-transform.c
index 18c22e7eac7..2db01676bdb 100644
--- a/gcc/tree-vect-transform.c
+++ b/gcc/tree-vect-transform.c
@@ -7047,6 +7047,8 @@ vect_transform_stmt (gimple stmt, gimple_stmt_iterator *gsi,
stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
gimple orig_stmt_in_pattern;
bool done;
+ loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info);
+ struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
switch (STMT_VINFO_TYPE (stmt_info))
{
@@ -7130,6 +7132,43 @@ vect_transform_stmt (gimple stmt, gimple_stmt_iterator *gsi,
}
}
+ /* Handle inner-loop stmts whose DEF is used in the loop-nest that
+ is being vectorized, but outside the immediately enclosing loop. */
+ if (vec_stmt
+ && nested_in_vect_loop_p (loop, stmt)
+ && STMT_VINFO_TYPE (stmt_info) != reduc_vec_info_type
+ && (STMT_VINFO_RELEVANT (stmt_info) == vect_used_in_outer
+ || STMT_VINFO_RELEVANT (stmt_info) == vect_used_in_outer_by_reduction))
+ {
+ struct loop *innerloop = loop->inner;
+ imm_use_iterator imm_iter;
+ use_operand_p use_p;
+ tree scalar_dest;
+ gimple exit_phi;
+
+ if (vect_print_dump_info (REPORT_DETAILS))
+ fprintf (vect_dump, "Record the vdef for outer-loop vectorization.");
+
+ /* Find the relevant loop-exit phi-node, and reord the vec_stmt there
+ (to be used when vectorizing outer-loop stmts that use the DEF of
+ STMT). */
+ if (gimple_code (stmt) == GIMPLE_PHI)
+ scalar_dest = PHI_RESULT (stmt);
+ else
+ scalar_dest = gimple_assign_lhs (stmt);
+
+ FOR_EACH_IMM_USE_FAST (use_p, imm_iter, scalar_dest)
+ {
+ if (!flow_bb_inside_loop_p (innerloop, gimple_bb (USE_STMT (use_p))))
+ {
+ exit_phi = USE_STMT (use_p);
+ STMT_VINFO_VEC_STMT (vinfo_for_stmt (exit_phi)) = vec_stmt;
+ }
+ }
+ }
+
+ /* Handle stmts whose DEF is used outside the loop-nest that is
+ being vectorized. */
if (STMT_VINFO_LIVE_P (stmt_info)
&& STMT_VINFO_TYPE (stmt_info) != reduc_vec_info_type)
{