Richard Sandiford <richard.sandif...@arm.com> writes: > The series to remove vinfo_for_stmt also removed tests of > flow_bb_inside_loop_p if the call was simply testing whether the > statement was in the vectorisation region. I'd tried to keep calls > that were testing whether the statement was in a particular loop > (inner or outer), but messed up in vect_is_simple_reduction and > removed calls that were actually needed. This patch restores them. > > I double-checked the other removed calls and I think these are > the only ones affected. > > Tested on aarch64-linux-gnu (with and without SVE), aarch64_be-elf and > x86_64-linux-gnu. Applied as obvious, on the basis that it's simply > reverting part of my own patch. > > Richard > > > 2018-08-08 Richard Sandiford <richard.sandif...@arm.com> > > gcc/ > PR tree-optimization/86858 > * tree-vect-loop.c (vect_is_simple_reduction): Restore > flow_bb_inside_loop_p calls. > > gcc/testsuite/ > PR tree-optimization/86858 > * gcc.dg/vect/pr86858.c: New test.
Sorry, patch was: Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c 2018-08-09 15:38:35.230258362 +0100 +++ gcc/tree-vect-loop.c 2018-08-09 15:41:10.672888995 +0100 @@ -2922,7 +2922,8 @@ vect_is_simple_reduction (loop_vec_info } stmt_vec_info def_stmt_info = loop_info->lookup_def (loop_arg); - if (!def_stmt_info) + if (!def_stmt_info + || !flow_bb_inside_loop_p (loop, gimple_bb (def_stmt_info->stmt))) return NULL; if (gassign *def_stmt = dyn_cast <gassign *> (def_stmt_info->stmt)) @@ -3161,6 +3162,7 @@ vect_is_simple_reduction (loop_vec_info && def2_info->stmt == phi && (code == COND_EXPR || !def1_info + || !flow_bb_inside_loop_p (loop, gimple_bb (def1_info->stmt)) || vect_valid_reduction_input_p (def1_info))) { if (dump_enabled_p ()) @@ -3172,6 +3174,7 @@ vect_is_simple_reduction (loop_vec_info && def1_info->stmt == phi && (code == COND_EXPR || !def2_info + || !flow_bb_inside_loop_p (loop, gimple_bb (def2_info->stmt)) || vect_valid_reduction_input_p (def2_info))) { if (! nested_in_vect_loop && orig_code != MINUS_EXPR) Index: gcc/testsuite/gcc.dg/vect/pr86858.c =================================================================== --- /dev/null 2018-07-26 10:26:13.137955424 +0100 +++ gcc/testsuite/gcc.dg/vect/pr86858.c 2018-08-09 15:41:10.672888995 +0100 @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +int a, b, c, d; +char e(char f, char g) { return f + g; } +void h() { + for (; c; ++c) { + d = 0; + for (; d != 8; d = e(d, 3)) { + a = b && a; + b = c; + } + } +}