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
This commit is contained in:
Dorit Nuzman 2008-12-30 06:58:57 +00:00 committed by Ira Rosen
parent b72bc5243f
commit 7f5c5702ca
4 changed files with 71 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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" } } */

View File

@ -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)
{