From 43ad66aa4a3c9eaec46354dcddaadebd3df71f69 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 27 Nov 2013 08:50:15 +0000 Subject: [PATCH] re PR tree-optimization/59288 (ICE in get_initial_def_for_induction) 2013-11-27 Richard Biener 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 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/torture/pr59288.c | 9 +++++++++ gcc/tree-vect-loop.c | 27 ++++++++++++++++----------- 4 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr59288.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 736b2c2b8f9..43383ffa098 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2013-11-27 Richard Biener + + 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 * ubsan.c (ubsan_type_descriptor): If varpool_get_node returns NULL diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 61fe795127f..2edd80b94d7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-11-27 Richard Biener + + PR tree-optimization/59288 + * gcc.dg/torture/pr59288.c: New testcase. + 2013-11-27 Marek Polacek * c-c++-common/ubsan/undefined-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/torture/pr59288.c b/gcc/testsuite/gcc.dg/torture/pr59288.c new file mode 100644 index 00000000000..8331e73289c --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr59288.c @@ -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); +} diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index c91c2e1b427..50c9d9caa34 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -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))) { -- 2.11.4.GIT