re PR tree-optimization/59288 (ICE in get_initial_def_for_induction)

2013-11-27  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/59288
	* tree-vect-loop.c (get_initial_def_for_induction): Do not
	re-analyze the PHI but use STMT_VINFO_LOOP_PHI_EVOLUTION_PART.

	* gcc.dg/torture/pr59288.c: New testcase.

From-SVN: r205434
This commit is contained in:
Richard Biener 2013-11-27 08:50:15 +00:00 committed by Richard Biener
parent 14a981b922
commit 43ad66aa4a
4 changed files with 36 additions and 11 deletions

View File

@ -1,3 +1,9 @@
2013-11-27 Richard Biener <rguenther@suse.de>
PR tree-optimization/59288
* tree-vect-loop.c (get_initial_def_for_induction): Do not
re-analyze the PHI but use STMT_VINFO_LOOP_PHI_EVOLUTION_PART.
2013-11-27 Marek Polacek <polacek@redhat.com>
* ubsan.c (ubsan_type_descriptor): If varpool_get_node returns NULL

View File

@ -1,3 +1,8 @@
2013-11-27 Richard Biener <rguenther@suse.de>
PR tree-optimization/59288
* gcc.dg/torture/pr59288.c: New testcase.
2013-11-27 Marek Polacek <polacek@redhat.com>
* c-c++-common/ubsan/undefined-1.c: New test.

View File

@ -0,0 +1,9 @@
/* { dg-do compile } */
void
baz (int *d)
{
long int i, j, k;
for (i = 0, j = 0, k = 0; i < 512; i = (int) i + 1, j = (int) j + 1, k = (int) k + 3)
d[i] = j ^ (i * 3) ^ (2 * k + 2);
}

View File

@ -3199,7 +3199,6 @@ get_initial_def_for_induction (gimple iv_phi)
struct loop *iv_loop;
basic_block new_bb;
tree new_vec, vec_init, vec_step, t;
tree access_fn;
tree new_var;
tree new_name;
gimple init_stmt, induction_phi, new_stmt;
@ -3207,7 +3206,6 @@ get_initial_def_for_induction (gimple iv_phi)
tree init_expr, step_expr;
int vf = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
int i;
bool ok;
int ncopies;
tree expr;
stmt_vec_info phi_info = vinfo_for_stmt (iv_phi);
@ -3236,13 +3234,12 @@ get_initial_def_for_induction (gimple iv_phi)
latch_e = loop_latch_edge (iv_loop);
loop_arg = PHI_ARG_DEF_FROM_EDGE (iv_phi, latch_e);
access_fn = analyze_scalar_evolution (iv_loop, PHI_RESULT (iv_phi));
gcc_assert (access_fn);
STRIP_NOPS (access_fn);
ok = vect_is_simple_iv_evolution (iv_loop->num, access_fn,
&init_expr, &step_expr);
gcc_assert (ok);
step_expr = STMT_VINFO_LOOP_PHI_EVOLUTION_PART (phi_info);
gcc_assert (step_expr != NULL_TREE);
pe = loop_preheader_edge (iv_loop);
init_expr = PHI_ARG_DEF_FROM_EDGE (iv_phi,
loop_preheader_edge (iv_loop));
vectype = get_vectype_for_scalar_type (TREE_TYPE (init_expr));
resvectype = get_vectype_for_scalar_type (TREE_TYPE (PHI_RESULT (iv_phi)));
@ -3253,6 +3250,16 @@ get_initial_def_for_induction (gimple iv_phi)
gcc_assert (phi_info);
gcc_assert (ncopies >= 1);
/* Convert the step to the desired type. */
step_expr = force_gimple_operand (fold_convert (TREE_TYPE (vectype),
step_expr),
&stmts, true, NULL_TREE);
if (stmts)
{
new_bb = gsi_insert_seq_on_edge_immediate (pe, stmts);
gcc_assert (!new_bb);
}
/* Find the first insertion point in the BB. */
si = gsi_after_labels (bb);
@ -3262,9 +3269,7 @@ get_initial_def_for_induction (gimple iv_phi)
/* iv_loop is nested in the loop to be vectorized. init_expr had already
been created during vectorization of previous stmts. We obtain it
from the STMT_VINFO_VEC_STMT of the defining stmt. */
tree iv_def = PHI_ARG_DEF_FROM_EDGE (iv_phi,
loop_preheader_edge (iv_loop));
vec_init = vect_get_vec_def_for_operand (iv_def, iv_phi, NULL);
vec_init = vect_get_vec_def_for_operand (init_expr, iv_phi, NULL);
/* If the initial value is not of proper type, convert it. */
if (!useless_type_conversion_p (vectype, TREE_TYPE (vec_init)))
{