aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDorit Nuzman <dorit@il.ibm.com>2008-12-30 06:58:57 +0000
committerIra Rosen <irar@gcc.gnu.org>2008-12-30 06:58:57 +0000
commit7f5c5702cad70ae6ac0d90178d9a91096f97253d (patch)
tree400c8e032ea4bf174b1c2f04975882457f9b370d
parentb72bc5243fdc2830e2e4290526d43d210ff3178a (diff)
downloadgcc-7f5c5702cad70ae6ac0d90178d9a91096f97253d.zip
gcc-7f5c5702cad70ae6ac0d90178d9a91096f97253d.tar.gz
gcc-7f5c5702cad70ae6ac0d90178d9a91096f97253d.tar.bz2
re PR tree-optimization/38529 (ICE with nested loops)
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. Co-Authored-By: Ira Rosen <irar@il.ibm.com> From-SVN: r142959
-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 c55f3f8..603b68d 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 24f7364..4f010a2 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 0000000..496aa43
--- /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 18c22e7..2db0167 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)
{