Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.
Richard. 2019-11-18 Richard Biener <rguent...@suse.de> PR tree-optimization/92558 * tree-vect-loop.c (vect_create_epilog_for_reduction): When reducting the width of a reduction vector def update new_phis. * gcc.dg/vect/pr92558.c: New testcase. Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c (revision 278389) +++ gcc/tree-vect-loop.c (working copy) @@ -5198,6 +5198,7 @@ vect_create_epilog_for_reduction (stmt_v new_temp = make_ssa_name (vectype1); epilog_stmt = gimple_build_assign (new_temp, code, dst1, dst2); gsi_insert_before (&exit_gsi, epilog_stmt, GSI_SAME_STMT); + new_phis[0] = epilog_stmt; } if (reduce_with_shift && !slp_reduc) Index: gcc/testsuite/gcc.dg/vect/pr92558.c =================================================================== --- gcc/testsuite/gcc.dg/vect/pr92558.c (nonexistent) +++ gcc/testsuite/gcc.dg/vect/pr92558.c (working copy) @@ -0,0 +1,23 @@ +/* { dg-additional-options "-mavx2" { target avx2_runtime } } */ + +void __attribute__((noipa)) +foo (int * __restrict wsum, int * __restrict cff, int * __restrict weight) +{ + for (int i = 0; i < 16; ++i) + { + *wsum += weight[2*i+0]; + *cff += weight[2*i+1]; + } +} + +int main() +{ + int weight[32]; + for (int i = 0; i < 32; ++i) + weight[i] = i; + int wsum = 0, cff = 0; + foo (&wsum, &cff, weight); + if (wsum != 240 || cff != 256) + __builtin_abort (); + return 0; +}