From fe0b4796ad3fe8ec17de328a628d39a100b17d7c Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Mon, 18 Feb 2013 13:58:21 +0000 Subject: [PATCH] re PR tree-optimization/56366 (ICE: verify_gimple failed (incompatible types in PHI argument)) 2013-02-18 Richard Biener PR tree-optimization/56366 * tree-vect-loop.c (get_initial_def_for_induction): Properly handle sign-conversion of outer-loop initial induction value. * gcc.dg/torture/pr56366.c: New testcase. From-SVN: r196121 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/torture/pr56366.c | 17 +++++++++++++++++ gcc/tree-vect-loop.c | 15 +++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/torture/pr56366.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ba374a184b5..0caa412055f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2013-02-18 Richard Biener + + PR tree-optimization/56366 + * tree-vect-loop.c (get_initial_def_for_induction): Properly + handle sign-conversion of outer-loop initial induction value. + 2013-02-18 Richard Biener PR middle-end/56349 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0c88ce2e0e0..fe995e8e0ea 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-02-18 Richard Biener + + PR tree-optimization/56366 + * gcc.dg/torture/pr56366.c: New testcase. + 2013-02-18 Richard Biener PR middle-end/56349 diff --git a/gcc/testsuite/gcc.dg/torture/pr56366.c b/gcc/testsuite/gcc.dg/torture/pr56366.c new file mode 100644 index 00000000000..15a43004823 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr56366.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ + +int a, *c, d; +unsigned short b; +short e; + +void f(void) +{ + for(;; d++) + { + for(a = -9; a < 63; a++) + for(d = 0; d < 9; d++) + b -= --e; + + a = b & *c; + } +} diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index d4f6bc72451..a2f90138fc9 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -3203,6 +3203,21 @@ get_initial_def_for_induction (gimple iv_phi) 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); + /* If the initial value is not of proper type, convert it. */ + if (!useless_type_conversion_p (vectype, TREE_TYPE (vec_init))) + { + new_stmt = gimple_build_assign_with_ops + (VIEW_CONVERT_EXPR, + vect_get_new_vect_var (vectype, vect_simple_var, "vec_iv_"), + build1 (VIEW_CONVERT_EXPR, vectype, vec_init), NULL_TREE); + vec_init = make_ssa_name (gimple_assign_lhs (new_stmt), new_stmt); + gimple_assign_set_lhs (new_stmt, vec_init); + new_bb = gsi_insert_on_edge_immediate (loop_preheader_edge (iv_loop), + new_stmt); + gcc_assert (!new_bb); + set_vinfo_for_stmt (new_stmt, + new_stmt_vec_info (new_stmt, loop_vinfo, NULL)); + } } else {