From: Richard Biener Date: Mon, 12 Jun 2017 10:42:57 +0000 (+0000) Subject: re PR tree-optimization/81053 (ICE on valid code at -O3 on x86_64-linux-gnu: in as_a... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3fd7fe218b325a5b3d1bd38b12ab0e6d00e1e7dc;p=gcc.git re PR tree-optimization/81053 (ICE on valid code at -O3 on x86_64-linux-gnu: in as_a, at is-a.h:192) 2017-06-12 Richard Biener PR tree-optimization/81053 * tree-vect-loop.c (vect_is_simple_reduction): Handle PHI with backedge value not defined in loop. Simplify def stmt compute. * gcc.dg/torture/pr81053.c: New testcase. From-SVN: r249113 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 192e8698f4d..9a95c6ce5cb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-06-12 Richard Biener + + PR tree-optimization/81053 + * tree-vect-loop.c (vect_is_simple_reduction): Handle PHI + with backedge value not defined in loop. Simplify def stmt + compute. + 2017-06-11 Tom de Vries PR target/79939 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 531c7879961..71be107cae2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-06-12 Richard Biener + + PR tree-optimization/81053 + * gcc.dg/torture/pr81053.c: New testcase. + 2017-06-10 Thomas Koenig PR fortran/80988 diff --git a/gcc/testsuite/gcc.dg/torture/pr81053.c b/gcc/testsuite/gcc.dg/torture/pr81053.c new file mode 100644 index 00000000000..98ab95dadeb --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr81053.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +int a, b[2], c, d; + +void fn1 () +{ + for (; d < 2; d++) + { + b[d] = a; + a = c; + } +} diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 64cf05dea57..cf9cd3b5073 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -2790,15 +2790,17 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi, } def_stmt = SSA_NAME_DEF_STMT (loop_arg); - if (gimple_nop_p (def_stmt)) + if (is_gimple_assign (def_stmt)) { - if (dump_enabled_p ()) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "reduction: no def_stmt\n"); - return NULL; + name = gimple_assign_lhs (def_stmt); + phi_def = false; } - - if (!is_gimple_assign (def_stmt) && gimple_code (def_stmt) != GIMPLE_PHI) + else if (gimple_code (def_stmt) == GIMPLE_PHI) + { + name = PHI_RESULT (def_stmt); + phi_def = true; + } + else { if (dump_enabled_p ()) { @@ -2809,37 +2811,27 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi, return NULL; } - if (is_gimple_assign (def_stmt)) - { - name = gimple_assign_lhs (def_stmt); - phi_def = false; - } - else - { - name = PHI_RESULT (def_stmt); - phi_def = true; - } - nloop_uses = 0; auto_vec lcphis; - FOR_EACH_IMM_USE_FAST (use_p, imm_iter, name) - { - gimple *use_stmt = USE_STMT (use_p); - if (is_gimple_debug (use_stmt)) - continue; - if (flow_bb_inside_loop_p (loop, gimple_bb (use_stmt))) - nloop_uses++; - else - /* We can have more than one loop-closed PHI. */ - lcphis.safe_push (as_a (use_stmt)); - if (nloop_uses > 1) - { - if (dump_enabled_p ()) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "reduction used in loop.\n"); - return NULL; - } - } + if (flow_bb_inside_loop_p (loop, gimple_bb (def_stmt))) + FOR_EACH_IMM_USE_FAST (use_p, imm_iter, name) + { + gimple *use_stmt = USE_STMT (use_p); + if (is_gimple_debug (use_stmt)) + continue; + if (flow_bb_inside_loop_p (loop, gimple_bb (use_stmt))) + nloop_uses++; + else + /* We can have more than one loop-closed PHI. */ + lcphis.safe_push (as_a (use_stmt)); + if (nloop_uses > 1) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "reduction used in loop.\n"); + return NULL; + } + } /* If DEF_STMT is a phi node itself, we expect it to have a single argument defined in the inner loop. */